89 lines
2.5 KiB
C#
89 lines
2.5 KiB
C#
|
using System;
|
|||
|
using System.Linq;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
using EliteBGS.LogGenerator;
|
|||
|
|
|||
|
namespace EliteBGS;
|
|||
|
|
|||
|
public class DiscordLogGenerator {
|
|||
|
protected List<LogFormatter> formatters = new List<LogFormatter>() {
|
|||
|
new MissionFormat(),
|
|||
|
new FailedMissionFormat(),
|
|||
|
new MurderFormat(),
|
|||
|
new VoucherFormat(),
|
|||
|
new CombatZoneFormat(),
|
|||
|
new KillBondsFormat(),
|
|||
|
new CartographicsFormat(),
|
|||
|
new MicroResourcesFormat(),
|
|||
|
new MarketBuyFormat(),
|
|||
|
new CargoSoldFormatter(),
|
|||
|
new VistaGenomicsFormat(),
|
|||
|
new SearchAndRescueFormat(),
|
|||
|
};
|
|||
|
|
|||
|
protected virtual string GenerateHeader() {
|
|||
|
return "";
|
|||
|
}
|
|||
|
|
|||
|
protected virtual string GenerateFooter() {
|
|||
|
return "\n";
|
|||
|
}
|
|||
|
|
|||
|
protected virtual string GenerateObjectiveHeader(Objective objective) {
|
|||
|
StringBuilder log = new StringBuilder();
|
|||
|
|
|||
|
log.AppendFormat("**Date:** {0}\n", DateTime.Now.ToString("dd/MM/yyyy"));
|
|||
|
log.AppendFormat("**Location:** {0}, {1}\n", objective.System, objective.Faction);
|
|||
|
log.AppendFormat("**Faction:** {0}\n", objective.Faction);
|
|||
|
log.AppendLine("");
|
|||
|
log.AppendLine("```");
|
|||
|
|
|||
|
return log.ToString();
|
|||
|
}
|
|||
|
|
|||
|
protected virtual string GenerateObjectiveFooter(Objective objective) {
|
|||
|
return "```\n";
|
|||
|
}
|
|||
|
|
|||
|
public virtual 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 "";
|
|||
|
}
|
|||
|
|
|||
|
log.AppendFormat("{0}\n", GenerateHeader());
|
|||
|
|
|||
|
foreach (Objective objective in objectives) {
|
|||
|
StringBuilder objlog = new StringBuilder();
|
|||
|
|
|||
|
log.AppendFormat("{0}\n", GenerateObjectiveHeader(objective));
|
|||
|
|
|||
|
foreach (LogFormatter formatter in formatters) {
|
|||
|
string text = formatter.GenerateLog(objective);
|
|||
|
text = text.Trim();
|
|||
|
if (!string.IsNullOrEmpty(text)) {
|
|||
|
objlog.AppendFormat("{0}\n\n", text);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
log.AppendFormat("{0}\n", objlog.ToString().Trim());
|
|||
|
|
|||
|
log.AppendFormat("{0}\n", GenerateObjectiveFooter(objective));
|
|||
|
}
|
|||
|
|
|||
|
log.AppendFormat("{0}\n", GenerateFooter());
|
|||
|
|
|||
|
return log.ToString().Trim();
|
|||
|
}
|
|||
|
}
|