2024-11-14 13:30:31 +01:00
|
|
|
|
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) {
|
2024-11-14 13:33:49 +01:00
|
|
|
|
if (!options.IgnorePowerplay) {
|
|
|
|
|
transactions.Add(new MeritsGained(entry) {
|
|
|
|
|
Merits = ((long)(context.CurrentMerits - context.LastMerits)),
|
|
|
|
|
Power = p.Power,
|
|
|
|
|
System = context.CurrentSystem,
|
|
|
|
|
Faction = p.Power,
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-11-14 13:30:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context.LastMerits = context.CurrentMerits;
|
|
|
|
|
}
|
|
|
|
|
}
|