EDBGS/EliteBGS/NonaDiscordLog.cs

80 lines
2.3 KiB
C#
Raw Normal View History

2022-11-24 19:38:19 +01:00
using System;
using System.Text;
using System.Globalization;
using EDPlayerJournal;
2022-11-29 16:39:20 +01:00
using System.Linq;
2022-11-24 19:38:19 +01:00
namespace EliteBGS.BGS;
public class NonaDiscordLog : DiscordLogGenerator {
private string FormatDate() {
CultureInfo cultureInfo = CultureInfo.InvariantCulture;
StringBuilder date = new StringBuilder();
2022-12-18 10:15:17 +01:00
DateTime today = DateTime.UtcNow;
2022-11-24 19:38:19 +01:00
string suffix;
if (today.Day == 1 || today.Day == 21 || today.Day == 31) {
suffix = "st";
} else if (today.Day == 2 || today.Day == 22) {
suffix = "nd";
2023-01-03 16:33:29 +01:00
// Shakaka wins the price for finding this "bug"!
} else if (today.Day == 3 || today.Day == 23) {
2022-11-24 19:38:19 +01:00
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";
}
2022-11-29 16:39:20 +01:00
int legacycount = objective.Transactions
.Where(x => x.IsLegacy)
.Count()
;
log.AppendFormat(":globe_with_meridians: `Target:` {0}\n", location);
2022-11-29 16:39:20 +01:00
if (legacycount > 0) {
log.Append(":rotating_light: `Warning`: Some actions were done in E:D Legacy\n");
}
2022-11-24 19:38:19 +01:00
log.Append(":clipboard: `Conducted:`\n");
log.Append("```\n");
2022-11-24 19:38:19 +01:00
return log.ToString();
}
protected override string GenerateObjectiveFooter(Objective objective) {
return "```\n";
2022-11-24 19:38:19 +01:00
}
protected override string GenerateHeader() {
return string.Format(":clock2: `Date:` {0}\n", FormatDate());
2022-11-24 19:38:19 +01:00
}
protected override string GenerateFooter() {
return "\n";
2022-11-24 19:38:19 +01:00
}
public override string ToString() {
return "Nova Navy Log";
}
}