Skip to content

Commit

Permalink
fix: fix issue where reroll could happen incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Oct 14, 2023
1 parent c13922d commit ae212e4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/roller/dice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]) => {
Expand All @@ -240,6 +235,9 @@ export class DiceRoller {
roll.display = `${newValue}`;
})
);
toReroll = toReroll.filter(([, { value }]) =>
this.checkCondition(value, conditionals)
);
}

toReroll.forEach(([index, value]) => {
Expand Down

0 comments on commit ae212e4

Please sign in to comment.