Support signed power point affixes
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
@using System.Diagnostics.CodeAnalysis
|
||||
@using RolemasterDb.App.Domain
|
||||
@using RolemasterDb.App.Features
|
||||
@using PowerPointModifierNotation = RolemasterDb.CriticalParsing.PowerPointModifierNotation
|
||||
|
||||
@if (EffectiveEffects.Count > 0)
|
||||
{
|
||||
@@ -61,7 +62,7 @@
|
||||
CriticalEffectCodes.DirectHits => $"+{effect.ValueInteger?.ToString() ?? string.Empty}",
|
||||
CriticalEffectCodes.FoePenalty
|
||||
or CriticalEffectCodes.AttackerBonusNextRound => effect.Modifier?.ToString() ?? string.Empty,
|
||||
CriticalEffectCodes.PowerPointModifier => effect.ValueExpression ?? string.Empty,
|
||||
CriticalEffectCodes.PowerPointModifier => PowerPointModifierNotation.FormatSignedExpression(effect.ValueExpression) ?? string.Empty,
|
||||
_ => effect.ValueInteger?.ToString()
|
||||
?? effect.Modifier?.ToString()
|
||||
?? effect.ValueExpression
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using RolemasterDb.CriticalParsing;
|
||||
|
||||
namespace RolemasterDb.App.Features;
|
||||
|
||||
@@ -72,25 +73,10 @@ public static class CriticalQuickNotationFormatter
|
||||
|
||||
private static string? FormatPowerPointModifier(string? valueExpression, string? sourceText)
|
||||
{
|
||||
var expression = CollapseWhitespace(valueExpression);
|
||||
if (string.IsNullOrWhiteSpace(expression))
|
||||
{
|
||||
return sourceText;
|
||||
}
|
||||
|
||||
expression = expression.Trim();
|
||||
if (expression.StartsWith('+'))
|
||||
{
|
||||
expression = expression[1..];
|
||||
}
|
||||
|
||||
if (expression.StartsWith('(') && expression.EndsWith(')') && expression.Length > 2)
|
||||
{
|
||||
expression = expression[1..^1].Trim();
|
||||
}
|
||||
|
||||
expression = Regex.Replace(expression, @"\s+", string.Empty);
|
||||
return $"+{expression}pp";
|
||||
var expression = PowerPointModifierNotation.FormatSignedExpression(valueExpression);
|
||||
return string.IsNullOrWhiteSpace(expression)
|
||||
? sourceText
|
||||
: $"{expression}pp";
|
||||
}
|
||||
|
||||
private static string CollapseWhitespace(string? value) =>
|
||||
|
||||
Reference in New Issue
Block a user