Damage reroll

This commit is contained in:
WBHarry 2026-03-15 19:01:59 +01:00
parent b5cd5b3bcd
commit 1f963fa4ab
4 changed files with 56 additions and 23 deletions

View file

@ -45,6 +45,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
rerollDice: TagTeamDialog.#rerollDice,
makeDamageRoll: TagTeamDialog.#makeDamageRoll,
removeDamageRoll: TagTeamDialog.#removeDamageRoll,
rerollDamageDice: TagTeamDialog.#rerollDamageDice,
selectRoll: TagTeamDialog.#selectRoll,
cancelRoll: TagTeamDialog.#onCancelRoll,
finishRoll: TagTeamDialog.#finishRoll
@ -434,6 +435,39 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
});
}
static async #rerollDamageDice(_, button) {
const { memberKey, damageKey, part, dice } = button.dataset;
const memberData = this.party.system.tagTeam.members[memberKey];
const partData = memberData.rollData.options.damage[damageKey].parts[part];
const activeDiceResultKey = Object.keys(partData.dice[dice].results).find(
index => partData.dice[dice].results[index].active
);
const { parsedRoll, rerolledDice } = await game.system.api.dice.DamageRoll.reroll(
partData,
dice,
activeDiceResultKey
);
const rollData = this.party.system.tagTeam.members[memberKey].rollData;
rollData.options.damage[damageKey].parts = rollData.options.damage[damageKey].parts.map((damagePart, index) => {
if (index !== Number.parseInt(part)) return damagePart;
return {
...damagePart,
total: parsedRoll.total,
dice: rerolledDice
};
});
rollData.options.damage[damageKey].total = rollData.options.damage[damageKey].parts.reduce((acc, part) => {
acc += part.total;
return acc;
}, 0);
this.updatePartyData({
[`system.tagTeam.members.${memberKey}.rollData`]: rollData
});
}
async getCriticalDamage(damage) {
const newDamage = foundry.utils.deepClone(damage);
for (let key in newDamage) {