80 lines
2.3 KiB
C#
80 lines
2.3 KiB
C#
using System;
|
|
using System.Text;
|
|
using System.Globalization;
|
|
using EDPlayerJournal;
|
|
using System.Linq;
|
|
|
|
namespace EliteBGS.BGS;
|
|
|
|
public class NonaDiscordLog : DiscordLogGenerator {
|
|
private string FormatDate() {
|
|
CultureInfo cultureInfo = CultureInfo.InvariantCulture;
|
|
StringBuilder date = new StringBuilder();
|
|
DateTime today = DateTime.UtcNow;
|
|
string suffix;
|
|
|
|
if (today.Day == 1 || today.Day == 21 || today.Day == 31) {
|
|
suffix = "st";
|
|
} else if (today.Day == 2 || today.Day == 22) {
|
|
suffix = "nd";
|
|
// Shakaka wins the price for finding this "bug"!
|
|
} else if (today.Day == 3 || today.Day == 23) {
|
|
suffix = "rd";
|
|
} else {
|
|
suffix = "th";
|
|
}
|
|
|
|
date.AppendFormat("{0} {1}{2}, {3}",
|
|
cultureInfo.DateTimeFormat.GetMonthName(today.Month),
|
|
today.Day, suffix,
|
|
today.Year + EliteDangerous.YearOffset
|
|
);
|
|
|
|
return date.ToString();
|
|
}
|
|
|
|
protected override string GenerateObjectiveHeader(Objective objective) {
|
|
StringBuilder log = new StringBuilder();
|
|
|
|
string location;
|
|
|
|
if (!string.IsNullOrEmpty(objective.System) && !string.IsNullOrEmpty(objective.Faction)) {
|
|
location = string.Format("{0}, {1}", objective.System, objective.Faction);
|
|
} else if (!string.IsNullOrEmpty(objective.System)) {
|
|
location = objective.System;
|
|
} else {
|
|
location = "Unknown Location";
|
|
}
|
|
|
|
int legacycount = objective.Transactions
|
|
.Where(x => x.IsLegacy)
|
|
.Count()
|
|
;
|
|
|
|
log.AppendFormat(":globe_with_meridians: `Target:` {0}\n", location);
|
|
if (legacycount > 0) {
|
|
log.Append(":rotating_light: `Warning`: Some actions were done in E:D Legacy\n");
|
|
}
|
|
log.Append(":clipboard: `Conducted:`\n");
|
|
log.Append("```\n");
|
|
|
|
return log.ToString();
|
|
}
|
|
|
|
protected override string GenerateObjectiveFooter(Objective objective) {
|
|
return "```\n";
|
|
}
|
|
|
|
protected override string GenerateHeader() {
|
|
return string.Format(":clock2: `Date:` {0}\n", FormatDate());
|
|
}
|
|
|
|
protected override string GenerateFooter() {
|
|
return "\n";
|
|
}
|
|
|
|
public override string ToString() {
|
|
return "Nova Navy Log";
|
|
}
|
|
}
|