From 88496938bd901ddb221cd37ced20968dd5d563e2 Mon Sep 17 00:00:00 2001 From: IIHOSHI Yoshinori Date: Tue, 31 Dec 2024 16:25:38 +0900 Subject: [PATCH] Fix to use PatternAttribute for th14.3 enums --- TemplateGenerator/Models/Th143/Definitions.cs | 8 ++++---- ThScoreFileConverter.Core/Models/Th143/Day.cs | 10 ++++++++++ .../Models/Th143/ItemWithTotal.cs | 11 +++++++++++ ThScoreFileConverter/Models/Th143/Parsers.cs | 6 ++---- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/TemplateGenerator/Models/Th143/Definitions.cs b/TemplateGenerator/Models/Th143/Definitions.cs index 31f16f4ec..d8231f88a 100644 --- a/TemplateGenerator/Models/Th143/Definitions.cs +++ b/TemplateGenerator/Models/Th143/Definitions.cs @@ -40,21 +40,21 @@ public static class Definitions (Day.Eighth, ("Day8", "八日目")), (Day.Ninth, ("Day9", "九日目")), (Day.Last, ("LastDay", "最終日")), - }.ToStringKeyedDictionary(); + }.ToPatternKeyedDictionary(); public static IReadOnlyDictionary NumScenesPerDay { get; } = EnumHelper.Enumerable.ToDictionary( - static day => day.ToShortName(), + static day => day.ToPattern(), static day => SpellCards.Count(pair => pair.Key.Day == day)); public static IReadOnlyDictionary ItemWithTotalNames { get; } = ItemWithTotalNamesImpl.ToDictionary( - static pair => pair.Item1.ToShortName(), + static pair => pair.Item1.ToPattern(), static pair => (pair.Item2, pair.Item1.ToLongName())); public static IReadOnlyDictionary ItemNames { get; } = ItemWithTotalNamesImpl.Where(static pair => pair.Item1 != ItemWithTotal.Total).ToDictionary( - static pair => pair.Item1.ToShortName(), + static pair => pair.Item1.ToPattern(), static pair => (pair.Item2, pair.Item1.ToLongName())); public static IEnumerable ItemKeysTotalFirst { get; } = ItemWithTotalNames.Keys.RotateRight(); diff --git a/ThScoreFileConverter.Core/Models/Th143/Day.cs b/ThScoreFileConverter.Core/Models/Th143/Day.cs index 4bc2aca64..bbd5c09d1 100644 --- a/ThScoreFileConverter.Core/Models/Th143/Day.cs +++ b/ThScoreFileConverter.Core/Models/Th143/Day.cs @@ -16,59 +16,69 @@ public enum Day /// The 1st Day. /// [EnumAltName("1", LongName = "01")] + [Pattern("1")] First, /// /// The 2nd Day. /// [EnumAltName("2", LongName = "02")] + [Pattern("2")] Second, /// /// The 3rd Day. /// [EnumAltName("3", LongName = "03")] + [Pattern("3")] Third, /// /// The 4th Day. /// [EnumAltName("4", LongName = "04")] + [Pattern("4")] Fourth, /// /// The 5th Day. /// [EnumAltName("5", LongName = "05")] + [Pattern("5")] Fifth, /// /// The 6th Day. /// [EnumAltName("6", LongName = "06")] + [Pattern("6")] Sixth, /// /// The 7th Day. /// [EnumAltName("7", LongName = "07")] + [Pattern("7")] Seventh, /// /// The 8th Day. /// [EnumAltName("8", LongName = "08")] + [Pattern("8")] Eighth, /// /// The 9th Day. /// [EnumAltName("9", LongName = "09")] + [Pattern("9")] Ninth, /// /// The Last Day. /// [EnumAltName("L", LongName = "10")] + [Pattern("L")] Last, } diff --git a/ThScoreFileConverter.Core/Models/Th143/ItemWithTotal.cs b/ThScoreFileConverter.Core/Models/Th143/ItemWithTotal.cs index 8185c7e93..da07022d3 100644 --- a/ThScoreFileConverter.Core/Models/Th143/ItemWithTotal.cs +++ b/ThScoreFileConverter.Core/Models/Th143/ItemWithTotal.cs @@ -16,65 +16,76 @@ public enum ItemWithTotal /// Nimble Fabric. /// [EnumAltName("1", LongName = "ひらり布")] + [Pattern("1")] Fablic, /// /// Tengu's Toy Camera. /// [EnumAltName("2", LongName = "天狗のトイカメラ")] + [Pattern("2")] Camera, /// /// Gap Folding Umbrella. /// [EnumAltName("3", LongName = "隙間の折りたたみ傘")] + [Pattern("3")] Umbrella, /// /// Ghastly Send-Off Lantern. /// [EnumAltName("4", LongName = "亡霊の送り提灯")] + [Pattern("4")] Lantern, /// /// Bloodthirsty Yin-Yang Orb. /// [EnumAltName("5", LongName = "血に飢えた陰陽玉")] + [Pattern("5")] Orb, /// /// Four-Foot Magic Bomb. /// [EnumAltName("6", LongName = "四尺マジックボム")] + [Pattern("6")] Bomb, /// /// Substitute Jizou. /// [EnumAltName("7", LongName = "身代わり地蔵")] + [Pattern("7")] Jizou, /// /// Cursed Decoy Doll. /// [EnumAltName("8", LongName = "呪いのデコイ人形")] + [Pattern("8")] Doll, /// /// A Miracle Mallet Replica. /// [EnumAltName("9", LongName = "打ち出の小槌(レプリカ)")] + [Pattern("9")] Mallet, /// /// No item. /// [EnumAltName("0", LongName = "ノーアイテム")] + [Pattern("0")] NoItem, /// /// Represents total across items. /// [EnumAltName("T", LongName = "合計")] + [Pattern("T")] Total, } diff --git a/ThScoreFileConverter/Models/Th143/Parsers.cs b/ThScoreFileConverter/Models/Th143/Parsers.cs index 4e3a24b07..0c59ea388 100644 --- a/ThScoreFileConverter/Models/Th143/Parsers.cs +++ b/ThScoreFileConverter/Models/Th143/Parsers.cs @@ -20,14 +20,12 @@ internal static class Parsers /// /// Gets the parser of . /// - public static EnumShortNameParser DayParser { get; } = - new EnumShortNameParser(); + public static Core.Models.EnumPatternParser DayParser { get; } = new(); /// /// Gets the parser of . /// - public static EnumShortNameParser ItemWithTotalParser { get; } = - new EnumShortNameParser(); + public static Core.Models.EnumPatternParser ItemWithTotalParser { get; } = new(); /// /// Gets the pattern used for parsing as a long name of a enumerator.