From e1ea60c2cb969b64646556a4eda412ab2484bdee Mon Sep 17 00:00:00 2001 From: Scott Benton Date: Tue, 31 Oct 2023 18:24:17 -0400 Subject: [PATCH] fix(die rolls): Maxed rolls at 10 --- src/providers/DieRollProvider/DieRollProvider.tsx | 6 ++++-- .../DieRollProvider/RollSnackbar/StatRollSnackbar.tsx | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/providers/DieRollProvider/DieRollProvider.tsx b/src/providers/DieRollProvider/DieRollProvider.tsx index 208c83f3..15f9cabc 100644 --- a/src/providers/DieRollProvider/DieRollProvider.tsx +++ b/src/providers/DieRollProvider/DieRollProvider.tsx @@ -75,7 +75,7 @@ export function DieRollProvider(props: PropsWithChildren) { const challenge2 = getRoll(10); const action = getRoll(6); - const actionTotal = action + (modifier ?? 0) + (adds ?? 0); + const actionTotal = Math.min(10, action + (modifier ?? 0) + (adds ?? 0)); let result: ROLL_RESULT = ROLL_RESULT.WEAK_HIT; if (actionTotal > challenge1 && actionTotal > challenge2) { @@ -116,7 +116,9 @@ export function DieRollProvider(props: PropsWithChildren) { verboseScreenReaderRolls ? `Rolled ${ moveName ? moveName + " using stat " + label : label - }. On your action die you rolled a ${action} plus ${modifier}${ + }. On your action die you rolled a ${ + action === 10 ? "max of 10" : action + } plus ${modifier}${ adds ? " plus " + adds + " adds" : "" } for a total of ${actionTotal}. On your challenge die you rolled a ${challenge1} and a ${challenge2}, for a ${getRollResultLabel( result diff --git a/src/providers/DieRollProvider/RollSnackbar/StatRollSnackbar.tsx b/src/providers/DieRollProvider/RollSnackbar/StatRollSnackbar.tsx index a763e3b6..5039701a 100644 --- a/src/providers/DieRollProvider/RollSnackbar/StatRollSnackbar.tsx +++ b/src/providers/DieRollProvider/RollSnackbar/StatRollSnackbar.tsx @@ -23,6 +23,8 @@ export interface StatRollSnackbarProps { export function StatRollSnackbar(props: StatRollSnackbarProps) { const { roll, clearRoll, expanded } = props; + const rollTotal = roll.action + (roll.modifier ?? 0) + (roll.adds ?? 0); + return ( ({ @@ -60,9 +62,7 @@ export function StatRollSnackbar(props: StatRollSnackbarProps) { {roll.modifier ? ` + ${roll.modifier}` : ""} {roll.adds ? ` + ${roll.adds}` : ""} {roll.modifier || roll.adds - ? ` = ${ - roll.action + (roll.modifier ?? 0) + (roll.adds ?? 0) - }` + ? ` = ${rollTotal > 10 ? "10 (Max)" : rollTotal}` : ""}