From bf43262a8eb107abd6c33021eff3b7f34d0cb40e Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Fri, 9 Dec 2022 17:36:26 +0100 Subject: [PATCH] add support for DropshipDeploy --- EDPlayerJournal/BGS/TransactionParser.cs | 14 ++++- .../Entries/DropshipDeployEntry.cs | 42 +++++++++++++ EDPlayerJournal/Entries/Entry.cs | 1 + EDPlayerJournal/Entries/Events.cs | 1 + EDPlayerJournalTests/CombatZoneTest.cs | 28 +++++++++ .../EDPlayerJournalTests.csproj | 3 + EDPlayerJournalTests/dropship-deploy.txt | 63 +++++++++++++++++++ 7 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 EDPlayerJournal/Entries/DropshipDeployEntry.cs create mode 100644 EDPlayerJournalTests/CombatZoneTest.cs create mode 100644 EDPlayerJournalTests/dropship-deploy.txt diff --git a/EDPlayerJournal/BGS/TransactionParser.cs b/EDPlayerJournal/BGS/TransactionParser.cs index cbab466..1d82c83 100644 --- a/EDPlayerJournal/BGS/TransactionParser.cs +++ b/EDPlayerJournal/BGS/TransactionParser.cs @@ -83,7 +83,7 @@ internal class TransactionParserContext { return; } - if (OnFootKills > 0) { + if (OnFootKills > 0 || IsOnFoot == true) { cztype = CombatZones.GroundCombatZone; // High on foot combat zones have enforcers that bring 80k a pop if (highest >= 80000) { @@ -93,7 +93,7 @@ internal class TransactionParserContext { } else { grade = CombatZones.DifficultyLow; } - } else if (ShipKills > 0) { + } else if (ShipKills > 0 && !IsOnFoot) { // Ship combat zones can be identified by the amount of kills if (ShipKills > 20) { grade = CombatZones.DifficultyHigh; @@ -832,6 +832,8 @@ internal class EmbarkDisembarkParser : TransactionParserPart { internal class SupercruiseEntryParser : TransactionParserPart { public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) { + // After a super cruise entry we are no longer on foot. + context.IsOnFoot = false; context.DiscernCombatZone(transactions, entry); context.ResetCombatZone(); } @@ -892,6 +894,13 @@ internal class DiedParser : TransactionParserPart { } } +internal class DropshipDeployParser : TransactionParserPart { + public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) { + // On drop ship deploy we are now on foot + context.IsOnFoot = true; + } +} + public class TransactionParser { private static Dictionary ParserParts { get; } = new() { @@ -900,6 +909,7 @@ public class TransactionParser { { Events.Died, new DiedParser() }, { Events.Disembark, new EmbarkDisembarkParser() }, { Events.Docked, new DockedParser() }, + { Events.DropshipDeploy, new DropshipDeployParser() }, { Events.Embark, new EmbarkDisembarkParser() }, { Events.FactionKillBond, new FactionKillBondParser() }, { Events.FileHeader, new FileHeaderParser() }, diff --git a/EDPlayerJournal/Entries/DropshipDeployEntry.cs b/EDPlayerJournal/Entries/DropshipDeployEntry.cs new file mode 100644 index 0000000..5a33cd7 --- /dev/null +++ b/EDPlayerJournal/Entries/DropshipDeployEntry.cs @@ -0,0 +1,42 @@ +namespace EDPlayerJournal.Entries; + +public class DropshipDeployEntry : Entry { + /// + /// Star system this drop happened in. + /// + public string? StarSystem { get; set; } + + /// + /// System address + /// + public ulong? SystemAddress { get; set; } + + /// + /// Planetary body + /// + public string? Body { get; set; } + + /// + /// Body ID + /// + public ulong? BodyID { get; set; } + + /// + /// Whether it happened on station. + /// + public bool? OnStation { get; set; } + + /// + /// Whether it happened on a planet. + /// + public bool? OnPlanet { get; set; } + + protected override void Initialise() { + StarSystem = JSON.Value("StarSystem"); + SystemAddress = JSON.Value("SystemAddress"); + Body = JSON.Value("Body"); + BodyID = JSON.Value("BodyID"); + OnStation = JSON.Value("OnStation"); + OnPlanet = JSON.Value("OnPlanet"); + } +} diff --git a/EDPlayerJournal/Entries/Entry.cs b/EDPlayerJournal/Entries/Entry.cs index dcf5b81..2db9cf6 100644 --- a/EDPlayerJournal/Entries/Entry.cs +++ b/EDPlayerJournal/Entries/Entry.cs @@ -19,6 +19,7 @@ public class Entry { { Events.Died, typeof(DiedEntry) }, { Events.Disembark, typeof(DisembarkEntry) }, { Events.Docked, typeof(DockedEntry) }, + { Events.DropshipDeploy, typeof(DropshipDeployEntry) }, { Events.Embark, typeof(EmbarkEntry) }, { Events.FactionKillBond, typeof(FactionKillBondEntry) }, { Events.FileHeader, typeof(FileHeaderEntry) }, diff --git a/EDPlayerJournal/Entries/Events.cs b/EDPlayerJournal/Entries/Events.cs index 94624b3..b8f1388 100644 --- a/EDPlayerJournal/Entries/Events.cs +++ b/EDPlayerJournal/Entries/Events.cs @@ -8,6 +8,7 @@ public class Events { public static readonly string Died = "Died"; public static readonly string Disembark = "Disembark"; public static readonly string Docked = "Docked"; + public static readonly string DropshipDeploy = "DropshipDeploy"; public static readonly string Embark = "Embark"; public static readonly string FactionKillBond = "FactionKillBond"; public static readonly string FighterDestroyed = "FighterDestroyed"; diff --git a/EDPlayerJournalTests/CombatZoneTest.cs b/EDPlayerJournalTests/CombatZoneTest.cs new file mode 100644 index 0000000..a185baf --- /dev/null +++ b/EDPlayerJournalTests/CombatZoneTest.cs @@ -0,0 +1,28 @@ +using EDPlayerJournal; +using EDPlayerJournal.Entries; +using EDPlayerJournal.BGS; + +namespace EDPlayerJournalTests; + +[TestClass] +public class CombatZoneTest { + [TestMethod] + public void DropshipDeployTest() { + TransactionParser parser = new(); + + List? entries = Helper.LoadTestData("dropship-deploy.txt"); + Assert.IsNotNull(entries); + + List? transactions = parser.Parse(entries); + Assert.IsNotNull(transactions); + + Vouchers? vouchers = transactions[0] as Vouchers; + Assert.IsNotNull(vouchers); + + CombatZone? combatzone = transactions[1] as CombatZone; + Assert.IsNotNull(combatzone); + + Assert.AreEqual(combatzone.Type, CombatZones.GroundCombatZone); + Assert.AreEqual(combatzone.Grade, CombatZones.DifficultyHigh); + } +} diff --git a/EDPlayerJournalTests/EDPlayerJournalTests.csproj b/EDPlayerJournalTests/EDPlayerJournalTests.csproj index 7eb4735..b62a8f9 100644 --- a/EDPlayerJournalTests/EDPlayerJournalTests.csproj +++ b/EDPlayerJournalTests/EDPlayerJournalTests.csproj @@ -26,6 +26,9 @@ Always + + Always + Always diff --git a/EDPlayerJournalTests/dropship-deploy.txt b/EDPlayerJournalTests/dropship-deploy.txt new file mode 100644 index 0000000..364e7ed --- /dev/null +++ b/EDPlayerJournalTests/dropship-deploy.txt @@ -0,0 +1,63 @@ +{"timestamp":"2022-12-09T14:23:52Z","event":"Fileheader","part":1,"language":"English/UK","Odyssey":true,"gameversion":"4.0.0.1476","build":"r289925/r0 "} +{"timestamp":"2022-12-09T14:33:01Z","event":"Location","DistFromStarLS":774.492896,"Docked":false,"OnFoot":true,"StarSystem":"Kazahua","SystemAddress":2871050905001,"StarPos":[93.28125,-180.25,14.6875],"SystemAllegiance":"Empire","SystemEconomy":"$economy_Industrial;","SystemEconomy_Localised":"Industrial","SystemSecondEconomy":"$economy_Colony;","SystemSecondEconomy_Localised":"Colony","SystemGovernment":"$government_Patronage;","SystemGovernment_Localised":"Patronage","SystemSecurity":"$SYSTEM_SECURITY_low;","SystemSecurity_Localised":"Low Security","Population":17949,"Body":"Kazahua 4 a","BodyID":5,"BodyType":"Planet","Factions":[{"Name":"Kazahua Co","FactionState":"None","Government":"Corporate","Influence":0.049098,"Allegiance":"Empire","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","MyReputation":0.0},{"Name":"Kazahua Crimson Ring","FactionState":"None","Government":"Anarchy","Influence":0.01002,"Allegiance":"Independent","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","MyReputation":0.0},{"Name":"HIP 10611 Shared","FactionState":"None","Government":"Cooperative","Influence":0.091182,"Allegiance":"Independent","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","MyReputation":2.97},{"Name":"Traditional Yao Tzu Liberty Party","FactionState":"None","Government":"Dictatorship","Influence":0.058116,"Allegiance":"Empire","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","MyReputation":-10.56},{"Name":"Sapii allied","FactionState":"War","Government":"Cooperative","Influence":0.395792,"Allegiance":"Independent","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","MyReputation":-6.0,"ActiveStates":[{"State":"War"}]},{"Name":"Nova Paresa","FactionState":"War","Government":"Patronage","Influence":0.395792,"Allegiance":"Empire","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","SquadronFaction":true,"MyReputation":63.045399,"ActiveStates":[{"State":"War"}]}],"SystemFaction":{"Name":"Nova Paresa","FactionState":"War"},"Conflicts":[{"WarType":"war","Status":"active","Faction1":{"Name":"Sapii allied","Stake":"Barmin Installation","WonDays":0},"Faction2":{"Name":"Nova Paresa","Stake":"Rabinowitz Colony","WonDays":0}}]} +{"timestamp":"2022-12-09T14:33:05Z","event":"ReceiveText","From":"Barmin Installation","Message":"$STATION_NoFireZone_entered;","Message_Localised":"No fire zone entered.","Channel":"npc"} +{"timestamp":"2022-12-09T14:36:52Z","event":"ReceiveText","From":"$ShipName_Police_Independent;","From_Localised":"System Authority Vessel","Message":"$Police_EndPatrol02;","Message_Localised":"Requesting docking clearance, Control.","Channel":"npc"} +{"timestamp":"2022-12-09T14:39:54Z","event":"ReceiveText","From":"$ShipName_Police_Independent;","From_Localised":"System Authority Vessel","Message":"$Police_StartPatrol01;","Message_Localised":"Patrol craft checking in. Pre-flight checks complete, I'm heading out.","Channel":"npc"} +{"timestamp":"2022-12-09T14:42:02Z","event":"ReceiveText","From":"$ShipName_Police_Independent;","From_Localised":"System Authority Vessel","Message":"$Police_EndPatrol04;","Message_Localised":"Negative, Tower, I'm bingo on fuel, RTB.","Channel":"npc"} +{"timestamp":"2022-12-09T14:42:05Z","event":"ReceiveText","From":"$ShipName_Police_Independent;","From_Localised":"System Authority Vessel","Message":"$Police_EndPatrol02;","Message_Localised":"Requesting docking clearance, Control.","Channel":"npc"} +{"timestamp":"2022-12-09T14:45:23Z","event":"ReceiveText","From":"$ShipName_Police_Independent;","From_Localised":"System Authority Vessel","Message":"$Police_StartPatrol01;","Message_Localised":"Patrol craft checking in. Pre-flight checks complete, I'm heading out.","Channel":"npc"} +{"timestamp":"2022-12-09T14:45:51Z","event":"ReceiveText","From":"$ShipName_Police_Independent;","From_Localised":"System Authority Vessel","Message":"$Police_StartPatrol04;","Message_Localised":"I'm away, heading to patrol route alpha now.","Channel":"npc"} +{"timestamp":"2022-12-09T14:46:22Z","event":"RedeemVoucher","Type":"CombatBond","Amount":17406041,"Faction":"Nova Paresa"} +{"timestamp":"2022-12-09T14:49:17Z","event":"ReceiveText","From":"$ShipName_Police_Independent;","From_Localised":"System Authority Vessel","Message":"$Police_EndPatrol02;","Message_Localised":"Requesting docking clearance, Control.","Channel":"npc"} +{"timestamp":"2022-12-09T14:49:43Z","event":"ReceiveText","From":"$ShipName_Police_Independent;","From_Localised":"System Authority Vessel","Message":"$Police_EndPatrol05;","Message_Localised":"Patrol completed, Command, I'm heading home.","Channel":"npc"} +{"timestamp":"2022-12-09T14:52:32Z","event":"ReceiveText","From":"$ShipName_Police_Independent;","From_Localised":"System Authority Vessel","Message":"$Police_StartPatrol01;","Message_Localised":"Patrol craft checking in. Pre-flight checks complete, I'm heading out.","Channel":"npc"} +{"timestamp":"2022-12-09T14:52:34Z","event":"Embark","SRV":false,"Taxi":true,"Multicrew":false,"StarSystem":"Kazahua","SystemAddress":2871050905001,"Body":"Kazahua 4 a","BodyID":5,"OnStation":false,"OnPlanet":true} +{"timestamp":"2022-12-09T14:53:29Z","event":"SupercruiseEntry","Taxi":true,"Multicrew":false,"StarSystem":"Kazahua","SystemAddress":2871050905001} +{"timestamp":"2022-12-09T14:58:16Z","event":"DropshipDeploy","StarSystem":"Kazahua","SystemAddress":2871050905001,"Body":"Kazahua 2","BodyID":2,"OnStation":false,"OnPlanet":true} +{"timestamp":"2022-12-09T14:59:38Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:00:02Z","event":"FactionKillBond","Reward":52500,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:00:12Z","event":"FactionKillBond","Reward":39642,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:00:33Z","event":"FactionKillBond","Reward":52500,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:00:45Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:01:07Z","event":"FactionKillBond","Reward":87362,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:01:11Z","event":"ReceiveText","From":"$ShipName_Military_Independent;","From_Localised":"System Defence Force","Message":"$Military_Passthrough06;","Message_Localised":"On patrol. Scanning for hostiles.","Channel":"npc"} +{"timestamp":"2022-12-09T15:02:12Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:02:21Z","event":"FactionKillBond","Reward":52500,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:02:24Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:02:32Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:02:42Z","event":"FactionKillBond","Reward":87362,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:02:45Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:02:50Z","event":"ReceiveText","From":"$ShipName_Military_Independent;","From_Localised":"System Defence Force","Message":"$Military_Passthrough09;","Message_Localised":"This is a routine patrol. There's nothing to worry about.","Channel":"npc"} +{"timestamp":"2022-12-09T15:04:03Z","event":"FactionKillBond","Reward":39642,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:04:03Z","event":"ReceiveText","From":"$ShipName_Military_Independent;","From_Localised":"System Defence Force","Message":"$Military_Passthrough06;","Message_Localised":"On patrol. Scanning for hostiles.","Channel":"npc"} +{"timestamp":"2022-12-09T15:04:09Z","event":"FactionKillBond","Reward":52500,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:04:13Z","event":"FactionKillBond","Reward":87362,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:04:25Z","event":"FactionKillBond","Reward":87362,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:05:06Z","event":"ReceiveText","From":"$ShipName_Military_Independent;","From_Localised":"System Defence Force","Message":"$Military_Passthrough06;","Message_Localised":"On patrol. Scanning for hostiles.","Channel":"npc"} +{"timestamp":"2022-12-09T15:05:10Z","event":"ReceiveText","From":"$ShipName_Military_Independent;","From_Localised":"System Defence Force","Message":"$Military_Passthrough10;","Message_Localised":"System sweep in operation.","Channel":"npc"} +{"timestamp":"2022-12-09T15:05:19Z","event":"ReceiveText","From":"$ShipName_Military_Independent;","From_Localised":"System Defence Force","Message":"$Military_Passthrough06;","Message_Localised":"On patrol. Scanning for hostiles.","Channel":"npc"} +{"timestamp":"2022-12-09T15:05:22Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:05:35Z","event":"FactionKillBond","Reward":87362,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:05:44Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:06:11Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:06:22Z","event":"ReceiveText","From":"$ShipName_Military_Independent;","From_Localised":"System Defence Force","Message":"$Military_Passthrough08;","Message_Localised":"Patrol waypoint reached. Scanning.","Channel":"npc"} +{"timestamp":"2022-12-09T15:06:27Z","event":"FactionKillBond","Reward":52500,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:06:27Z","event":"FactionKillBond","Reward":39642,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:06:39Z","event":"FactionKillBond","Reward":52500,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:06:44Z","event":"ReceiveText","From":"$ShipName_Military_Independent;","From_Localised":"System Defence Force","Message":"$Military_Passthrough09;","Message_Localised":"This is a routine patrol. There's nothing to worry about.","Channel":"npc"} +{"timestamp":"2022-12-09T15:06:50Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:07:03Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:07:11Z","event":"FactionKillBond","Reward":39642,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:07:15Z","event":"FactionKillBond","Reward":52500,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:07:26Z","event":"FactionKillBond","Reward":87362,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:08:20Z","event":"FactionKillBond","Reward":52500,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:08:26Z","event":"FactionKillBond","Reward":65358,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:08:29Z","event":"ReceiveText","From":"$ShipName_Military_Independent;","From_Localised":"System Defence Force","Message":"$Military_Passthrough07;","Message_Localised":"No need to worry, the navy is here.","Channel":"npc"} +{"timestamp":"2022-12-09T15:08:33Z","event":"FactionKillBond","Reward":87362,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:08:47Z","event":"FactionKillBond","Reward":87362,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:08:48Z","event":"FactionKillBond","Reward":87362,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:09:00Z","event":"FactionKillBond","Reward":39642,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:09:00Z","event":"FactionKillBond","Reward":39642,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:09:08Z","event":"FactionKillBond","Reward":39642,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:09:20Z","event":"FactionKillBond","Reward":78777,"AwardingFaction":"Nova Paresa","VictimFaction":"Sapii allied"} +{"timestamp":"2022-12-09T15:09:46Z","event":"Shutdown"} \ No newline at end of file