diff --git a/EDPlayerJournal/CombatZones.cs b/EDPlayerJournal/CombatZones.cs index 0eec1c9..3c59477 100644 --- a/EDPlayerJournal/CombatZones.cs +++ b/EDPlayerJournal/CombatZones.cs @@ -43,7 +43,7 @@ public class CombatZones { /// Returns the given combat zone difficulty as an integer, so it can be sorted. /// 0 = lowest difficulty, 1 = medium and so forth. /// - public static int? DifficultyRank(string difficulty) { + public static int? DifficultyRank(string? difficulty) { Dictionary ranks = new() { { DifficultyLow, 0 }, { DifficultyMedium, 1 }, @@ -51,6 +51,10 @@ public class CombatZones { { DifficultyVeryHigh, 3 } }; + if (difficulty == null ) { + return null; + } + if (ranks.TryGetValue(difficulty, out int rank)) { return rank; } diff --git a/EliteBGS/LogGenerator/CombatZoneFormat.cs b/EliteBGS/LogGenerator/CombatZoneFormat.cs index e849bd8..33aa726 100644 --- a/EliteBGS/LogGenerator/CombatZoneFormat.cs +++ b/EliteBGS/LogGenerator/CombatZoneFormat.cs @@ -9,7 +9,7 @@ class CombatZoneFormat : LogFormatter { public string GenerateLog(Objective objective) { var logs = objective .EnabledOfType() - .OrderBy(x => CombatZones.DifficultyRank(x.Grade)) + .OrderBy(x => (CombatZones.DifficultyRank(x.Grade) ?? 0)) .GroupBy(x => new { x.Type, x.Grade }) .ToDictionary(x => x.Key, x => x.ToList()) ; @@ -48,7 +48,7 @@ class CombatZoneFormat : LogFormatter { public string GenerateSummary(Objective objective) { var logs = objective .EnabledOfType() - .OrderBy(x => CombatZones.DifficultyRank(x.Grade)) + .OrderBy(x => (CombatZones.DifficultyRank(x.Grade) ?? 0)) .GroupBy(x => new { x.Type, x.Grade }) .ToDictionary(x => x.Key, x => x.ToList()) ;