Compare commits
No commits in common. "a49859b079bcabe2d9069709e2fa447c59f51081" and "091c4434407f31732ff6584e9df4e7d7609347ea" have entirely different histories.
a49859b079
...
091c443440
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
namespace EDPlayerJournal.BGS;
|
namespace EDPlayerJournal.BGS;
|
||||||
public class FactionKillBonds : Transaction {
|
public class FactionKillBonds : Transaction {
|
||||||
public ulong TotalSum {
|
public int TotalSum {
|
||||||
get {
|
get {
|
||||||
return (ulong)Entries
|
return Entries
|
||||||
.OfType<FactionKillBondEntry>()
|
.OfType<FactionKillBondEntry>()
|
||||||
.Sum(x => (decimal)x.Reward)
|
.Sum(x => x.Reward)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
using EDPlayerJournal.Entries;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EDPlayerJournal.BGS;
|
|
||||||
|
|
||||||
public class ThargoidKill : Transaction {
|
|
||||||
/// <summary>
|
|
||||||
/// Thargoid vessel that was killed
|
|
||||||
/// </summary>
|
|
||||||
public ThargoidVessel ThargoidType { get; set; } = ThargoidVessel.Unknown;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Name of the thargoid type killed
|
|
||||||
/// </summary>
|
|
||||||
public string? ThargoidName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Total reward received
|
|
||||||
/// </summary>
|
|
||||||
public ulong TotalReward {
|
|
||||||
get { return (ulong)Entries.OfType<FactionKillBondEntry>().Sum(x => (decimal)x.Reward); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public ThargoidKill() { }
|
|
||||||
|
|
||||||
public ThargoidKill(FactionKillBondEntry entry) {
|
|
||||||
if (string.Compare(entry.VictimFaction, Thargoid.ThargoidFaction) != 0) {
|
|
||||||
throw new Exception("Not a valid thargoid kill");
|
|
||||||
}
|
|
||||||
|
|
||||||
Entries.Add(entry);
|
|
||||||
|
|
||||||
ThargoidType = Thargoid.GetVesselByPayout(entry.Reward);
|
|
||||||
ThargoidName = Thargoid.GetVesselName(ThargoidType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString() {
|
|
||||||
return string.Format("{0}x {1} killed", Entries.Count, ThargoidName);
|
|
||||||
}
|
|
||||||
}
|
|
@ -580,26 +580,11 @@ internal class MarketSellParser : TransactionParserPart {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class FactionKillBondParser : TransactionParserPart {
|
|
||||||
public void Parse(Entry e, TransactionParserContext context, TransactionList transactions) {
|
|
||||||
FactionKillBondEntry? entry = e as FactionKillBondEntry;
|
|
||||||
if (entry == null) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.Compare(entry.VictimFaction, Thargoid.ThargoidFaction) == 0) {
|
|
||||||
// Thargoid bonk
|
|
||||||
transactions.Add(new ThargoidKill(entry));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TransactionParser {
|
public class TransactionParser {
|
||||||
private static Dictionary<string, TransactionParserPart> ParserParts { get; } = new()
|
private static Dictionary<string, TransactionParserPart> ParserParts { get; } = new()
|
||||||
{
|
{
|
||||||
{ Events.CommitCrime, new CommitCrimeParser() },
|
{ Events.CommitCrime, new CommitCrimeParser() },
|
||||||
{ Events.Docked, new DockedParser() },
|
{ Events.Docked, new DockedParser() },
|
||||||
{ Events.FactionKillBond, new FactionKillBondParser() },
|
|
||||||
{ Events.FSDJump, new FSDJumpParser() },
|
{ Events.FSDJump, new FSDJumpParser() },
|
||||||
{ Events.Location, new LocationParser() },
|
{ Events.Location, new LocationParser() },
|
||||||
{ Events.MarketBuy, new MarketBuyParser() },
|
{ Events.MarketBuy, new MarketBuyParser() },
|
||||||
|
@ -3,11 +3,7 @@
|
|||||||
namespace EDPlayerJournal;
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
public class Credits {
|
public class Credits {
|
||||||
public static string FormatCredits(uint amount) {
|
public static string FormatCredits(int amount) {
|
||||||
return FormatCredits((long)amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string FormatCredits(ulong amount) {
|
|
||||||
return FormatCredits((long)amount);
|
return FormatCredits((long)amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,32 +1,13 @@
|
|||||||
namespace EDPlayerJournal.Entries;
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
public class FactionKillBondEntry : Entry {
|
public class FactionKillBondEntry : Entry {
|
||||||
/// <summary>
|
public int Reward { get; set; }
|
||||||
/// Reward given
|
|
||||||
/// </summary>
|
|
||||||
public ulong Reward { get; set; } = 0;
|
|
||||||
/// <summary>
|
|
||||||
/// Faction that awarded the kill bond
|
|
||||||
/// </summary>
|
|
||||||
public string? AwardingFaction { get; set; }
|
public string? AwardingFaction { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// Localised string of the awarding faction if available
|
|
||||||
/// </summary>
|
|
||||||
public string? AwardingFactionLocalised { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Victim faction, internal name
|
|
||||||
/// </summary>
|
|
||||||
public string? VictimFaction { get; set; }
|
public string? VictimFaction { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// Localised name of the victim faction
|
|
||||||
/// </summary>
|
|
||||||
public string? VictimFactionLocalised { get; set; }
|
|
||||||
|
|
||||||
protected override void Initialise() {
|
protected override void Initialise() {
|
||||||
Reward = JSON.Value<ulong?>("Reward") ?? 0;
|
Reward = JSON.Value<int?>("Reward") ?? 0;
|
||||||
AwardingFaction = JSON.Value<string>("AwardingFaction");
|
AwardingFaction = JSON.Value<string>("AwardingFaction");
|
||||||
AwardingFactionLocalised = JSON.Value<string>("AwardingFaction_Localised");
|
|
||||||
VictimFaction = JSON.Value<string>("VictimFaction");
|
VictimFaction = JSON.Value<string>("VictimFaction");
|
||||||
VictimFactionLocalised = JSON.Value<string>("VictimFaction_Localised");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace EDPlayerJournal;
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
public class FactionState {
|
public class FactionState {
|
||||||
public string? State { get; set; }
|
public string? State { get; set; }
|
||||||
public long? Trend { get; set; }
|
public long? Trend { get; set; }
|
||||||
@ -29,18 +28,6 @@ public class FactionState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Factions {
|
|
||||||
/// <summary>
|
|
||||||
/// Internal name for the Pilots Federation faction
|
|
||||||
/// </summary>
|
|
||||||
public static string PilotsFederation = "$faction_PilotsFederation;";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Internal name for the Thargoid faction
|
|
||||||
/// </summary>
|
|
||||||
public static string Thargoid = "$faction_Thargoid;";
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Faction {
|
public class Faction {
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public string? FactionState { get; set; }
|
public string? FactionState { get; set; }
|
||||||
|
63
EDPlayerJournal/HumanReadableMissionName.cs
Normal file
63
EDPlayerJournal/HumanReadableMissionName.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
|
public class HumanReadableMissionName {
|
||||||
|
private static Dictionary<string, string>? humanreadable = null;
|
||||||
|
|
||||||
|
private static void LoadMissions() {
|
||||||
|
try {
|
||||||
|
string dir = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
string file = Path.Combine(dir, "MissionNames.xml");
|
||||||
|
|
||||||
|
XmlDocument document = new XmlDocument();
|
||||||
|
|
||||||
|
using (FileStream stream = new FileStream(file, FileMode.Open)) {
|
||||||
|
document.Load(stream);
|
||||||
|
XmlNode? missions = document.DocumentElement;
|
||||||
|
|
||||||
|
if (missions == null ||
|
||||||
|
missions.Name != "Missions" ||
|
||||||
|
missions.ChildNodes == null) {
|
||||||
|
throw new ApplicationException("Invalid XML");
|
||||||
|
}
|
||||||
|
|
||||||
|
humanreadable = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
foreach (XmlNode mission in missions.ChildNodes) {
|
||||||
|
if (mission.Attributes == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? mission_key = mission.Attributes["Name"]?.Value;
|
||||||
|
string? mission_name = mission.InnerText;
|
||||||
|
|
||||||
|
if (mission_key == null || mission_name == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
humanreadable.Add(mission_key, mission_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception) {
|
||||||
|
humanreadable = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string? MakeHumanReadableName(string name) {
|
||||||
|
LoadMissions();
|
||||||
|
|
||||||
|
if (humanreadable == null || name == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (humanreadable.ContainsKey(name)) {
|
||||||
|
return humanreadable[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,56 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EDPlayerJournal;
|
|
||||||
|
|
||||||
public enum ThargoidVessel {
|
|
||||||
Unknown = 0,
|
|
||||||
Scout = 1,
|
|
||||||
/// <summary>
|
|
||||||
/// According to AX wiki no longer found ingame
|
|
||||||
/// </summary>
|
|
||||||
Orthrus = 2,
|
|
||||||
Cyclops = 3,
|
|
||||||
Basilisk = 4,
|
|
||||||
Medusa = 5,
|
|
||||||
Hydra = 6,
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Thargoid {
|
|
||||||
public static string ThargoidFaction = Factions.Thargoid;
|
|
||||||
|
|
||||||
public static Dictionary<ulong, ThargoidVessel> VesselPayout { get; } = new() {
|
|
||||||
{ 80000, ThargoidVessel.Scout },
|
|
||||||
{ 8000000, ThargoidVessel.Cyclops },
|
|
||||||
{ 24000000, ThargoidVessel.Basilisk },
|
|
||||||
{ 40000000, ThargoidVessel.Medusa },
|
|
||||||
{ 60000000, ThargoidVessel.Hydra },
|
|
||||||
};
|
|
||||||
|
|
||||||
public static Dictionary<ThargoidVessel, string?> VesselNames { get; } = new() {
|
|
||||||
{ ThargoidVessel.Unknown, null },
|
|
||||||
{ ThargoidVessel.Scout, "Thargoid Scout" },
|
|
||||||
{ ThargoidVessel.Orthrus, "Orthrus" },
|
|
||||||
{ ThargoidVessel.Cyclops, "Cyclops" },
|
|
||||||
{ ThargoidVessel.Basilisk, "Basilisk" },
|
|
||||||
{ ThargoidVessel.Medusa, "Medusa" },
|
|
||||||
{ ThargoidVessel.Hydra, "Hydra" },
|
|
||||||
};
|
|
||||||
|
|
||||||
public static ThargoidVessel GetVesselByPayout(ulong payout) {
|
|
||||||
if (VesselPayout.ContainsKey(payout)) {
|
|
||||||
return VesselPayout[payout];
|
|
||||||
}
|
|
||||||
return ThargoidVessel.Unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string? GetVesselName(ThargoidVessel v) {
|
|
||||||
if (VesselNames.ContainsKey(v)) {
|
|
||||||
return VesselNames[v];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -44,9 +44,6 @@
|
|||||||
<None Update="SellOrganicData.txt">
|
<None Update="SellOrganicData.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="ThargoidKills.txt">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
using EDPlayerJournal.Entries;
|
|
||||||
|
|
||||||
namespace EDPlayerJournalTests;
|
|
||||||
|
|
||||||
public class Helper {
|
|
||||||
public static List<Entry>? LoadTestData(string filename) {
|
|
||||||
string path = Path.GetFullPath("./" + filename);
|
|
||||||
string[] lines = File.ReadAllLines(path);
|
|
||||||
List<Entry> entries = new();
|
|
||||||
|
|
||||||
foreach (string line in lines) {
|
|
||||||
line.Trim();
|
|
||||||
if (string.IsNullOrEmpty(line)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Entry? entry = Entry.Parse(line);
|
|
||||||
if (entry != null) {
|
|
||||||
entries.Add(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,11 +6,31 @@ namespace EDPlayerJournalTests;
|
|||||||
|
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class TestTransactionParser {
|
public class TestTransactionParser {
|
||||||
|
private List<Entry>? LoadTestData(string filename) {
|
||||||
|
string path = Path.GetFullPath("./" + filename);
|
||||||
|
string[] lines = File.ReadAllLines(path);
|
||||||
|
List<Entry> entries = new();
|
||||||
|
|
||||||
|
foreach (string line in lines) {
|
||||||
|
line.Trim();
|
||||||
|
if (string.IsNullOrEmpty(line)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry? entry = Entry.Parse(line);
|
||||||
|
if (entry != null) {
|
||||||
|
entries.Add(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void DoubleFiveINF() {
|
public void DoubleFiveINF() {
|
||||||
TransactionParser parser = new();
|
TransactionParser parser = new();
|
||||||
|
|
||||||
List<Entry>? entries = Helper.LoadTestData("double-five-inf.txt");
|
List<Entry>? entries = LoadTestData("double-five-inf.txt");
|
||||||
Assert.IsNotNull(entries, "could not load test data");
|
Assert.IsNotNull(entries, "could not load test data");
|
||||||
|
|
||||||
if (entries == null) {
|
if (entries == null) {
|
||||||
@ -26,7 +46,7 @@ public class TestTransactionParser {
|
|||||||
public void DoubleSupport() {
|
public void DoubleSupport() {
|
||||||
TransactionParser parser = new();
|
TransactionParser parser = new();
|
||||||
|
|
||||||
List<Entry>? entries = Helper.LoadTestData("double-support.txt");
|
List<Entry>? entries = LoadTestData("double-support.txt");
|
||||||
Assert.IsNotNull(entries, "could not load test data");
|
Assert.IsNotNull(entries, "could not load test data");
|
||||||
|
|
||||||
if (entries == null) {
|
if (entries == null) {
|
||||||
@ -42,7 +62,7 @@ public class TestTransactionParser {
|
|||||||
public void MissionFailed() {
|
public void MissionFailed() {
|
||||||
TransactionParser parser = new();
|
TransactionParser parser = new();
|
||||||
|
|
||||||
List<Entry>? entries = Helper.LoadTestData("mission-failed.txt");
|
List<Entry>? entries = LoadTestData("mission-failed.txt");
|
||||||
Assert.IsNotNull(entries, "could not load test data");
|
Assert.IsNotNull(entries, "could not load test data");
|
||||||
|
|
||||||
if (entries == null) {
|
if (entries == null) {
|
||||||
@ -58,7 +78,7 @@ public class TestTransactionParser {
|
|||||||
public void MissionNoINF() {
|
public void MissionNoINF() {
|
||||||
TransactionParser parser = new();
|
TransactionParser parser = new();
|
||||||
|
|
||||||
List<Entry>? entries = Helper.LoadTestData("mission-noinfforsourceortarget.txt");
|
List<Entry>? entries = LoadTestData("mission-noinfforsourceortarget.txt");
|
||||||
Assert.IsNotNull(entries, "could not load test data");
|
Assert.IsNotNull(entries, "could not load test data");
|
||||||
|
|
||||||
if (entries == null) {
|
if (entries == null) {
|
||||||
@ -74,7 +94,7 @@ public class TestTransactionParser {
|
|||||||
public void Murder() {
|
public void Murder() {
|
||||||
TransactionParser parser = new();
|
TransactionParser parser = new();
|
||||||
|
|
||||||
List<Entry>? entries = Helper.LoadTestData("murder.txt");
|
List<Entry>? entries = LoadTestData("murder.txt");
|
||||||
Assert.IsNotNull(entries, "could not load test data");
|
Assert.IsNotNull(entries, "could not load test data");
|
||||||
|
|
||||||
if (entries == null) {
|
if (entries == null) {
|
||||||
@ -98,7 +118,7 @@ public class TestTransactionParser {
|
|||||||
public void NoFactionNameNoInfluence() {
|
public void NoFactionNameNoInfluence() {
|
||||||
TransactionParser parser = new();
|
TransactionParser parser = new();
|
||||||
|
|
||||||
List<Entry>? entries = Helper.LoadTestData("nofactionname-andnoinfluence.txt");
|
List<Entry>? entries = LoadTestData("nofactionname-andnoinfluence.txt");
|
||||||
Assert.IsNotNull(entries, "could not load test data");
|
Assert.IsNotNull(entries, "could not load test data");
|
||||||
|
|
||||||
if (entries == null) {
|
if (entries == null) {
|
||||||
@ -114,7 +134,7 @@ public class TestTransactionParser {
|
|||||||
public void SellOrganicData() {
|
public void SellOrganicData() {
|
||||||
TransactionParser parser = new();
|
TransactionParser parser = new();
|
||||||
|
|
||||||
List<Entry>? entries = Helper.LoadTestData("SellOrganicData.txt");
|
List<Entry>? entries = LoadTestData("SellOrganicData.txt");
|
||||||
Assert.IsNotNull(entries, "could not load test data");
|
Assert.IsNotNull(entries, "could not load test data");
|
||||||
|
|
||||||
if (entries == null) {
|
if (entries == null) {
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
using EDPlayerJournal.BGS;
|
|
||||||
using EDPlayerJournal.Entries;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EDPlayerJournalTests;
|
|
||||||
|
|
||||||
[TestClass]
|
|
||||||
public class ThargoidKills {
|
|
||||||
[TestMethod]
|
|
||||||
public void ThargoidBonks() {
|
|
||||||
TransactionParser parser = new();
|
|
||||||
|
|
||||||
List<Entry>? entries = Helper.LoadTestData("ThargoidKills.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, 4);
|
|
||||||
|
|
||||||
Assert.IsInstanceOfType(transactions[0], typeof(ThargoidKill), "result is not of type ThargoidKill");
|
|
||||||
Assert.IsInstanceOfType(transactions[1], typeof(ThargoidKill), "result is not of type ThargoidKill");
|
|
||||||
Assert.IsInstanceOfType(transactions[2], typeof(ThargoidKill), "result is not of type ThargoidKill");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
{ "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" }
|
|
Loading…
Reference in New Issue
Block a user