make sure missions read as 0 INF if no INF was generated

This commit is contained in:
Florian Stinglmayr 2024-11-14 10:51:18 +01:00
parent 6cbe54ff73
commit be3bceb880

View File

@ -64,6 +64,7 @@ public class MissionFormat : LogFormatter {
Dictionary<string, ulong> passengers = new(); Dictionary<string, ulong> passengers = new();
StringBuilder output = new StringBuilder(); StringBuilder output = new StringBuilder();
long total_influence = 0; long total_influence = 0;
bool hadmissions = false;
var missions = objective.EnabledOfType<MissionCompleted>(); var missions = objective.EnabledOfType<MissionCompleted>();
var support = objective.EnabledOfType<InfluenceSupport>(); var support = objective.EnabledOfType<InfluenceSupport>();
@ -85,6 +86,7 @@ public class MissionFormat : LogFormatter {
++collated[m.MissionName][m.Influence]; ++collated[m.MissionName][m.Influence];
hadmissions = true;
total_influence += m.Influence.Length; total_influence += m.Influence.Length;
if (m.AcceptedEntry != null && if (m.AcceptedEntry != null &&
@ -121,19 +123,23 @@ public class MissionFormat : LogFormatter {
output.Append(failedlog); output.Append(failedlog);
output.Append("\n"); output.Append("\n");
} }
if (failed.Count > 0) {
hadmissions = true;
}
total_influence += failed.Sum(x => x.InfluenceAmount); total_influence += failed.Sum(x => x.InfluenceAmount);
foreach (InfluenceSupport inf in support) { foreach (InfluenceSupport inf in support) {
output.Append(inf.ToString()); output.Append(inf.ToString());
output.Append("\n"); output.Append("\n");
hadmissions = true;
total_influence += inf.Influence.InfluenceAmount; total_influence += inf.Influence.InfluenceAmount;
} }
if (support.Count() > 0) { if (support.Count > 0) {
output.Append("\n"); output.Append("\n");
} }
if (total_influence != 0) { if (hadmissions) {
output.AppendFormat("Total Influence: {0}", total_influence); output.AppendFormat("Total Influence: {0}", total_influence);
} }
@ -141,6 +147,10 @@ public class MissionFormat : LogFormatter {
} }
public string GenerateSummary(Objective objective) { public string GenerateSummary(Objective objective) {
bool hadmissions = objective
.EnabledOfType<MissionCompleted>()
.Count > 0
;
long influence = objective long influence = objective
.EnabledOfType<MissionCompleted>() .EnabledOfType<MissionCompleted>()
.Sum(x => x.Influence.Length) .Sum(x => x.Influence.Length)
@ -154,7 +164,7 @@ public class MissionFormat : LogFormatter {
.Sum(x => x.InfluenceAmount) .Sum(x => x.InfluenceAmount)
; ;
if (influence == 0 && support == 0 && failed == 0) { if (influence == 0 && support == 0 && failed == 0 && !hadmissions) {
return ""; return "";
} }