From e0e7cb57922c4b250b2dcf64acf9938ec1248b82 Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Fri, 25 Nov 2022 14:48:59 +0100 Subject: [PATCH] add thargoid formatter for logs --- EliteBGS/DiscordLogGenerator.cs | 1 + EliteBGS/LogGenerator/ThargoidFormatter.cs | 32 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 EliteBGS/LogGenerator/ThargoidFormatter.cs diff --git a/EliteBGS/DiscordLogGenerator.cs b/EliteBGS/DiscordLogGenerator.cs index 9b7e135..12cfc45 100644 --- a/EliteBGS/DiscordLogGenerator.cs +++ b/EliteBGS/DiscordLogGenerator.cs @@ -12,6 +12,7 @@ public class DiscordLogGenerator { new FailedMissionFormat(), new MurderFormat(), new VoucherFormat(), + new ThargoidFormatter(), new CombatZoneFormat(), new KillBondsFormat(), new CartographicsFormat(), diff --git a/EliteBGS/LogGenerator/ThargoidFormatter.cs b/EliteBGS/LogGenerator/ThargoidFormatter.cs new file mode 100644 index 0000000..c9acb4b --- /dev/null +++ b/EliteBGS/LogGenerator/ThargoidFormatter.cs @@ -0,0 +1,32 @@ +using EDPlayerJournal; +using EDPlayerJournal.BGS; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EliteBGS.LogGenerator; + +public class ThargoidFormatter : LogFormatter { + public string GenerateLog(Objective objective) { + List kills = objective.EnabledOfType().ToList(); + + if (kills.Count == 0 ) { + return ""; + } + + Dictionary> sorted = kills + .GroupBy(x => x.ThargoidType) + .ToDictionary(x => x.Key, x => x.ToList()) + ; + + StringBuilder builder = new StringBuilder(); + foreach (var k in sorted) { + string name = Thargoid.GetVesselName(k.Key); + builder.AppendFormat("{0}x {1} killed\n", k.Value.Count, name); + } + + return builder.ToString(); + } +}