[Fix] 397 - Reroll Improvements (#400)

* Fixed reroll correcting automation hope/fear/stress

* Fixed advantage/disadvantage reroll counting on d20s
This commit is contained in:
WBHarry 2025-07-25 00:06:41 +02:00 committed by GitHub
parent e8e328039e
commit 80744381f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 86 additions and 7 deletions

View file

@ -1,4 +1,5 @@
import D20RollDialog from '../applications/dialogs/d20RollDialog.mjs';
import { getDiceSoNicePresets } from '../config/generalConfig.mjs';
import DHRoll from './dhRoll.mjs';
export default class D20Roll extends DHRoll {
@ -156,6 +157,14 @@ export default class D20Roll extends DHRoll {
dice: roll.dAdvantage?.denomination,
value: roll.dAdvantage?.total
};
data.dice = data.dice.map(dice => ({
...dice,
results: dice.results.filter(x => !x.rerolled),
rerolled: {
any: dice.results.some(x => x.rerolled),
rerolls: dice.results.filter(x => x.rerolled)
}
}));
data.isCritical = roll.isCritical;
data.extra = roll.dice
.filter(d => !roll.baseTerms.includes(d))
@ -188,6 +197,26 @@ export default class D20Roll extends DHRoll {
await game.dice3d.showForRoll(parsedRoll, game.user, true);
}
return { newRoll, parsedRoll };
const rerolled = {
any: true,
rerolls: [
...(message.system.roll.dice[0].rerolled?.rerolls?.length > 0
? [message.system.roll.dice[0].rerolled?.rerolls]
: []),
rollString.terms[0].results
]
};
return {
newRoll: {
...newRoll,
dice: [
{
...newRoll.dice[0],
rerolled: rerolled
}
]
},
parsedRoll
};
}
}