Skip to content

Commit

Permalink
Fix to use IntegerParser for th18
Browse files Browse the repository at this point in the history
  • Loading branch information
y-iihoshi committed Jan 1, 2025
1 parent 8ed5c66 commit dba1478
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ThScoreFileConverter/Models/Th18/AbilityCardReplacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@

using System.Linq;
using System.Text.RegularExpressions;
using ThScoreFileConverter.Core.Models;
using ThScoreFileConverter.Helpers;

namespace ThScoreFileConverter.Models.Th18;

// %T18ABIL[xx]
internal sealed class AbilityCardReplacer(IAbilityCardHolder holder) : IStringReplaceable
{
private static readonly string Pattern = StringHelper.Create($@"{Definitions.FormatPrefix}ABIL(\d{{2}})");
private static readonly IntegerParser NumberParser = new(@"\d{2}");
private static readonly string Pattern = StringHelper.Create($@"{Definitions.FormatPrefix}ABIL({NumberParser.Pattern})");

private readonly MatchEvaluator evaluator = new(match =>
{
var number = IntegerHelper.Parse(match.Groups[1].Value);
var number = NumberParser.Parse(match.Groups[1]);

if (!Definitions.AbilityCardTable.TryGetValue(number - 1, out var card))
return match.ToString();
Expand Down

0 comments on commit dba1478

Please sign in to comment.