diff --git a/EDPlayerJournal/BGS/TransactionParser.cs b/EDPlayerJournal/BGS/TransactionParser.cs index 0177481..a15779f 100644 --- a/EDPlayerJournal/BGS/TransactionParser.cs +++ b/EDPlayerJournal/BGS/TransactionParser.cs @@ -44,6 +44,11 @@ internal class TransactionParserContext { /// public ulong ThargoidInterceptorKills { get; set; } = 0; + /// + /// Whether we have seen an AX warzone NPC talk to us with ReceiveText + /// + public bool HaveSeenAXWarzoneNPC { get; set; } = false; + /// /// A list of accepted missions index by their mission ID /// @@ -69,11 +74,8 @@ internal class TransactionParserContext { public void DiscernCombatZone(TransactionList transactions, Entry e) { string? grade = CombatZones.DifficultyLow; string cztype; - ulong? highest = HighestCombatBond; - - if (highest == null || LastRecordedAwardingFaction == null) { - return; - } + ulong highest = HighestCombatBond ?? 0; + string? faction = LastRecordedAwardingFaction; if (OnFootKills > 0) { cztype = CombatZones.GroundCombatZone; @@ -110,7 +112,8 @@ internal class TransactionParserContext { } } cztype = CombatZones.ShipCombatZone; - } else if (ThargoidScoutKills > 0 && ThargoidInterceptorKills > 0) { + } else if ((ThargoidScoutKills > 0 && ThargoidInterceptorKills > 0) || + HaveSeenAXWarzoneNPC == true) { // Could be a thargoid combat zones if interceptors and scouts are there cztype = CombatZones.AXCombatZone; // Still unknown @@ -122,7 +125,7 @@ internal class TransactionParserContext { CombatZone zone = new CombatZone() { System = CurrentSystem, - Faction = LastRecordedAwardingFaction, + Faction = faction, IsLegacy = IsLegacy, Grade = grade, Type = cztype, @@ -161,6 +164,7 @@ internal class TransactionParserContext { ShipKills = 0; ThargoidInterceptorKills = 0; ThargoidScoutKills = 0; + HaveSeenAXWarzoneNPC = false; } public void BoughtCargo(string? cargo, long? cost) { @@ -856,11 +860,38 @@ internal class FileHeaderParser : TransactionParserPart { } } +internal class ReceiveTextParser : TransactionParserPart { + public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) { + ReceiveTextEntry? receivetext = entry as ReceiveTextEntry; + + if (receivetext == null) { + return; + } + + if (string.Compare(receivetext.Channel, Channels.NPC) != 0) { + return; + } + + if (string.Compare(receivetext.NPCCategory, NPCs.AXMilitary) == 0) { + context.HaveSeenAXWarzoneNPC = true; + } + } +} + +internal class DiedParser : TransactionParserPart { + public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) { + // You can't complete a combat zone if you die in it. Others might keep it open + // for you, but still you will not have completed it unless you jump back in. + context.ResetCombatZone(); + } +} + public class TransactionParser { private static Dictionary ParserParts { get; } = new() { { Events.CapShipBond, new CapShipBondParser() }, { Events.CommitCrime, new CommitCrimeParser() }, + { Events.Died, new DiedParser() }, { Events.Disembark, new EmbarkDisembarkParser() }, { Events.Docked, new DockedParser() }, { Events.Embark, new EmbarkDisembarkParser() }, @@ -874,6 +905,7 @@ public class TransactionParser { { Events.MissionCompleted, new MissionCompletedParser() }, { Events.MissionFailed, new MissionFailedParser() }, { Events.MultiSellExplorationData, new MultiSellExplorationDataParser() }, + { Events.ReceiveText, new ReceiveTextParser() }, { Events.RedeemVoucher, new RedeemVoucherParser() }, { Events.SearchAndRescue, new SearchAndRescueParser() }, { Events.SellExplorationData, new SellExplorationDataParser() }, diff --git a/EDPlayerJournal/Channels.cs b/EDPlayerJournal/Channels.cs new file mode 100644 index 0000000..cf6544f --- /dev/null +++ b/EDPlayerJournal/Channels.cs @@ -0,0 +1,8 @@ +namespace EDPlayerJournal; + +public class Channels { + /// + /// Channel NPCs use to talk to the commander. + /// + public static readonly string NPC = "npc"; +} diff --git a/EDPlayerJournal/Entries/ReceiveTextEntry.cs b/EDPlayerJournal/Entries/ReceiveTextEntry.cs index a8303ee..fbad2d3 100644 --- a/EDPlayerJournal/Entries/ReceiveTextEntry.cs +++ b/EDPlayerJournal/Entries/ReceiveTextEntry.cs @@ -46,7 +46,7 @@ public class ReceiveTextEntry : Entry { return null; } - return parts[0]; + return string.Format("{0};", parts[0]); } } diff --git a/EDPlayerJournal/NPC.cs b/EDPlayerJournal/NPC.cs index 794b73c..1544c05 100644 --- a/EDPlayerJournal/NPC.cs +++ b/EDPlayerJournal/NPC.cs @@ -41,6 +41,11 @@ public class NPCs { /// public static string WarzoneCorrespondent = "$LUASC_Scenario_Warzone_NPC_WarzoneCorrespondent;"; + /// + /// AX Military NPC + /// + public static string AXMilitary = "$Name_AX_Military;"; + /// /// Returns true if the pilotname is either a captain, specops, or correspondent ///