sort combat zones

This commit is contained in:
Florian Stinglmayr 2023-02-25 17:48:01 +01:00
parent e864db8488
commit 831bf38e78
2 changed files with 21 additions and 0 deletions

View File

@ -38,4 +38,23 @@ public class CombatZones {
/// Very high difficulty, so far AX combat zone only
/// </summary>
public static readonly string DifficultyVeryHigh = "Very High";
/// <summary>
/// Returns the given combat zone difficulty as an integer, so it can be sorted.
/// 0 = lowest difficulty, 1 = medium and so forth.
/// </summary>
public static int? DifficultyRank(string difficulty) {
Dictionary<string, int> ranks = new() {
{ DifficultyLow, 0 },
{ DifficultyMedium, 1 },
{ DifficultyHigh, 2 },
{ DifficultyVeryHigh, 3 }
};
if (ranks.TryGetValue(difficulty, out int rank)) {
return rank;
}
return null;
}
}

View File

@ -9,6 +9,7 @@ class CombatZoneFormat : LogFormatter {
public string GenerateLog(Objective objective) {
var logs = objective
.EnabledOfType<CombatZone>()
.OrderBy(x => CombatZones.DifficultyRank(x.Grade))
.GroupBy(x => new { x.Type, x.Grade })
.ToDictionary(x => x.Key, x => x.ToList())
;
@ -47,6 +48,7 @@ class CombatZoneFormat : LogFormatter {
public string GenerateSummary(Objective objective) {
var logs = objective
.EnabledOfType<CombatZone>()
.OrderBy(x => CombatZones.DifficultyRank(x.Grade))
.GroupBy(x => new { x.Type, x.Grade })
.ToDictionary(x => x.Key, x => x.ToList())
;