From 67966ca27a7f21f5941ebd271ed765fc362ef20a Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Sat, 3 Dec 2022 14:42:32 +0100 Subject: [PATCH] add code to detect thargoid combat zones --- EDPlayerJournal/BGS/CombatZone.cs | 10 ++++++--- EDPlayerJournal/BGS/TransactionParser.cs | 28 +++++++++++++++++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/EDPlayerJournal/BGS/CombatZone.cs b/EDPlayerJournal/BGS/CombatZone.cs index 09be364..ee37f12 100644 --- a/EDPlayerJournal/BGS/CombatZone.cs +++ b/EDPlayerJournal/BGS/CombatZone.cs @@ -9,9 +9,9 @@ public class CombatZone : Transaction { public string Type { get; set; } = CombatZones.ShipCombatZone; /// - /// Difficulty type, low, medium or high. + /// Difficulty type, low, medium or high. Null means unknown. /// - public string Grade { get; set; } = CombatZones.DifficultyLow; + public string? Grade { get; set; } /// /// Whether spec ops were won. @@ -91,6 +91,10 @@ public class CombatZone : Transaction { } public override string ToString() { - return string.Format("Won {0} {1} Combat Zone", Grade, Type); + if (Grade != null) { + return string.Format("Won {0} {1} Combat Zone", Grade, Type); + } else { + return string.Format("Won {0} Combat Zone", Type); + } } } diff --git a/EDPlayerJournal/BGS/TransactionParser.cs b/EDPlayerJournal/BGS/TransactionParser.cs index ec37d2e..022c5bb 100644 --- a/EDPlayerJournal/BGS/TransactionParser.cs +++ b/EDPlayerJournal/BGS/TransactionParser.cs @@ -34,6 +34,16 @@ internal class TransactionParserContext { /// public ulong ShipKills { get; set; } = 0; + /// + /// Thargoid scouts killed + /// + public ulong ThargoidScoutKills { get; set; } = 0; + + /// + /// Thargoid interceptor kills + /// + public ulong ThargoidInterceptorKills { get; set; } = 0; + /// /// A list of accepted missions index by their mission ID /// @@ -57,7 +67,7 @@ internal class TransactionParserContext { public Dictionary BuyCost = new(); public void DiscernCombatZone(TransactionList transactions, Entry e) { - string grade = CombatZones.DifficultyLow; + string? grade = CombatZones.DifficultyLow; string cztype; ulong? highest = HighestCombatBond; @@ -100,6 +110,11 @@ internal class TransactionParserContext { } } cztype = CombatZones.ShipCombatZone; + } else if (ThargoidScoutKills > 0 && ThargoidInterceptorKills > 0) { + // Could be a thargoid combat zones if interceptors and scouts are there + cztype = CombatZones.ThargoidCombatZone; + // Still unknown + grade = null; } else { transactions.AddIncomplete(new CombatZone(), "Failed to discern combat zone type"); return; @@ -144,6 +159,8 @@ internal class TransactionParserContext { LastRecordedAwardingFaction = null; OnFootKills = 0; ShipKills = 0; + ThargoidInterceptorKills = 0; + ThargoidScoutKills = 0; } public void BoughtCargo(string? cargo, long? cost) { @@ -776,6 +793,15 @@ internal class FactionKillBondParser : TransactionParserPart { IsLegacy = context.IsLegacy, }); + ThargoidVessel vessel = Thargoid.GetVesselByPayout(entry.Reward); + if (vessel != ThargoidVessel.Unknown) { + if (vessel == ThargoidVessel.Scout) { + ++context.ThargoidScoutKills; + } else { + ++context.ThargoidInterceptorKills; + } + } + // We are done return; }