store in the transaction whether it was done in legacy or live

This commit is contained in:
Florian Stinglmayr 2022-11-29 16:30:46 +01:00
parent 91bca70168
commit 712c416725
5 changed files with 70 additions and 0 deletions

View File

@ -21,6 +21,11 @@ public class Transaction : IComparable<Transaction> {
}
}
/// <summary>
/// Returns true if this transaction was completed in legacy ED
/// </summary>
public bool IsLegacy { get; set; } = false;
/// <summary>
/// Controlling faction of the station this entry was made/turned into.
/// </summary>

View File

@ -19,6 +19,11 @@ internal class TransactionParserContext {
public bool HaveSeenSpecOps { get; set; } = false;
public bool HaveSeenCorrespondent { get; set; } = false;
/// <summary>
/// Returns true if the current session is legacy
/// </summary>
public bool IsLegacy { get; set; } = false;
/// <summary>
/// How many on foot kills were done.
/// </summary>
@ -103,6 +108,7 @@ internal class TransactionParserContext {
CombatZone zone = new CombatZone() {
System = CurrentSystem,
Faction = LastRecordedAwardingFaction,
IsLegacy = IsLegacy,
Grade = grade,
Type = cztype,
// Sad truth is, if HaveSeenXXX is false, we just don't know for certain
@ -384,6 +390,7 @@ internal class CommitCrimeParser : TransactionParserPart {
transactions.Add(new FoulMurder(entry) {
System = context.CurrentSystem,
IsLegacy = context.IsLegacy,
Faction = faction,
});
}
@ -498,6 +505,7 @@ internal class MissionCompletedParser : TransactionParserPart {
Faction = source_faction_name,
SystemAddress = accepted_location.SystemAddress,
Station = accepted_location.Station,
IsLegacy = context.IsLegacy,
});
} else if (string.Compare(faction, source_faction_name, true) != 0 ||
(string.Compare(faction, source_faction_name) == 0 &&
@ -511,6 +519,7 @@ internal class MissionCompletedParser : TransactionParserPart {
System = system,
SystemAddress = system_address,
RelevantMission = entry,
IsLegacy = context.IsLegacy,
});
}
}
@ -561,6 +570,7 @@ internal class MissionFailedParser : TransactionParserPart {
Station = accepted_location.Station,
System = accepted_location.StarSystem,
SystemAddress = accepted_location.SystemAddress,
IsLegacy = context.IsLegacy,
});
}
}
@ -576,6 +586,7 @@ internal class SellExplorationDataParser : TransactionParserPart {
System = context.CurrentSystem,
Station = context.CurrentStation,
Faction = context.ControllingFaction,
IsLegacy = context.IsLegacy,
});
}
}
@ -591,6 +602,7 @@ internal class SellOrganicDataParser : TransactionParserPart {
System = context.CurrentSystem,
Station = context.CurrentStation,
Faction = context.ControllingFaction,
IsLegacy = context.IsLegacy,
});
}
}
@ -606,6 +618,7 @@ internal class MultiSellExplorationDataParser : TransactionParserPart {
System = context.CurrentSystem,
Station = context.CurrentStation,
Faction = context.ControllingFaction,
IsLegacy = context.IsLegacy,
});
}
}
@ -660,6 +673,7 @@ internal class RedeemVoucherParser : TransactionParserPart {
Station = context.CurrentStation,
Faction = relevantFaction,
ControllingFaction = context.ControllingFaction,
IsLegacy = context.IsLegacy,
});
}
}
@ -677,6 +691,7 @@ internal class SellMicroResourcesParser : TransactionParserPart {
System = context.CurrentSystem,
Station = context.CurrentStation,
Faction = context.ControllingFaction,
IsLegacy = context.IsLegacy,
});
}
}
@ -692,6 +707,7 @@ internal class SearchAndRescueParser : TransactionParserPart {
Faction = context.ControllingFaction,
Station = context.CurrentStation,
System = context.CurrentSystem,
IsLegacy = context.IsLegacy,
});
}
}
@ -709,6 +725,7 @@ internal class MarketBuyParser : TransactionParserPart {
Faction = context.ControllingFaction,
Station = context.CurrentStation,
System = context.CurrentSystem,
IsLegacy = context.IsLegacy,
});
}
}
@ -736,6 +753,7 @@ internal class MarketSellParser : TransactionParserPart {
Station = context.CurrentStation,
System = context.CurrentSystem,
Profit = profit,
IsLegacy = context.IsLegacy,
});
}
}
@ -753,6 +771,7 @@ internal class FactionKillBondParser : TransactionParserPart {
System = context.CurrentSystem,
Faction = Factions.PilotsFederation,
Station = context.CurrentStation,
IsLegacy = context.IsLegacy,
});
// We are done
@ -797,6 +816,18 @@ internal class CapShipBondParser : TransactionParserPart {
}
}
internal class FileHeaderParser : TransactionParserPart {
public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) {
FileHeaderEntry? fileheader = entry as FileHeaderEntry;
if (fileheader == null) {
return;
}
context.IsLegacy = fileheader.IsLegacy;
}
}
public class TransactionParser {
private static Dictionary<string, TransactionParserPart> ParserParts { get; } = new()
{
@ -806,6 +837,7 @@ public class TransactionParser {
{ Events.Docked, new DockedParser() },
{ Events.Embark, new EmbarkDisembarkParser() },
{ Events.FactionKillBond, new FactionKillBondParser() },
{ Events.FileHeader, new FileHeaderParser() },
{ Events.FSDJump, new FSDJumpParser() },
{ Events.Location, new LocationParser() },
{ Events.MarketBuy, new MarketBuyParser() },

View File

@ -26,6 +26,9 @@
<None Update="double-support.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="legacy-transaction.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="mission-failed.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

View File

@ -6,6 +6,29 @@ namespace EDPlayerJournalTests;
[TestClass]
public class TestTransactionParser {
[TestMethod]
public void Legacy() {
TransactionParser parser = new();
// File header, followed by two legacy transactions, followed by another
// file header with an Odyssey transaction
List<Entry>? entries = Helper.LoadTestData("legacy-transaction.txt");
Assert.IsNotNull(entries, "could not load test data");
if (entries == null) {
return;
}
List<Transaction>? transactions = parser.Parse(entries);
Assert.IsNotNull(transactions, "could not parse entries");
Assert.AreEqual(transactions.Count, 3);
Assert.AreEqual(transactions[0].IsLegacy, true);
Assert.AreEqual(transactions[1].IsLegacy, true);
Assert.AreEqual(transactions[2].IsLegacy, false);
}
[TestMethod]
public void DoubleFiveINF() {
TransactionParser parser = new();

View File

@ -0,0 +1,7 @@
{ "timestamp":"2022-02-06T16:36:53Z", "event":"Fileheader", "part":1, "language":"English/UK", "gameversion":"3.8.0.1102", "build":"r280672/r0 " }
{ "timestamp":"2022-02-06T18:10:26Z", "event":"FSDJump", "Taxi":false, "Multicrew":false, "StarSystem":"Akualanu", "SystemAddress":5069805856169, "StarPos":[63.78125,-128.50000,3.00000], "SystemAllegiance":"Empire", "SystemEconomy":"$economy_Tourism;", "SystemEconomy_Localised":"Tourism", "SystemSecondEconomy":"$economy_HighTech;", "SystemSecondEconomy_Localised":"High Tech", "SystemGovernment":"$government_Patronage;", "SystemGovernment_Localised":"Patronage", "SystemSecurity":"$SYSTEM_SECURITY_low;", "SystemSecurity_Localised":"Low Security", "Population":787019, "Body":"Akualanu A", "BodyID":1, "BodyType":"Star", "Powers":[ "A. Lavigny-Duval" ], "PowerplayState":"Exploited", "JumpDist":40.001, "FuelUsed":4.849240, "FuelLevel":22.573641, "Factions":[ { "Name":"Akualanu United & Co", "FactionState":"War", "Government":"Corporate", "Influence":0.158000, "Allegiance":"Empire", "Happiness":"$Faction_HappinessBand3;", "Happiness_Localised":"Discontented", "MyReputation":100.000000, "RecoveringStates":[ { "State":"InfrastructureFailure", "Trend":0 } ], "ActiveStates":[ { "State":"Lockdown" }, { "State":"Famine" }, { "State":"War" } ] }, { "Name":"Alacagui Holdings", "FactionState":"War", "Government":"Corporate", "Influence":0.086000, "Allegiance":"Empire", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":55.000000, "RecoveringStates":[ { "State":"PirateAttack", "Trend":0 } ], "ActiveStates":[ { "State":"War" } ] }, { "Name":"Left Party of Akualanu", "FactionState":"War", "Government":"Communism", "Influence":0.086000, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand3;", "Happiness_Localised":"Discontented", "MyReputation":95.899399, "RecoveringStates":[ { "State":"InfrastructureFailure", "Trend":0 } ], "ActiveStates":[ { "State":"Lockdown" }, { "State":"Famine" }, { "State":"War" } ] }, { "Name":"Cartel of Akualanu", "FactionState":"Famine", "Government":"Anarchy", "Influence":0.028000, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":29.040001, "RecoveringStates":[ { "State":"InfrastructureFailure", "Trend":0 } ], "ActiveStates":[ { "State":"Famine" } ] }, { "Name":"Revolutionary Akualanu Liberals", "FactionState":"Bust", "Government":"Democracy", "Influence":0.085000, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand3;", "Happiness_Localised":"Discontented", "MyReputation":43.093700, "PendingStates":[ { "State":"Lockdown", "Trend":0 } ], "ActiveStates":[ { "State":"InfrastructureFailure" }, { "State":"Bust" } ] }, { "Name":"Conservatives of Cockaigne", "FactionState":"War", "Government":"Dictatorship", "Influence":0.138000, "Allegiance":"Empire", "Happiness":"$Faction_HappinessBand3;", "Happiness_Localised":"Discontented", "MyReputation":70.000000, "ActiveStates":[ { "State":"CivilUnrest" }, { "State":"InfrastructureFailure" }, { "State":"War" } ] }, { "Name":"Nova Paresa", "FactionState":"Investment", "Government":"Patronage", "Influence":0.419000, "Allegiance":"Empire", "Happiness":"$Faction_HappinessBand1;", "Happiness_Localised":"Elated", "SquadronFaction":true, "MyReputation":100.000000, "ActiveStates":[ { "State":"Investment" }, { "State":"CivilLiberty" } ] } ], "SystemFaction":{ "Name":"Nova Paresa", "FactionState":"Investment" }, "Conflicts":[ { "WarType":"war", "Status":"active", "Faction1":{ "Name":"Akualanu United & Co", "Stake":"Konig Institution", "WonDays":0 }, "Faction2":{ "Name":"Conservatives of Cockaigne", "Stake":"", "WonDays":1 } }, { "WarType":"war", "Status":"active", "Faction1":{ "Name":"Alacagui Holdings", "Stake":"Ware Cultivation Facility", "WonDays":2 }, "Faction2":{ "Name":"Left Party of Akualanu", "Stake":"", "WonDays":2 } } ] }
{ "timestamp":"2022-02-06T18:13:30Z", "event":"Docked", "StationName":"Hughes Vista", "StationType":"Coriolis", "Taxi":false, "Multicrew":false, "StarSystem":"Akualanu", "SystemAddress":5069805856169, "MarketID":3222969088, "StationFaction":{ "Name":"Nova Paresa", "FactionState":"Investment" }, "StationGovernment":"$government_Patronage;", "StationGovernment_Localised":"Patronage", "StationAllegiance":"Empire", "StationServices":[ "dock", "autodock", "commodities", "contacts", "exploration", "missions", "outfitting", "crewlounge", "rearm", "refuel", "repair", "shipyard", "tuning", "engineer", "missionsgenerated", "facilitator", "flightcontroller", "stationoperations", "powerplay", "searchrescue", "stationMenu", "shop", "livery", "socialspace", "bartender", "vistagenomics", "pioneersupplies", "apexinterstellar", "frontlinesolutions" ], "StationEconomy":"$economy_Tourism;", "StationEconomy_Localised":"Tourism", "StationEconomies":[ { "Name":"$economy_Tourism;", "Name_Localised":"Tourism", "Proportion":1.000000 } ], "DistFromStarLS":78.917615, "LandingPads":{ "Small":13, "Medium":16, "Large":8 } }
{ "timestamp":"2022-11-25T09:52:28Z", "event":"FactionKillBond", "Reward":24000000, "AwardingFaction":"$faction_PilotsFederation;", "AwardingFaction_Localised":"Pilots' Federation", "VictimFaction":"$faction_Thargoid;", "VictimFaction_Localised":"Thargoids" }
{ "timestamp":"2022-11-21T15:56:08Z", "event":"MarketSell", "MarketID":3222176256, "Type":"silver", "Count":224, "SellPrice":40996, "TotalSale":9183104, "AvgPricePaid":34311 }
{ "timestamp":"2022-02-06T16:36:53Z", "event":"Fileheader", "part":1, "language":"English/UK", "Odyssey":true, "gameversion":"4.0.0.1102", "build":"r280672/r0 " }
{ "timestamp":"2022-02-06T18:17:44Z", "event":"SellOrganicData", "MarketID":3222969088, "BioData":[ { "Genus":"$Codex_Ent_Stratum_Genus_Name;", "Genus_Localised":"Stratum", "Species":"$Codex_Ent_Stratum_07_Name;", "Species_Localised":"Stratum Tectonicas", "Value":806300, "Bonus":0 }, { "Genus":"$Codex_Ent_Aleoids_Genus_Name;", "Genus_Localised":"Aleoida", "Species":"$Codex_Ent_Aleoids_05_Name;", "Species_Localised":"Aleoida Gravis", "Value":596500, "Bonus":0 } ] }