From bf401db483134e297635890743f2254eaae1fbe3 Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Mon, 10 Jan 2022 18:58:50 +0100 Subject: [PATCH] rework how failed missions are handled This cleans up the logs, especially since failed missions don't show a lot of detailed information. --- BGS/GenericDiscordLog.cs | 6 ++++-- BGS/MissionFailed.cs | 21 ++++++++++++++++++++- BGS/NonaDiscordLog.cs | 22 ++++++++++++++++++++++ BGS/Report.cs | 4 ++++ CHANGELOG.md | 14 ++++++++++++++ EliteBGS.csproj | 1 + 6 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 CHANGELOG.md diff --git a/BGS/GenericDiscordLog.cs b/BGS/GenericDiscordLog.cs index a55744a..feed8dd 100644 --- a/BGS/GenericDiscordLog.cs +++ b/BGS/GenericDiscordLog.cs @@ -113,8 +113,10 @@ namespace EliteBGS.BGS { foreach (MissionFailed failed in missions) { MissionFailedEntry f = failed.Failed; - builder.AppendFormat("Failed mission \"{0}\"\n", - f.HumanReadableName == null ? f.Name : f.HumanReadableName + builder.AppendFormat("Failed {0} mission(s) \"{1}\" targeting {2}\n", + failed.Entries.Count, + f.HumanReadableName == null ? f.Name : f.HumanReadableName, + failed.Faction ); } diff --git a/BGS/MissionFailed.cs b/BGS/MissionFailed.cs index e734331..da66b2e 100644 --- a/BGS/MissionFailed.cs +++ b/BGS/MissionFailed.cs @@ -11,6 +11,24 @@ namespace EliteBGS.BGS { Faction = accepted.Faction; } + public override int CompareTo(LogEntry other) { + if (other.GetType() != typeof(MissionFailed)) { + return -1; + } + + MissionFailed failed = other as MissionFailed; + + /* if it is the same mission name, the same faction and the same system, + * collate mission failures together */ + if (failed.Failed.HumanReadableName == Failed.HumanReadableName && + failed.Faction == Faction && + failed.System == System) { + return 0; + } + + return -1; + } + public override string ToString() { StringBuilder builder = new StringBuilder(); @@ -18,7 +36,8 @@ namespace EliteBGS.BGS { return ""; } - builder.AppendFormat("Mission failed: \"{0}\"", + builder.AppendFormat("{0}x Mission failed: \"{1}\"", + Entries.Count, Failed.HumanReadableName != null ? Failed.HumanReadableName : Failed.Name ); diff --git a/BGS/NonaDiscordLog.cs b/BGS/NonaDiscordLog.cs index 1ba379f..e313df8 100644 --- a/BGS/NonaDiscordLog.cs +++ b/BGS/NonaDiscordLog.cs @@ -186,6 +186,25 @@ namespace EliteBGS.BGS { return builder.ToString(); } + private string BuildFailedMissions(Objective objective) { + MissionFailed[] missions = objective.LogEntries.OfType().ToArray(); + StringBuilder builder = new StringBuilder(); + + if (missions.Length <= 0) { + return ""; + } + + foreach (MissionFailed failed in missions) { + MissionFailedEntry f = failed.Failed; + builder.AppendFormat("Failed {0} mission(s) \"{1}\" targeting {2}\n", + failed.Entries.Count, + f.HumanReadableName == null ? f.Name : f.HumanReadableName, + failed.Faction + ); + } + + return builder.ToString(); + } public string GenerateDiscordLog(Report report) { StringBuilder log = new StringBuilder(); @@ -209,6 +228,9 @@ namespace EliteBGS.BGS { var missions = BuildMissionList(objective); entries.Append(missions); + var failed = BuildFailedMissions(objective); + entries.Append(failed); + var vouchers = BuildVouchers(objective); entries.Append(vouchers); diff --git a/BGS/Report.cs b/BGS/Report.cs index 55ee73e..491ea7f 100644 --- a/BGS/Report.cs +++ b/BGS/Report.cs @@ -121,6 +121,10 @@ namespace EliteBGS.BGS { failed.Name + "\" was not recognised"); } + + /* Mission failed should be collated if they are in the same system/station + */ + collate = true; } else if (e.Is(Events.MultiSellExplorationData)) { /* For multi-sell-exploraton-data only the controlling faction of the station sold to matters. */ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..236fa9a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# EliteBGS changelog + +## 0.1.0-beta3 on ??.??.???? + +* Collated failed missions into a single entry with a counter +* Added failed missions to Nova Navy log template + +## 0.1.0-beta2 on 09.01.2022 + +* Adding combat zones has been repaired + +## 0.1.0-beta1 on 07.01.2022 + +* Initial release \ No newline at end of file diff --git a/EliteBGS.csproj b/EliteBGS.csproj index e959ea3..9ab0dcf 100644 --- a/EliteBGS.csproj +++ b/EliteBGS.csproj @@ -168,6 +168,7 @@ Always +