Files
RolemasterDB/src/RolemasterDb.App/Features/AttackResolutionCalculator.cs

13 lines
576 B
C#

namespace RolemasterDb.App.Features;
public static class AttackResolutionCalculator
{
public static AttackResolutionSummary Resolve(int rawRoll, int offensiveBonus, int defensiveBonus) =>
new(rawRoll, offensiveBonus, defensiveBonus, rawRoll + offensiveBonus - defensiveBonus);
public static bool IsFumble(AttackResolutionSummary resolution, AttackTableReference? table) =>
table is { FumbleMinRoll: int fumbleMinRoll, FumbleMaxRoll: int fumbleMaxRoll } &&
resolution.RawRoll >= fumbleMinRoll &&
resolution.RawRoll <= fumbleMaxRoll;
}