Remove redundant Rolemaster parser states

This commit is contained in:
2026-04-03 01:44:21 +02:00
parent f0dd79e589
commit 923c6ae26d
7 changed files with 6 additions and 30 deletions

View File

@@ -43,11 +43,11 @@ public sealed class DiceRulesTests
Assert.False(unknownRulesetExpression.Succeeded); Assert.False(unknownRulesetExpression.Succeeded);
Assert.Equal("d10", rolemasterImplicitSingle.Value!.Canonical); Assert.Equal("d10", rolemasterImplicitSingle.Value!.Canonical);
Assert.Equal(DiceExpressionKind.RolemasterStandard, rolemasterImplicitSingle.Value.Kind); Assert.Equal(DiceExpressionKind.Standard, rolemasterImplicitSingle.Value.Kind);
Assert.Equal("15d10-15", rolemasterManyDice.Value!.Canonical); Assert.Equal("15d10-15", rolemasterManyDice.Value!.Canonical);
Assert.Equal(DiceExpressionKind.RolemasterStandard, rolemasterManyDice.Value.Kind); Assert.Equal(DiceExpressionKind.Standard, rolemasterManyDice.Value.Kind);
Assert.Equal("d100+4", rolemasterPercentile.Value!.Canonical); Assert.Equal("d100+4", rolemasterPercentile.Value!.Canonical);
Assert.Equal(DiceExpressionKind.RolemasterStandard, rolemasterPercentile.Value.Kind); Assert.Equal(DiceExpressionKind.Standard, rolemasterPercentile.Value.Kind);
Assert.Equal("d100!+85", rolemasterOpenEnded.Value!.Canonical); Assert.Equal("d100!+85", rolemasterOpenEnded.Value!.Canonical);
Assert.Equal(DiceExpressionKind.RolemasterOpenEndedPercentile, rolemasterOpenEnded.Value.Kind); Assert.Equal(DiceExpressionKind.RolemasterOpenEndedPercentile, rolemasterOpenEnded.Value.Kind);

View File

@@ -57,12 +57,6 @@ public partial class RollDiceStrip
case RollDieKinds.RolemasterStandard: case RollDieKinds.RolemasterStandard:
classes.Add("rolemaster-standard"); classes.Add("rolemaster-standard");
break; break;
case RollDieKinds.RolemasterInitiative:
classes.Add("rolemaster-initiative");
break;
case RollDieKinds.RolemasterPercentile:
classes.Add("rolemaster-percentile");
break;
case RollDieKinds.RolemasterOpenEndedInitial: case RollDieKinds.RolemasterOpenEndedInitial:
classes.Add("rolemaster-open-ended-initial"); classes.Add("rolemaster-open-ended-initial");
break; break;
@@ -103,12 +97,6 @@ public partial class RollDiceStrip
case RollDieKinds.RolemasterStandard: case RollDieKinds.RolemasterStandard:
labels.Add("Rolemaster roll"); labels.Add("Rolemaster roll");
break; break;
case RollDieKinds.RolemasterInitiative:
labels.Add("Rolemaster initiative");
break;
case RollDieKinds.RolemasterPercentile:
labels.Add("Rolemaster percentile");
break;
case RollDieKinds.RolemasterOpenEndedInitial: case RollDieKinds.RolemasterOpenEndedInitial:
labels.Add(die.SignedContribution.HasValue ? "Rolemaster open-ended initial" : "Rolemaster low-end trigger (ignored in total)"); labels.Add(die.SignedContribution.HasValue ? "Rolemaster open-ended initial" : "Rolemaster low-end trigger (ignored in total)");
break; break;

View File

