From ae212e462d45467433c5c75d001350837f750559 Mon Sep 17 00:00:00 2001 From: Jeremy Valentine <38669521+valentine195@users.noreply.github.com> Date: Fri, 13 Oct 2023 21:02:27 -0400 Subject: [PATCH] fix: fix issue where reroll could happen incorrectly --- src/roller/dice.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/roller/dice.ts b/src/roller/dice.ts index d61a591..7d34926 100644 --- a/src/roller/dice.ts +++ b/src/roller/dice.ts @@ -224,12 +224,7 @@ export class DiceRoller { toReroll = [...this.results].filter(([, { value }]) => this.checkCondition(value, conditionals) ); - while ( - i < times && - toReroll.filter(([, { value }]) => - this.checkCondition(value, conditionals) - ).length > 0 - ) { + while (i < times && toReroll.length > 0) { i++; await Promise.all( toReroll.map(async ([i, roll]) => { @@ -240,6 +235,9 @@ export class DiceRoller { roll.display = `${newValue}`; }) ); + toReroll = toReroll.filter(([, { value }]) => + this.checkCondition(value, conditionals) + ); } toReroll.forEach(([index, value]) => {