Skip to content

Commit

Permalink
Merge pull request #275 from scottbenton/fix/max-10
Browse files Browse the repository at this point in the history
fix(die rolls): Maxed rolls at 10
  • Loading branch information
scottbenton authored Oct 31, 2023
2 parents fb6de3b + e1ea60c commit dbe2ffd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/providers/DieRollProvider/DieRollProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Card
sx={(theme) => ({
Expand Down Expand Up @@ -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}`
: ""}
</Typography>
</Box>
Expand Down

0 comments on commit dbe2ffd

Please sign in to comment.