add merits to the log
This commit is contained in:
parent
693d49be14
commit
4cefc393b5
@ -12,7 +12,14 @@ public class MeritsGained : Transaction {
|
||||
/// <summary>
|
||||
/// Number of merits gained
|
||||
/// </summary>
|
||||
public long Merits { get; set; } = 0;
|
||||
public long Merits {
|
||||
get {
|
||||
return Entries
|
||||
.OfType<PowerplayMeritsEntry>()
|
||||
.Sum(x => x.MeritsGained)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For what power those merits were gained
|
||||
|
31
EDPlayerJournal/BGS/Parsers/PowerplayMeritsParser.cs
Normal file
31
EDPlayerJournal/BGS/Parsers/PowerplayMeritsParser.cs
Normal file
@ -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<MeritsGained>()
|
||||
.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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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() },
|
||||
|
@ -2,6 +2,14 @@
|
||||
|
||||
public class PowerplayMeritsEntry : Entry {
|
||||
protected override void Initialise() {
|
||||
// TODO
|
||||
Power = JSON.Value<string?>("Power") ?? string.Empty;
|
||||
MeritsGained = JSON.Value<long?>("MeritsGained") ?? 0;
|
||||
TotalMerits = JSON.Value<long?>("TotalMerits") ?? 0;
|
||||
}
|
||||
|
||||
public string Power { get; set; } = string.Empty;
|
||||
|
||||
public long MeritsGained { get; set; } = 0;
|
||||
|
||||
public long TotalMerits { get; set; } = 0;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user