Skip to content

Commit

Permalink
Fix to use IntegerParser for th17
Browse files Browse the repository at this point in the history
  • Loading branch information
y-iihoshi committed Jan 1, 2025
1 parent 4efabb8 commit 284cdda
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ThScoreFileConverter/Models/Th17/AchievementReplacerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using ThScoreFileConverter.Core.Models;
using ThScoreFileConverter.Helpers;

namespace ThScoreFileConverter.Models.Th17;

internal class AchievementReplacerBase : IStringReplaceable
{
private static readonly IntegerParser NumberParser = new(@"\d{2}");

private readonly string pattern;
private readonly MatchEvaluator evaluator;

protected AchievementReplacerBase(string formatPrefix, IReadOnlyList<string> achievementNames, IAchievementHolder achievementHolder)
{
this.pattern = StringHelper.Create($@"{formatPrefix}ACHV(\d{{2}})");
this.pattern = StringHelper.Create($@"{formatPrefix}ACHV({NumberParser.Pattern})");
this.evaluator = new MatchEvaluator(match =>
{
var number = IntegerHelper.Parse(match.Groups[1].Value);
var number = NumberParser.Parse(match.Groups[1]);

if (number <= 0 || number > achievementNames.Count)
return match.ToString();
Expand Down

0 comments on commit 284cdda

Please sign in to comment.