change one line discord log to only show summaries

This commit is contained in:
2023-04-19 10:06:10 +02:00
parent fce534c88f
commit 8cf8d7f529
7 changed files with 121 additions and 12 deletions

View File

@@ -58,11 +58,20 @@ public class CargoSoldFormatter : LogFormatter {
public string GenerateSummary(Objective objective) {
SellCargo[] sold = objective.EnabledOfType<SellCargo>().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();
}
}

View File

@@ -26,7 +26,7 @@ public class GenericFormat<Type> : LogFormatter where Type : Transaction {
return builder.ToString();
}
public string GenerateSummary(Objective objective) {
public virtual string GenerateSummary(Objective objective) {
throw new System.NotImplementedException();
}
}

View File

@@ -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<FactionKillBonds> {
public override string GenerateSummary(Objective objective) {
StringBuilder builder = new StringBuilder();
var bonds = objective
.EnabledOfType<FactionKillBonds>()
.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();
}
}

View File

@@ -1,6 +1,17 @@
using EDPlayerJournal.BGS;
using System.Linq;
namespace EliteBGS.LogGenerator;
public class MarketBuyFormat : GenericFormat<BuyCargo> {
public override string GenerateSummary(Objective objective) {
long tons = objective
.EnabledOfType<BuyCargo>()
.Sum(x => x.Amount)
;
if (tons <= 0) {
return "";
}
return string.Format("Market: {0}t bought", tons);
}
}

View File

@@ -1,6 +1,18 @@
using EDPlayerJournal.BGS;
using EDPlayerJournal;
using EDPlayerJournal.BGS;
using System.Linq;
namespace EliteBGS.LogGenerator;
public class SearchAndRescueFormat : GenericFormat<SearchAndRescue> {
public override string GenerateSummary(Objective objective) {
long profit = objective
.EnabledOfType<SearchAndRescue>()
.Sum(x => x.Count)
;
if (profit <= 0) {
return "";
}
return string.Format("S&R: {0}t", profit);
}
}

View File

@@ -1,6 +1,18 @@
using EDPlayerJournal.BGS;
using EDPlayerJournal;
using EDPlayerJournal.BGS;
using System.Linq;
namespace EliteBGS.LogGenerator;
class VistaGenomicsFormat : GenericFormat<OrganicData> {
public override string GenerateSummary(Objective objective) {
long profit = objective
.EnabledOfType<OrganicData>()
.Sum(x => x.TotalValue)
;
if (profit <= 0) {
return "";
}
return string.Format("Organic: {0} Profit", Credits.FormatMillions(profit));
}
}