2022-11-24 19:38:19 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using EDPlayerJournal.BGS;
|
|
|
|
|
|
|
|
|
|
namespace EliteBGS.LogGenerator;
|
|
|
|
|
|
|
|
|
|
public class FailedMissionFormat : LogFormatter {
|
|
|
|
|
public string GenerateLog(Objective objective) {
|
|
|
|
|
var missions = objective.EnabledOfType<MissionFailed>();
|
|
|
|
|
|
|
|
|
|
if (missions.Count <= 0) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-28 10:41:26 +01:00
|
|
|
|
StringBuilder builder = new StringBuilder();
|
2022-12-20 18:33:09 +01:00
|
|
|
|
|
2022-12-28 10:41:26 +01:00
|
|
|
|
var grouping = missions
|
|
|
|
|
.GroupBy(x => x.Mission.IsOnFoot)
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
foreach (var group in grouping) {
|
|
|
|
|
int amount = group.Count();
|
2022-12-20 18:33:09 +01:00
|
|
|
|
|
2022-12-28 10:41:26 +01:00
|
|
|
|
if (group.Key) {
|
|
|
|
|
builder.AppendFormat("Failed {0} On Foot Mission(s)\n", amount);
|
2022-12-20 18:33:09 +01:00
|
|
|
|
} else {
|
2022-12-28 10:41:26 +01:00
|
|
|
|
builder.AppendFormat("Failed {0} Ship Mission(s)\n", amount);
|
2022-12-20 18:33:09 +01:00
|
|
|
|
}
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return builder.ToString().Trim();
|
|
|
|
|
}
|
2023-02-23 21:44:55 +01:00
|
|
|
|
|
|
|
|
|
public string GenerateSummary(Objective objective) {
|
|
|
|
|
var missions = objective.EnabledOfType<MissionFailed>();
|
|
|
|
|
|
|
|
|
|
if (missions.Count <= 0) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new();
|
|
|
|
|
|
|
|
|
|
int onFootFails = missions.Where(x => x.Mission.IsOnFoot).Count();
|
|
|
|
|
int shipFails = missions.Where(x => !x.Mission.IsOnFoot).Count();
|
|
|
|
|
|
2023-02-26 22:03:31 +01:00
|
|
|
|
sb.Append("Fails: ");
|
2023-02-23 21:44:55 +01:00
|
|
|
|
if (onFootFails > 0) {
|
2023-02-26 22:03:31 +01:00
|
|
|
|
sb.AppendFormat("{0} Ground", onFootFails);
|
2023-02-23 21:44:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (shipFails > 0) {
|
2023-02-26 22:03:31 +01:00
|
|
|
|
if (onFootFails > 0) {
|
2023-02-23 21:44:55 +01:00
|
|
|
|
sb.Append(", ");
|
|
|
|
|
}
|
|
|
|
|
sb.AppendFormat("{0} Ship", shipFails);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|