diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index 210727d7..d17ddbb5 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -254,8 +254,8 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo const target = event.target.closest('[data-die-index]'); if (target.dataset.type === 'damage') { - const { damageType, dice, result } = target.dataset; - await message.system.damage.rerollDamageDice(damageType, dice, result); + const { damageType, dice } = target.dataset; + await message.system.damage.rerollDamageDice(damageType, dice); await message.update({ 'system.damage.types': { [damageType]: { diff --git a/module/data/chat-message/actorRoll.mjs b/module/data/chat-message/actorRoll.mjs index 002715fe..834d2dab 100644 --- a/module/data/chat-message/actorRoll.mjs +++ b/module/data/chat-message/actorRoll.mjs @@ -59,21 +59,20 @@ class ChatMessageRollDamage extends foundry.abstract.DataModel { } } - async rerollDamageDice(damageType, dice, resultIndex) { + async rerollDamageDice(damageType, dice) { const reroll = this.types[damageType].roll; const rerollDice = reroll.dice[dice]; - const diceResult = rerollDice.results[resultIndex]; - await rerollDice.reroll(`/r1=${diceResult.result}`); + await rerollDice.reroll(`/r1=${rerollDice.total}`); await reroll._evaluate(); - - const rerolledResult = rerollDice.results[rerollDice.results.length - 1]; - if (rerolledResult) { + + const result = rerollDice.results.find(x => x.active); + if (result) { const fakeRoll = { _evaluated: true, dice: [new foundry.dice.terms.Die({ ...rerollDice, - results: [rerolledResult], - total: rerolledResult.value, + results: [result], + total: result.value, faces: rerollDice.faces })], options: { appearance: {} } diff --git a/module/dice/damageRoll.mjs b/module/dice/damageRoll.mjs index 14b88c15..3c99f489 100644 --- a/module/dice/damageRoll.mjs +++ b/module/dice/damageRoll.mjs @@ -19,15 +19,11 @@ export default class DamageRoll extends DHRoll { for (const roll of config.roll) { await roll.roll.evaluate(); - - if (!config.damage?.types) config.damage = { types: {} }; config.damage.types[roll.applyTo] = { roll: roll.roll, damageTypes: roll.damageTypes ?? [] }; } - - roll._evaluated = true; } static async buildPost(roll, config, message) { diff --git a/templates/ui/chat/parts/damage-part.hbs b/templates/ui/chat/parts/damage-part.hbs index e1d35b97..cd4085e0 100644 --- a/templates/ui/chat/parts/damage-part.hbs +++ b/templates/ui/chat/parts/damage-part.hbs @@ -40,7 +40,7 @@