mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-22 07:23:37 +02:00
Damage reroll
This commit is contained in:
parent
b5cd5b3bcd
commit
1f963fa4ab
4 changed files with 56 additions and 23 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue