Skip to content

Commit

Permalink
Fix to use IntegerParser for th14
Browse files Browse the repository at this point in the history
  • Loading branch information
y-iihoshi committed Jan 1, 2025
1 parent 1daebf6 commit fb34da2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ThScoreFileConverter/Models/Th14/CareerReplacerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ internal class CareerReplacerBase<
where TStPrac : struct, Enum
where TScoreData : IScoreData
{
private static readonly IntegerParser TypeParser = new(@"[12]");

private readonly string pattern;
private readonly MatchEvaluator evaluator;

Expand All @@ -41,15 +43,16 @@ protected CareerReplacerBase(
INumberFormatter formatter)
{
var numDigits = IntegerHelper.GetNumDigits(validCardNumbers.Count());
var cardNumberParser = new IntegerParser($@"\d{{{numDigits}}}");

this.pattern = StringHelper.Create(
$@"{formatPrefix}C({gameModeParser.Pattern})(\d{{{numDigits}}})({charaWithTotalParser.Pattern})([12])");
$@"{formatPrefix}C({gameModeParser.Pattern})({cardNumberParser.Pattern})({charaWithTotalParser.Pattern})({TypeParser.Pattern})");
this.evaluator = new MatchEvaluator(match =>
{
var mode = gameModeParser.Parse(match.Groups[1]);
var number = IntegerHelper.Parse(match.Groups[2].Value);
var number = cardNumberParser.Parse(match.Groups[2]);
var chara = charaWithTotalParser.Parse(match.Groups[3]);
var type = IntegerHelper.Parse(match.Groups[4].Value);
var type = TypeParser.Parse(match.Groups[4]);

Func<Th13.ISpellCard<TLv>, int> getCount = (mode, type) switch
{
Expand Down

0 comments on commit fb34da2

Please sign in to comment.