EDBGS/EliteBGS/LogGenerator/CombatZoneFormat.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2022-11-26 16:27:51 +01:00
using EDPlayerJournal;
using EDPlayerJournal.BGS;
using System.Linq;
using System.Text;
2022-11-24 19:38:19 +01:00
namespace EliteBGS.LogGenerator;
2022-11-26 16:27:51 +01:00
class CombatZoneFormat : LogFormatter {
public string GenerateLog(Objective objective) {
var logs = objective
.EnabledOfType<CombatZone>()
.GroupBy(x => new { x.Type, x.Grade })
.ToDictionary(x => x.Key, x => x.ToList())
;
StringBuilder builder = new StringBuilder();
if (logs == null || logs.Count() <= 0) {
return "";
}
foreach (var log in logs) {
int optionals = log.Value
.Sum(x => x.OptionalObjectivesCompleted)
;
2022-12-07 22:43:24 +01:00
if (!string.IsNullOrEmpty(log.Key.Grade)) {
builder.AppendFormat("Won {0}x {1} {2} Combat Zone(s)",
log.Value.Count,
log.Key.Grade,
log.Key.Type
);
} else {
builder.AppendFormat("Won {0}x {1} Combat Zone(s)",
log.Value.Count,
log.Key.Type
);
}
if (optionals > 0) {
builder.AppendFormat(" (with {0} optional objectives)", optionals);
}
builder.Append("\n");
2022-11-26 16:27:51 +01:00
}
return builder.ToString().Trim();
}
2022-11-24 19:38:19 +01:00
}