diff --git a/EDPlayerJournal/BGS/TransactionParser.cs b/EDPlayerJournal/BGS/TransactionParser.cs
index 2527701..ab11efe 100644
--- a/EDPlayerJournal/BGS/TransactionParser.cs
+++ b/EDPlayerJournal/BGS/TransactionParser.cs
@@ -484,24 +484,37 @@ internal class RedeemVoucherParser : TransactionParserPart {
if (current_factions == null) {
transactions.AddIncomplete(new Vouchers(),
"Current system factions are unknown, so vouchers were ineffective");
- return;
}
foreach (string faction in entry.Factions) {
- if (current_factions.Find(x => string.Compare(x.Name, faction, true) == 0) == null) {
- transactions.AddIncomplete(new Vouchers(),
- string.Format("Vouchers for {0} were ignored in {1} since said " +
- "faction is not present here", faction, context.CurrentSystem)
- );
- continue;
+ bool relevantBond = false;
+
+ if (string.Compare(faction, Factions.PilotsFederationVouchers) == 0) {
+ // Target faction is pilots' federation, so we assume thargoid bonks
+ relevantBond = true;
}
- transactions.Add(new Vouchers(entry) {
- System = context.CurrentSystem,
- Station = context.CurrentStation,
- Faction = faction,
- ControllingFaction = context.ControllingFaction,
- });
+ if (current_factions != null && !relevantBond) {
+ // If we have local factions, and it ain't thargoid bonds see if the bonds were
+ // useful in the current system
+ if (current_factions.Find(x => string.Compare(x.Name, faction, true) == 0) != null) {
+ relevantBond = true;
+ } else {
+ transactions.AddIncomplete(new Vouchers(),
+ string.Format("Vouchers for {0} had no effect in {1} since said " +
+ "faction is not present here", faction, context.CurrentSystem)
+ );
+ }
+ }
+
+ if (relevantBond) {
+ transactions.Add(new Vouchers(entry) {
+ System = context.CurrentSystem,
+ Station = context.CurrentStation,
+ Faction = faction,
+ ControllingFaction = context.ControllingFaction,
+ });
+ }
}
}
}
diff --git a/EDPlayerJournal/Faction.cs b/EDPlayerJournal/Faction.cs
index e264099..94f9f42 100644
--- a/EDPlayerJournal/Faction.cs
+++ b/EDPlayerJournal/Faction.cs
@@ -33,7 +33,12 @@ public class Factions {
///
/// Internal name for the Pilots Federation faction
///
- public static string PilotsFederation = "$faction_PilotsFederation;";
+ public static string PilotsFederationInternal = "$faction_PilotsFederation;";
+
+ ///
+ /// Name used for Pilots Federation in vouchers
+ ///
+ public static string PilotsFederationVouchers = "PilotsFederation";
///
/// Internal name for the Thargoid faction
diff --git a/EDPlayerJournalTests/EDPlayerJournalTests.csproj b/EDPlayerJournalTests/EDPlayerJournalTests.csproj
index cd5a563..a6beec8 100644
--- a/EDPlayerJournalTests/EDPlayerJournalTests.csproj
+++ b/EDPlayerJournalTests/EDPlayerJournalTests.csproj
@@ -44,6 +44,9 @@
Always
+
+ Always
+
Always
diff --git a/EDPlayerJournalTests/ThargoidBonds.txt b/EDPlayerJournalTests/ThargoidBonds.txt
new file mode 100644
index 0000000..4f24237
--- /dev/null
+++ b/EDPlayerJournalTests/ThargoidBonds.txt
@@ -0,0 +1,3 @@
+{ "timestamp":"2022-11-25T10:10:43Z", "event":"FSDJump", "Taxi":false, "Multicrew":false, "StarSystem":"Nyalayan", "SystemAddress":1458309042898, "StarPos":[29.71875,-172.71875,-6.46875], "SystemAllegiance":"Independent", "SystemEconomy":"$economy_Agri;", "SystemEconomy_Localised":"Agriculture", "SystemSecondEconomy":"$economy_Refinery;", "SystemSecondEconomy_Localised":"Refinery", "SystemGovernment":"$government_Theocracy;", "SystemGovernment_Localised":"Theocracy", "SystemSecurity":"$SYSTEM_SECURITY_medium;", "SystemSecurity_Localised":"Medium Security", "Population":1920608781, "Body":"Nyalayan A", "BodyID":1, "BodyType":"Star", "JumpDist":7.769, "FuelUsed":0.142448, "FuelLevel":15.857553, "Factions":[ { "Name":"Nyalayan Imperial Society", "FactionState":"Election", "Government":"Patronage", "Influence":0.165138, "Allegiance":"Empire", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":17.496799, "ActiveStates":[ { "State":"Election" } ] }, { "Name":"Reret Emperor's Grace", "FactionState":"War", "Government":"Patronage", "Influence":0.257900, "Allegiance":"Empire", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":100.000000, "ActiveStates":[ { "State":"Expansion" }, { "State":"War" } ] }, { "Name":"Nyalayan Silver Transport Org", "FactionState":"None", "Government":"Corporate", "Influence":0.076453, "Allegiance":"Empire", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":81.875000 }, { "Name":"Nyalayan Power & Co", "FactionState":"None", "Government":"Corporate", "Influence":0.060143, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":23.173201 }, { "Name":"Amanogawa Enlight", "FactionState":"War", "Government":"Theocracy", "Influence":0.257900, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":-1.210600, "ActiveStates":[ { "State":"Expansion" }, { "State":"War" } ] }, { "Name":"Nyalayan Crimson Dragons", "FactionState":"None", "Government":"Anarchy", "Influence":0.017329, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":-13.530000 }, { "Name":"Traditional Nyalayan Front", "FactionState":"Election", "Government":"Dictatorship", "Influence":0.165138, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":64.699997, "ActiveStates":[ { "State":"Election" } ] } ], "SystemFaction":{ "Name":"Amanogawa Enlight", "FactionState":"War" }, "Conflicts":[ { "WarType":"election", "Status":"active", "Faction1":{ "Name":"Nyalayan Imperial Society", "Stake":"Pilcher Port", "WonDays":2 }, "Faction2":{ "Name":"Traditional Nyalayan Front", "Stake":"Lamar Falls", "WonDays":0 } }, { "WarType":"war", "Status":"active", "Faction1":{ "Name":"Reret Emperor's Grace", "Stake":"", "WonDays":1 }, "Faction2":{ "Name":"Amanogawa Enlight", "Stake":"Sutter Ring", "WonDays":2 } } ] }
+{ "timestamp":"2022-11-25T10:13:32Z", "event":"Docked", "StationName":"Pilcher Port", "StationType":"Orbis", "Taxi":false, "Multicrew":false, "StarSystem":"Nyalayan", "SystemAddress":1458309042898, "MarketID":3222853120, "StationFaction":{ "Name":"Nyalayan Imperial Society", "FactionState":"Election" }, "StationGovernment":"$government_Patronage;", "StationGovernment_Localised":"Patronage", "StationAllegiance":"Empire", "StationServices":[ "dock", "autodock", "commodities", "contacts", "exploration", "missions", "outfitting", "crewlounge", "rearm", "refuel", "repair", "shipyard", "tuning", "engineer", "missionsgenerated", "flightcontroller", "stationoperations", "powerplay", "searchrescue", "stationMenu", "shop", "livery", "socialspace", "bartender", "vistagenomics", "pioneersupplies", "apexinterstellar", "frontlinesolutions" ], "StationEconomy":"$economy_Refinery;", "StationEconomy_Localised":"Refinery", "StationEconomies":[ { "Name":"$economy_Refinery;", "Name_Localised":"Refinery", "Proportion":1.000000 } ], "DistFromStarLS":76.465557, "LandingPads":{ "Small":8, "Medium":11, "Large":6 } }
+{ "timestamp":"2022-11-25T10:13:53Z", "event":"RedeemVoucher", "Type":"CombatBond", "Amount":24240000, "Faction":"PilotsFederation" }
diff --git a/EDPlayerJournalTests/ThargoidKills.cs b/EDPlayerJournalTests/ThargoidKills.cs
index 0e78145..9d2056a 100644
--- a/EDPlayerJournalTests/ThargoidKills.cs
+++ b/EDPlayerJournalTests/ThargoidKills.cs
@@ -1,10 +1,6 @@
-using EDPlayerJournal.BGS;
+using EDPlayerJournal;
+using EDPlayerJournal.BGS;
using EDPlayerJournal.Entries;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace EDPlayerJournalTests;
@@ -21,13 +17,38 @@ public class ThargoidKills {
return;
}
- List? transactions = parser.Parse(entries);
+ List? transactions = parser.Parse(entries)?.OfType().ToList();
Assert.IsNotNull(transactions, "could not parse entries");
- Assert.AreEqual(transactions.Count, 4);
+ Assert.AreEqual(transactions.Count, 3);
Assert.IsInstanceOfType(transactions[0], typeof(ThargoidKill), "result is not of type ThargoidKill");
+ Assert.AreEqual(transactions[0].ThargoidType, EDPlayerJournal.ThargoidVessel.Scout);
+
Assert.IsInstanceOfType(transactions[1], typeof(ThargoidKill), "result is not of type ThargoidKill");
+ Assert.AreEqual(transactions[1].ThargoidType, EDPlayerJournal.ThargoidVessel.Basilisk);
+
Assert.IsInstanceOfType(transactions[2], typeof(ThargoidKill), "result is not of type ThargoidKill");
+ Assert.AreEqual(transactions[2].ThargoidType, EDPlayerJournal.ThargoidVessel.Scout);
+ }
+
+ [TestMethod]
+ public void ThargoidBonds() {
+ TransactionParser parser = new();
+
+ List? entries = Helper.LoadTestData("ThargoidBonds.txt");
+ Assert.IsNotNull(entries, "could not load test data");
+
+ if (entries == null) {
+ return;
+ }
+
+ List? transactions = parser.Parse(entries)?.OfType().ToList();
+
+ Assert.IsNotNull(transactions, "could not parse entries");
+ Assert.AreEqual(transactions.Count, 1);
+ Assert.AreEqual(transactions[0].Faction, Factions.PilotsFederationVouchers);
+ Assert.AreEqual(transactions[0].TotalSum, 24240000L);
+ Assert.AreEqual(transactions[0].Type, "Combat Bond");
}
}
diff --git a/EDPlayerJournalTests/ThargoidKills.txt b/EDPlayerJournalTests/ThargoidKills.txt
index d468e1d..f8a31bc 100644
--- a/EDPlayerJournalTests/ThargoidKills.txt
+++ b/EDPlayerJournalTests/ThargoidKills.txt
@@ -1,4 +1,3 @@
{ "timestamp":"2022-11-25T09:50:45Z", "event":"FactionKillBond", "Reward":80000, "AwardingFaction":"$faction_PilotsFederation;", "AwardingFaction_Localised":"Pilots' Federation", "VictimFaction":"$faction_Thargoid;", "VictimFaction_Localised":"Thargoids" }
{ "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-25T09:47:19Z", "event":"FactionKillBond", "Reward":80000, "AwardingFaction":"$faction_PilotsFederation;", "AwardingFaction_Localised":"Pilots' Federation", "VictimFaction":"$faction_Thargoid;", "VictimFaction_Localised":"Thargoids" }
-{ "timestamp":"2022-11-25T10:13:53Z", "event":"RedeemVoucher", "Type":"CombatBond", "Amount":24240000, "Faction":"PilotsFederation" }
\ No newline at end of file