add format for merits gained in log

This commit is contained in:
Florian Stinglmayr 2024-11-14 13:52:17 +01:00
parent d9dd2cc524
commit 88b770e5ec
2 changed files with 51 additions and 0 deletions

View File

@ -21,6 +21,7 @@ public class DiscordLogGenerator {
new CargoSoldFormatter(),
new VistaGenomicsFormat(),
new SearchAndRescueFormat(),
new MeritsGainedFormat(),
};
protected virtual string GetToolVersion() {

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EDPlayerJournal;
using EDPlayerJournal.BGS;
namespace EliteBGS.LogGenerator;
public class MeritsGainedFormat : LogFormatter {
public string GenerateLog(Objective objective) {
var builder = new StringBuilder();
var merits = objective
.EnabledOfType<MeritsGained>()
.GroupBy(x => x.Power)
.ToDictionary(x => x.Key, x => x.Sum(x => x.Merits))
;
if (merits == null || merits.Count == 0) {
return "";
}
foreach (var merit in merits) {
builder.AppendFormat("{0} merits gained for {1}\n", merit.Value, merit.Key);
}
return builder.ToString().Trim();
}
public string GenerateSummary(Objective objective) {
var builder = new StringBuilder();
var merits = objective
.EnabledOfType<MeritsGained>()
.GroupBy(x => x.Power)
.ToDictionary(x => x.Key, x => x.Sum(x => x.Merits))
;
if (merits == null || merits.Count == 0) {
return "";
}
foreach (var merit in merits) {
builder.AppendFormat("MRT: {0}, {1}; ", merit.Key, merit.Value);
}
return builder.ToString().Trim();
}
}