fix: title-case jobs and skip empty ones

This commit is contained in:
Anna 2023-11-15 11:07:09 -05:00
parent fe65226598
commit a150c0d76f
Signed by: anna
GPG Key ID: D0943384CD9F87D1
2 changed files with 12 additions and 7 deletions

View File

@ -48,14 +48,17 @@ internal static class BreakdownExt {
name => name.ToUpperInvariant()
),
[Breakdown.MainJob] = Service.DataManager.GetExcelSheet<ClassJob>()!
.Where(cj => cj.RowId != 0)
.Where(cj => cj.RowId != 0 && !string.IsNullOrWhiteSpace(cj.Name.RawString))
.ToDictionary(
cj => cj.RowId.ToString(),
cj => cj.Name.RawString
cj => Util.TitleCase(cj.Name.RawString)
),
};
private static Dictionary<Breakdown, string[]> Keys { get; } = new() {
[Breakdown.Country] = ISO3166.Country.List
.Select(c => c.TwoLetterCode)
.ToArray(),
[Breakdown.CharacterRace] = Service.DataManager.GetExcelSheet<Race>()!
.Where(race => race.RowId != 0)
.Select(race => race.RowId.ToString())
@ -108,13 +111,9 @@ internal static class BreakdownExt {
};
}
private static readonly string[] CountryCodes = ISO3166.Country.List
.Select(c => c.TwoLetterCode)
.ToArray();
internal static string[] GetBreakdownKeys(this Breakdown breakdown) {
return breakdown switch {
Breakdown.Country => CountryCodes,
Breakdown.Country => Keys[Breakdown.Country],
Breakdown.Gender => new[] {
"female",
"non_binary",

View File

@ -10,4 +10,10 @@ internal static class Util {
return $"{replaced[..1].ToUpperInvariant()}{replaced[1..]}";
}
internal static string TitleCase(string text) {
var parts = text.Trim().Split(' ');
var capitalised = parts.Select(part => $"{part[..1].ToUpperInvariant()}{part[1..]}");
return string.Join(' ', capitalised);
}
}