Compare commits
2 Commits
91bca70168
...
674757d734
Author | SHA1 | Date | |
---|---|---|---|
674757d734 | |||
712c416725 |
@ -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>
|
||||
|
@ -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() },
|
||||
|
@ -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>
|
||||
|
@ -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();
|
||||
|
7
EDPlayerJournalTests/legacy-transaction.txt
Normal file
7
EDPlayerJournalTests/legacy-transaction.txt
Normal 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 } ] }
|
@ -44,8 +44,16 @@ public class DiscordLogGenerator {
|
||||
location = "Unknown Location";
|
||||
}
|
||||
|
||||
int legacycount = objective.Transactions
|
||||
.Where(x => x.IsLegacy)
|
||||
.Count()
|
||||
;
|
||||
|
||||
log.AppendFormat("**Date:** {0}\n", DateTime.Now.ToString("dd/MM/yyyy"));
|
||||
log.AppendFormat("**Target:** {0}\n", location);
|
||||
if (legacycount > 0) {
|
||||
log.AppendFormat("**Warning:** Some actions were performed on ED Legacy");
|
||||
}
|
||||
log.AppendLine("");
|
||||
log.AppendLine("```");
|
||||
|
||||
|
@ -299,7 +299,7 @@ public partial class MainWindow : Window {
|
||||
}
|
||||
|
||||
private TransactionType GetTransaction<TransactionType>(object sender) where TransactionType : Transaction {
|
||||
System.Windows.Controls.Control? button = sender as System.Windows.Controls.Control;
|
||||
System.Windows.Controls.Control button = sender as System.Windows.Controls.Control;
|
||||
if (button == null || button.DataContext == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using EDPlayerJournal;
|
||||
using System.Linq;
|
||||
|
||||
namespace EliteBGS.BGS;
|
||||
|
||||
@ -44,7 +45,15 @@ public class NonaDiscordLog : DiscordLogGenerator {
|
||||
location = "Unknown Location";
|
||||
}
|
||||
|
||||
int legacycount = objective.Transactions
|
||||
.Where(x => x.IsLegacy)
|
||||
.Count()
|
||||
;
|
||||
|
||||
log.AppendFormat(":globe_with_meridians: `Target:` {0}\n", location);
|
||||
if (legacycount > 0) {
|
||||
log.Append(":rotating_light: `Warning`: Some actions were done in E:D Legacy\n");
|
||||
}
|
||||
log.Append(":clipboard: `Conducted:`\n");
|
||||
log.Append("```");
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class UITransaction {
|
||||
|
||||
public Visibility IsShipCombatZone {
|
||||
get {
|
||||
CombatZone? combat = Transaction as CombatZone;
|
||||
CombatZone combat = Transaction as CombatZone;
|
||||
if (combat == null) {
|
||||
return Visibility.Hidden;
|
||||
}
|
||||
@ -40,9 +40,9 @@ public class UITransaction {
|
||||
}
|
||||
}
|
||||
|
||||
public bool? HasSpecOps {
|
||||
public bool HasSpecOps {
|
||||
get {
|
||||
CombatZone? combat = Transaction as CombatZone;
|
||||
CombatZone combat = Transaction as CombatZone;
|
||||
if (combat == null) {
|
||||
return false;
|
||||
}
|
||||
@ -50,7 +50,7 @@ public class UITransaction {
|
||||
return combat.SpecOps ?? false;
|
||||
}
|
||||
set {
|
||||
CombatZone? combat = Transaction as CombatZone;
|
||||
CombatZone combat = Transaction as CombatZone;
|
||||
if (combat == null) {
|
||||
return;
|
||||
}
|
||||
@ -59,9 +59,9 @@ public class UITransaction {
|
||||
}
|
||||
}
|
||||
|
||||
public bool? HasCapitalShip {
|
||||
public bool HasCapitalShip {
|
||||
get {
|
||||
CombatZone? combat = Transaction as CombatZone;
|
||||
CombatZone combat = Transaction as CombatZone;
|
||||
if (combat == null) {
|
||||
return false;
|
||||
}
|
||||
@ -69,7 +69,7 @@ public class UITransaction {
|
||||
return combat.CapitalShip ?? false;
|
||||
}
|
||||
set {
|
||||
CombatZone? combat = Transaction as CombatZone;
|
||||
CombatZone combat = Transaction as CombatZone;
|
||||
if (combat == null) {
|
||||
return;
|
||||
}
|
||||
@ -78,9 +78,9 @@ public class UITransaction {
|
||||
}
|
||||
}
|
||||
|
||||
public bool? HasCaptain {
|
||||
public bool HasCaptain {
|
||||
get {
|
||||
CombatZone? combat = Transaction as CombatZone;
|
||||
CombatZone combat = Transaction as CombatZone;
|
||||
if (combat == null) {
|
||||
return false;
|
||||
}
|
||||
@ -88,7 +88,7 @@ public class UITransaction {
|
||||
return combat.Captain ?? false;
|
||||
}
|
||||
set {
|
||||
CombatZone? combat = Transaction as CombatZone;
|
||||
CombatZone combat = Transaction as CombatZone;
|
||||
if (combat == null) {
|
||||
return;
|
||||
}
|
||||
@ -97,9 +97,9 @@ public class UITransaction {
|
||||
}
|
||||
}
|
||||
|
||||
public bool? HasCorrespondent {
|
||||
public bool HasCorrespondent {
|
||||
get {
|
||||
CombatZone? combat = Transaction as CombatZone;
|
||||
CombatZone combat = Transaction as CombatZone;
|
||||
if (combat == null) {
|
||||
return false;
|
||||
}
|
||||
@ -107,7 +107,7 @@ public class UITransaction {
|
||||
return combat.Correspondent ?? false;
|
||||
}
|
||||
set {
|
||||
CombatZone? combat = Transaction as CombatZone;
|
||||
CombatZone combat = Transaction as CombatZone;
|
||||
if (combat == null) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user