diff --git a/EDPlayerJournal/BGS/MeritsGained.cs b/EDPlayerJournal/BGS/MeritsGained.cs
index 872b018..1f7c40b 100644
--- a/EDPlayerJournal/BGS/MeritsGained.cs
+++ b/EDPlayerJournal/BGS/MeritsGained.cs
@@ -12,7 +12,14 @@ public class MeritsGained : Transaction {
///
/// Number of merits gained
///
- public long Merits { get; set; } = 0;
+ public long Merits {
+ get {
+ return Entries
+ .OfType()
+ .Sum(x => x.MeritsGained)
+ ;
+ }
+ }
///
/// For what power those merits were gained
diff --git a/EDPlayerJournal/BGS/Parsers/PowerplayMeritsParser.cs b/EDPlayerJournal/BGS/Parsers/PowerplayMeritsParser.cs
new file mode 100644
index 0000000..2a26735
--- /dev/null
+++ b/EDPlayerJournal/BGS/Parsers/PowerplayMeritsParser.cs
@@ -0,0 +1,31 @@
+using EDPlayerJournal.Entries;
+
+namespace EDPlayerJournal.BGS.Parsers;
+
+internal class PowerplayMeritsParser : ITransactionParserPart {
+ public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
+ PowerplayMeritsEntry? e = entry as PowerplayMeritsEntry;
+ if (e == null) {
+ throw new ApplicationException("not a valid PowerplayMerits entry");
+ }
+
+ MeritsGained? transaction = null;
+
+ transaction = transactions
+ .OfType()
+ .Where(x => x.System == context.CurrentSystem &&
+ x.Power == e.Power)
+ .FirstOrDefault()
+ ;
+ if (transaction == null) {
+ transaction = new MeritsGained(e) {
+ System = context.CurrentSystem,
+ Power = e.Power,
+ Faction = e.Power,
+ };
+ transactions.Add(transaction);
+ } else {
+ transaction.Entries.Add(e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/EDPlayerJournal/BGS/Parsers/PowerplayParser.cs b/EDPlayerJournal/BGS/Parsers/PowerplayParser.cs
deleted file mode 100644
index a808f23..0000000
--- a/EDPlayerJournal/BGS/Parsers/PowerplayParser.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using EDPlayerJournal.Entries;
-
-namespace EDPlayerJournal.BGS.Parsers;
-
-internal class PowerplayParser : ITransactionParserPart {
- public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
- PowerplayEntry? p = entry as PowerplayEntry;
- if (p == null) {
- return;
- }
-
- if (context.LastMerits == null) {
- context.LastMerits = p.Merits;
- }
-
- context.CurrentMerits = p.Merits;
-
- if (context.LastMerits != context.CurrentMerits) {
- if (!options.IgnorePowerplay) {
- transactions.Add(new MeritsGained(entry) {
- Merits = ((long)(context.CurrentMerits - context.LastMerits)),
- Power = p.Power,
- System = context.CurrentSystem,
- Faction = p.Power,
- });
- }
- }
-
- context.LastMerits = context.CurrentMerits;
- }
-}
diff --git a/EDPlayerJournal/BGS/TransactionParser.cs b/EDPlayerJournal/BGS/TransactionParser.cs
index 47f86d1..9bc39d0 100644
--- a/EDPlayerJournal/BGS/TransactionParser.cs
+++ b/EDPlayerJournal/BGS/TransactionParser.cs
@@ -644,7 +644,7 @@ public class TransactionParser {
{ Events.Missions, new MissionsParser() },
{ Events.MultiSellExplorationData, new MultiSellExplorationDataParser() },
{ Events.Music, new MusicParser() },
- { Events.Powerplay, new PowerplayParser() },
+ { Events.PowerplayMerits, new PowerplayMeritsParser() },
{ Events.ReceiveText, new ReceiveTextParser() },
{ Events.RedeemVoucher, new RedeemVoucherParser() },
{ Events.SearchAndRescue, new SearchAndRescueParser() },
diff --git a/EDPlayerJournal/Entries/PowerplayMeritsEntry.cs b/EDPlayerJournal/Entries/PowerplayMeritsEntry.cs
index 21da115..1edeaf1 100644
--- a/EDPlayerJournal/Entries/PowerplayMeritsEntry.cs
+++ b/EDPlayerJournal/Entries/PowerplayMeritsEntry.cs
@@ -2,6 +2,14 @@
public class PowerplayMeritsEntry : Entry {
protected override void Initialise() {
- // TODO
+ Power = JSON.Value("Power") ?? string.Empty;
+ MeritsGained = JSON.Value("MeritsGained") ?? 0;
+ TotalMerits = JSON.Value("TotalMerits") ?? 0;
}
+
+ public string Power { get; set; } = string.Empty;
+
+ public long MeritsGained { get; set; } = 0;
+
+ public long TotalMerits { get; set; } = 0;
}
diff --git a/EliteBGS/LogGenerator/MeritsGainedFormat.cs b/EliteBGS/LogGenerator/MeritsGainedFormat.cs
index 564394a..b5895d1 100644
--- a/EliteBGS/LogGenerator/MeritsGainedFormat.cs
+++ b/EliteBGS/LogGenerator/MeritsGainedFormat.cs
@@ -1,8 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
+using System.Linq;
using System.Text;
-using EDPlayerJournal;
using EDPlayerJournal.BGS;
namespace EliteBGS.LogGenerator;