Skip to content

Commit

Permalink
Fix to use PatternAttribute for th14.3 enums
Browse files Browse the repository at this point in the history
  • Loading branch information
y-iihoshi committed Dec 31, 2024
1 parent e12ebc4 commit 8849693
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
8 changes: 4 additions & 4 deletions TemplateGenerator/Models/Th143/Definitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ public static class Definitions
(Day.Eighth, ("Day8", "八日目")),
(Day.Ninth, ("Day9", "九日目")),
(Day.Last, ("LastDay", "最終日")),
}.ToStringKeyedDictionary();
}.ToPatternKeyedDictionary();

public static IReadOnlyDictionary<string, int> NumScenesPerDay { get; } =
EnumHelper<Day>.Enumerable.ToDictionary(
static day => day.ToShortName(),
static day => day.ToPattern(),
static day => SpellCards.Count(pair => pair.Key.Day == day));

public static IReadOnlyDictionary<string, (string ShortName, string LongName)> ItemWithTotalNames { get; } =
ItemWithTotalNamesImpl.ToDictionary(
static pair => pair.Item1.ToShortName(),
static pair => pair.Item1.ToPattern(),
static pair => (pair.Item2, pair.Item1.ToLongName()));

public static IReadOnlyDictionary<string, (string ShortName, string LongName)> 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<string> ItemKeysTotalFirst { get; } = ItemWithTotalNames.Keys.RotateRight();
Expand Down
10 changes: 10 additions & 0 deletions ThScoreFileConverter.Core/Models/Th143/Day.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,69 @@ public enum Day
/// The 1st Day.
/// </summary>
[EnumAltName("1", LongName = "01")]
[Pattern("1")]
First,

/// <summary>
/// The 2nd Day.
/// </summary>
[EnumAltName("2", LongName = "02")]
[Pattern("2")]
Second,

/// <summary>
/// The 3rd Day.
/// </summary>
[EnumAltName("3", LongName = "03")]
[Pattern("3")]
Third,

/// <summary>
/// The 4th Day.
/// </summary>
[EnumAltName("4", LongName = "04")]
[Pattern("4")]
Fourth,

/// <summary>
/// The 5th Day.
/// </summary>
[EnumAltName("5", LongName = "05")]
[Pattern("5")]
Fifth,

/// <summary>
/// The 6th Day.
/// </summary>
[EnumAltName("6", LongName = "06")]
[Pattern("6")]
Sixth,

/// <summary>
/// The 7th Day.
/// </summary>
[EnumAltName("7", LongName = "07")]
[Pattern("7")]
Seventh,

/// <summary>
/// The 8th Day.
/// </summary>
[EnumAltName("8", LongName = "08")]
[Pattern("8")]
Eighth,

/// <summary>
/// The 9th Day.
/// </summary>
[EnumAltName("9", LongName = "09")]
[Pattern("9")]
Ninth,

/// <summary>
/// The Last Day.
/// </summary>
[EnumAltName("L", LongName = "10")]
[Pattern("L")]
Last,
}
11 changes: 11 additions & 0 deletions ThScoreFileConverter.Core/Models/Th143/ItemWithTotal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,65 +16,76 @@ public enum ItemWithTotal
/// Nimble Fabric.
/// </summary>
[EnumAltName("1", LongName = "ひらり布")]
[Pattern("1")]
Fablic,

/// <summary>
/// Tengu's Toy Camera.
/// </summary>
[EnumAltName("2", LongName = "天狗のトイカメラ")]
[Pattern("2")]
Camera,

/// <summary>
/// Gap Folding Umbrella.
/// </summary>
[EnumAltName("3", LongName = "隙間の折りたたみ傘")]
[Pattern("3")]
Umbrella,

/// <summary>
/// Ghastly Send-Off Lantern.
/// </summary>
[EnumAltName("4", LongName = "亡霊の送り提灯")]
[Pattern("4")]
Lantern,

/// <summary>
/// Bloodthirsty Yin-Yang Orb.
/// </summary>
[EnumAltName("5", LongName = "血に飢えた陰陽玉")]
[Pattern("5")]
Orb,

/// <summary>
/// Four-Foot Magic Bomb.
/// </summary>
[EnumAltName("6", LongName = "四尺マジックボム")]
[Pattern("6")]
Bomb,

/// <summary>
/// Substitute Jizou.
/// </summary>
[EnumAltName("7", LongName = "身代わり地蔵")]
[Pattern("7")]
Jizou,

/// <summary>
/// Cursed Decoy Doll.
/// </summary>
[EnumAltName("8", LongName = "呪いのデコイ人形")]
[Pattern("8")]
Doll,

/// <summary>
/// A Miracle Mallet Replica.
/// </summary>
[EnumAltName("9", LongName = "打ち出の小槌(レプリカ)")]
[Pattern("9")]
Mallet,

/// <summary>
/// No item.
/// </summary>
[EnumAltName("0", LongName = "ノーアイテム")]
[Pattern("0")]
NoItem,

/// <summary>
/// Represents total across items.
/// </summary>
[EnumAltName("T", LongName = "合計")]
[Pattern("T")]
Total,
}
6 changes: 2 additions & 4 deletions ThScoreFileConverter/Models/Th143/Parsers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ internal static class Parsers
/// <summary>
/// Gets the parser of <see cref="Day"/>.
/// </summary>
public static EnumShortNameParser<Day> DayParser { get; } =
new EnumShortNameParser<Day>();
public static Core.Models.EnumPatternParser<Day> DayParser { get; } = new();

/// <summary>
/// Gets the parser of <see cref="ItemWithTotal"/>.
/// </summary>
public static EnumShortNameParser<ItemWithTotal> ItemWithTotalParser { get; } =
new EnumShortNameParser<ItemWithTotal>();
public static Core.Models.EnumPatternParser<ItemWithTotal> ItemWithTotalParser { get; } = new();

/// <summary>
/// Gets the pattern used for parsing as a long name of a <see cref="Day"/> enumerator.
Expand Down

0 comments on commit 8849693

Please sign in to comment.