61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
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 "";
|
|
}
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
var grouping = missions
|
|
.GroupBy(x => x.Mission.IsOnFoot)
|
|
;
|
|
|
|
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 {0} Ship Mission(s)\n", amount);
|
|
}
|
|
}
|
|
|
|
return builder.ToString().Trim();
|
|
}
|
|
|
|
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();
|
|
|
|
sb.Append("Fails: ");
|
|
if (onFootFails > 0) {
|
|
sb.AppendFormat("{0} Ground", onFootFails);
|
|
}
|
|
|
|
if (shipFails > 0) {
|
|
if (onFootFails > 0) {
|
|
sb.Append(", ");
|
|
}
|
|
sb.AppendFormat("{0} Ship", shipFails);
|
|
}
|
|
|
|
return sb.ToString();
|
|
}
|
|
}
|