change one line discord log to only show summaries
This commit is contained in:
parent
fce534c88f
commit
8cf8d7f529
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user