@@ -53,8 +53,6 @@ public sealed record RollSkillRequest(string Visibility);
public static class RollDieKinds public static class RollDieKinds
{ {
public const string RolemasterStandard = "rolemaster-standard"; public const string RolemasterStandard = "rolemaster-standard";
public const string RolemasterInitiative = "rolemaster-initiative";
public const string RolemasterPercentile = "rolemaster-percentile";
public const string RolemasterOpenEndedInitial = "rolemaster-open-ended-initial"; public const string RolemasterOpenEndedInitial = "rolemaster-open-ended-initial";
public const string RolemasterOpenEndedHigh = "rolemaster-open-ended-high"; public const string RolemasterOpenEndedHigh = "rolemaster-open-ended-high";
public const string RolemasterOpenEndedLowSubtract = "rolemaster-open-ended-low-subtract"; public const string RolemasterOpenEndedLowSubtract = "rolemaster-open-ended-low-subtract";

View File

@@ -93,7 +93,6 @@ public sealed class RollLogEntry
public enum DiceExpressionKind public enum DiceExpressionKind
{ {
Standard, Standard,
RolemasterStandard,
RolemasterOpenEndedPercentile RolemasterOpenEndedPercentile
} }

View File

@@ -100,7 +100,7 @@ public static partial class DiceRules
var countPrefix = diceCount == 1 ? string.Empty : diceCount.ToString(); var countPrefix = diceCount == 1 ? string.Empty : diceCount.ToString();
var canonical = $"{countPrefix}d{sides}{(isOpenEnded ? "!" : string.Empty)}{FormatModifier(modifier)}"; var canonical = $"{countPrefix}d{sides}{(isOpenEnded ? "!" : string.Empty)}{FormatModifier(modifier)}";
var kind = isOpenEnded ? DiceExpressionKind.RolemasterOpenEndedPercentile : DiceExpressionKind.RolemasterStandard; var kind = isOpenEnded ? DiceExpressionKind.RolemasterOpenEndedPercentile : DiceExpressionKind.Standard;
return ServiceResult<DiceExpression>.Success(new(diceCount, sides, modifier, canonical, kind)); return ServiceResult<DiceExpression>.Success(new(diceCount, sides, modifier, canonical, kind));
} }

View File

@@ -949,9 +949,8 @@ public sealed class GameService : IGameService
{ {
return expression.Kind switch return expression.Kind switch
{ {
DiceExpressionKind.RolemasterStandard => ComputeRolemasterStandardRoll(expression),
DiceExpressionKind.RolemasterOpenEndedPercentile => ComputeRolemasterOpenEndedRoll(expression, skill.FumbleRange.GetValueOrDefault()), DiceExpressionKind.RolemasterOpenEndedPercentile => ComputeRolemasterOpenEndedRoll(expression, skill.FumbleRange.GetValueOrDefault()),
_ => ComputeStandardRoll(expression) _ => ComputeRolemasterStandardRoll(expression)
}; };
} }
@@ -1423,20 +1422,12 @@ public sealed class GameService : IGameService
return $"{preview} | rolemaster"; return $"{preview} | rolemaster";
} }
if (dice.Any(die => string.Equals(die.Kind, RollDieKinds.RolemasterInitiative, StringComparison.Ordinal)))
return $"{string.Join(" + ", dice.Select(die => die.Roll.ToString()))} | initiative";
if (dice.Any(die => string.Equals(die.Kind, RollDieKinds.RolemasterPercentile, StringComparison.Ordinal)))
return $"{dice[0].Roll} | percentile";
return string.Join(", ", dice.Take(3).Select(die => die.Roll.ToString())); return string.Join(", ", dice.Take(3).Select(die => die.Roll.ToString()));
} }
private static bool IsRolemasterDieKind(string? kind) private static bool IsRolemasterDieKind(string? kind)
{ {
return kind is RollDieKinds.RolemasterStandard or return kind is RollDieKinds.RolemasterStandard or
RollDieKinds.RolemasterInitiative or
RollDieKinds.RolemasterPercentile or
RollDieKinds.RolemasterOpenEndedInitial or RollDieKinds.RolemasterOpenEndedInitial or
RollDieKinds.RolemasterOpenEndedHigh or RollDieKinds.RolemasterOpenEndedHigh or
RollDieKinds.RolemasterOpenEndedLowSubtract; RollDieKinds.RolemasterOpenEndedLowSubtract;

View File

@@ -107,7 +107,7 @@ Affected areas:
Current validation is split between generic expression parsing and D6 option validation. Rolemaster needs its own validation layer. Current validation is split between generic expression parsing and D6 option validation. Rolemaster needs its own validation layer.
Validation rules to add: Validation rules to add:
- `RolemasterStandard` - standard Rolemaster expressions
- supports generic `NdS` syntax with any supported side count - supports generic `NdS` syntax with any supported side count
- assumes a dice count of `1` when the count is omitted before `d` - assumes a dice count of `1` when the count is omitted before `d`
- integer modifier required - integer modifier required