diff --git a/EliteBGS/DiscordLogGenerator.cs b/EliteBGS/DiscordLogGenerator.cs index d941366..22a23ed 100644 --- a/EliteBGS/DiscordLogGenerator.cs +++ b/EliteBGS/DiscordLogGenerator.cs @@ -21,6 +21,7 @@ public class DiscordLogGenerator { new CargoSoldFormatter(), new VistaGenomicsFormat(), new SearchAndRescueFormat(), + new MeritsGainedFormat(), }; protected virtual string GetToolVersion() { diff --git a/EliteBGS/LogGenerator/MeritsGainedFormat.cs b/EliteBGS/LogGenerator/MeritsGainedFormat.cs new file mode 100644 index 0000000..d0148f3 --- /dev/null +++ b/EliteBGS/LogGenerator/MeritsGainedFormat.cs @@ -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() + .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() + .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(); + } +}