diff --git a/EliteBGS/LogGenerator/CargoSoldFormatter.cs b/EliteBGS/LogGenerator/CargoSoldFormatter.cs index ced96de..f67103a 100644 --- a/EliteBGS/LogGenerator/CargoSoldFormatter.cs +++ b/EliteBGS/LogGenerator/CargoSoldFormatter.cs @@ -58,11 +58,20 @@ public class CargoSoldFormatter : LogFormatter { public string GenerateSummary(Objective objective) { SellCargo[] sold = objective.EnabledOfType().ToArray(); long totalProfit = sold.Sum(x => x.Profit); + long tons = sold.Sum(x => x.Amount); - if (totalProfit >= 100000) { - return string.Format("Trade: {0}", Credits.FormatMillions(totalProfit)); + if (tons <= 0) { + return ""; } - return ""; + StringBuilder builder = new(); + + builder.Append("Trade: "); + builder.AppendFormat("{0}t", tons); + if (totalProfit >= 100000) { + builder.AppendFormat(", {0} Profit", Credits.FormatMillions(totalProfit)); + } + + return builder.ToString(); } } diff --git a/EliteBGS/LogGenerator/GenericFormat.cs b/EliteBGS/LogGenerator/GenericFormat.cs index 699c5bd..0fd9531 100644 --- a/EliteBGS/LogGenerator/GenericFormat.cs +++ b/EliteBGS/LogGenerator/GenericFormat.cs @@ -26,7 +26,7 @@ public class GenericFormat : LogFormatter where Type : Transaction { return builder.ToString(); } - public string GenerateSummary(Objective objective) { + public virtual string GenerateSummary(Objective objective) { throw new System.NotImplementedException(); } } diff --git a/EliteBGS/LogGenerator/KillBondsFormat.cs b/EliteBGS/LogGenerator/KillBondsFormat.cs index 1435cf1..31e7af7 100644 --- a/EliteBGS/LogGenerator/KillBondsFormat.cs +++ b/EliteBGS/LogGenerator/KillBondsFormat.cs @@ -1,6 +1,38 @@ -using EDPlayerJournal.BGS; +using EDPlayerJournal; +using EDPlayerJournal.BGS; +using System.Linq; +using System.Text; namespace EliteBGS.LogGenerator; public class KillBondsFormat : GenericFormat { + public override string GenerateSummary(Objective objective) { + StringBuilder builder = new StringBuilder(); + + var bonds = objective + .EnabledOfType() + .GroupBy(x => x.VictimFaction) + .ToDictionary(x => x.Key, x => x.ToList()) + ; + + if (bonds.Count <= 0) { + return ""; + } + + builder.Append("Killbonds: "); + foreach (var entry in bonds) { + long sum = (long)entry.Value.Sum(x => (decimal)x.TotalSum); + builder.AppendFormat("{0} against {1}, ", + Credits.FormatMillions(sum), + entry.Key + ); + } + + if (builder.Length > 2) { + // Remove trailing comma + builder.Remove(builder.Length - 2, 2); + } + + return builder.ToString(); + } } diff --git a/EliteBGS/LogGenerator/MarketBuyFormat.cs b/EliteBGS/LogGenerator/MarketBuyFormat.cs index 2eed5e1..56af36d 100644 --- a/EliteBGS/LogGenerator/MarketBuyFormat.cs +++ b/EliteBGS/LogGenerator/MarketBuyFormat.cs @@ -1,6 +1,17 @@ using EDPlayerJournal.BGS; +using System.Linq; namespace EliteBGS.LogGenerator; public class MarketBuyFormat : GenericFormat { + public override string GenerateSummary(Objective objective) { + long tons = objective + .EnabledOfType() + .Sum(x => x.Amount) + ; + if (tons <= 0) { + return ""; + } + return string.Format("Market: {0}t bought", tons); + } } diff --git a/EliteBGS/LogGenerator/SearchAndRescueFormat.cs b/EliteBGS/LogGenerator/SearchAndRescueFormat.cs index bbf75b1..a5b6eb2 100644 --- a/EliteBGS/LogGenerator/SearchAndRescueFormat.cs +++ b/EliteBGS/LogGenerator/SearchAndRescueFormat.cs @@ -1,6 +1,18 @@ -using EDPlayerJournal.BGS; +using EDPlayerJournal; +using EDPlayerJournal.BGS; +using System.Linq; namespace EliteBGS.LogGenerator; public class SearchAndRescueFormat : GenericFormat { + public override string GenerateSummary(Objective objective) { + long profit = objective + .EnabledOfType() + .Sum(x => x.Count) + ; + if (profit <= 0) { + return ""; + } + return string.Format("S&R: {0}t", profit); + } } diff --git a/EliteBGS/LogGenerator/VistaGenomicsFormat.cs b/EliteBGS/LogGenerator/VistaGenomicsFormat.cs index 1a2b4ca..f2d65b3 100644 --- a/EliteBGS/LogGenerator/VistaGenomicsFormat.cs +++ b/EliteBGS/LogGenerator/VistaGenomicsFormat.cs @@ -1,6 +1,18 @@ -using EDPlayerJournal.BGS; +using EDPlayerJournal; +using EDPlayerJournal.BGS; +using System.Linq; namespace EliteBGS.LogGenerator; class VistaGenomicsFormat : GenericFormat { + public override string GenerateSummary(Objective objective) { + long profit = objective + .EnabledOfType() + .Sum(x => x.TotalValue) + ; + if (profit <= 0) { + return ""; + } + return string.Format("Organic: {0} Profit", Credits.FormatMillions(profit)); + } } diff --git a/EliteBGS/OneLineDiscordLog.cs b/EliteBGS/OneLineDiscordLog.cs index ab5a7d4..e1b74d9 100644 --- a/EliteBGS/OneLineDiscordLog.cs +++ b/EliteBGS/OneLineDiscordLog.cs @@ -1,4 +1,8 @@ -namespace EliteBGS; +using EliteBGS.LogGenerator; +using System.Linq; +using System.Text; + +namespace EliteBGS; public class OneLineDiscordLog : DiscordLogGenerator { protected override string GenerateObjectiveHeader(Objective objective) { @@ -10,7 +14,7 @@ public class OneLineDiscordLog : DiscordLogGenerator { } protected override string GenerateObjectiveFooter(Objective objective) { - return ""; + return "\n"; } protected override string GenerateFooter() { @@ -21,9 +25,38 @@ public class OneLineDiscordLog : DiscordLogGenerator { return ""; } - protected override string TransformFinalLogForObjective(Objective objective, string log) { - string[] lines = log.Split("\n", System.StringSplitOptions.RemoveEmptyEntries); - return string.Join(", ", lines); + public override string GenerateDiscordLog(Report report) { + StringBuilder log = new StringBuilder(); + + if (report == null) { + return ""; + } + + var objectives = report.Objectives + .Where(x => x.IsEnabled && x.Transactions.Count() > 0) + ; + + if (objectives == null || objectives.Count() <= 0) { + return ""; + } + + foreach (Objective objective in objectives) { + log.AppendFormat("{0}", GenerateObjectiveHeader(objective)); + + foreach (LogFormatter formatter in formatters) { + string text = formatter.GenerateSummary(objective); + text = text.Trim(); + if (!string.IsNullOrEmpty(text)) { + log.AppendFormat("{0}; ", text); + } + } + + log.AppendFormat("{0}", GenerateObjectiveFooter(objective)); + } + + log.AppendFormat("{0}", GenerateFooter()); + + return log.ToString().Trim(); } public override string ToString() {