add thargoid kills to transaction parser
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace EDPlayerJournal.BGS;
|
||||
public class FactionKillBonds : Transaction {
|
||||
public int TotalSum {
|
||||
public ulong TotalSum {
|
||||
get {
|
||||
return Entries
|
||||
return (ulong)Entries
|
||||
.OfType<FactionKillBondEntry>()
|
||||
.Sum(x => x.Reward)
|
||||
.Sum(x => (decimal)x.Reward)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
44
EDPlayerJournal/BGS/ThargoidKill.cs
Normal file
44
EDPlayerJournal/BGS/ThargoidKill.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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,11 +580,26 @@ 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 {
|
||||
private static Dictionary<string, TransactionParserPart> ParserParts { get; } = new()
|
||||
{
|
||||
{ Events.CommitCrime, new CommitCrimeParser() },
|
||||
{ Events.Docked, new DockedParser() },
|
||||
{ Events.FactionKillBond, new FactionKillBondParser() },
|
||||
{ Events.FSDJump, new FSDJumpParser() },
|
||||
{ Events.Location, new LocationParser() },
|
||||
{ Events.MarketBuy, new MarketBuyParser() },
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
namespace EDPlayerJournal;
|
||||
|
||||
public class Credits {
|
||||
public static string FormatCredits(int amount) {
|
||||
public static string FormatCredits(uint amount) {
|
||||
return FormatCredits((long)amount);
|
||||
}
|
||||
|
||||
public static string FormatCredits(ulong amount) {
|
||||
return FormatCredits((long)amount);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ public class FactionKillBondEntry : Entry {
|
||||
/// <summary>
|
||||
/// Reward given
|
||||
/// </summary>
|
||||
public int Reward { get; set; }
|
||||
public ulong Reward { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// Faction that awarded the kill bond
|
||||
/// </summary>
|
||||
@@ -23,7 +23,7 @@ public class FactionKillBondEntry : Entry {
|
||||
public string? VictimFactionLocalised { get; set; }
|
||||
|
||||
protected override void Initialise() {
|
||||
Reward = JSON.Value<int?>("Reward") ?? 0;
|
||||
Reward = JSON.Value<ulong?>("Reward") ?? 0;
|
||||
AwardingFaction = JSON.Value<string>("AwardingFaction");
|
||||
AwardingFactionLocalised = JSON.Value<string>("AwardingFaction_Localised");
|
||||
VictimFaction = JSON.Value<string>("VictimFaction");
|
||||
|
||||
Reference in New Issue
Block a user