Compare commits

..

2 Commits

Author SHA1 Message Date
0b47b7331e fix bug with failed missions 2022-12-28 10:43:45 +01:00
2fae724bd2 condense mission fails down 2022-12-28 10:41:26 +01:00
2 changed files with 11 additions and 20 deletions

View File

@ -36,10 +36,6 @@ public class MissionFailed : Transaction {
return -1;
}
public int Amount {
get { return Entries.Count + 1; }
}
public override string ToString() {
StringBuilder builder = new StringBuilder();
@ -47,8 +43,7 @@ public class MissionFailed : Transaction {
return "";
}
builder.AppendFormat("{0}x Mission failed: \"{1}\"",
Amount,
builder.AppendFormat(" Mission failed: \"{0}\"",
Mission?.FriendlyName
);

View File

@ -8,28 +8,24 @@ namespace EliteBGS.LogGenerator;
public class FailedMissionFormat : LogFormatter {
public string GenerateLog(Objective objective) {
var missions = objective.EnabledOfType<MissionFailed>();
StringBuilder builder = new StringBuilder();
if (missions.Count <= 0) {
return "";
}
foreach (var failed in missions) {
MissionFailedEntry f = failed.Failed;
string name;
StringBuilder builder = new StringBuilder();
if (!string.IsNullOrEmpty(f.Mission.FriendlyName)) {
name = f.Mission.FriendlyName;
} else if (!string.IsNullOrEmpty(f.Mission.LocalisedName)) {
name = f.Mission.LocalisedName;
} else {
name = f.Mission.Name;
}
var grouping = missions
.GroupBy(x => x.Mission.IsOnFoot)
;
if (!string.IsNullOrEmpty(failed.Faction)) {
builder.AppendFormat("Failed mission \"{0}\" targeting {1}\n", name, failed.Faction);
foreach (var group in grouping) {
int amount = group.Count();
if (group.Key) {
builder.AppendFormat("Failed {0} On Foot Mission(s)\n", amount);
} else {
builder.AppendFormat("Failed mission \"{0}\"\n", name);
builder.AppendFormat("Failed {0} Ship Mission(s)\n", amount);
}
}