diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index e3a628f2..c457a6a6 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -181,21 +181,13 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo async onRollSimple(event, message) { const buttonType = event.target.dataset.type ?? 'damage'; const total = message.rolls.reduce((a, c) => a + Roll.fromJSON(c).total, 0); - const damages = { - hitPoints: { - damageTypes: [], - roll: { total } - } - }; const targets = Array.from(game.user.targets); - if (targets.length === 0) return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected')); - - targets.forEach(target => { - if (buttonType === 'healing') target.actor.takeHealing(damages); - else target.actor.takeDamage(damages); - }); + for (const target of targets) { + if (buttonType === 'healing') target.actor.takeHealing({ hitPoints: total }); + else target.actor.takeDamage({ total }); + } } async abilityUseButton(event, message) { diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index 38277c35..666d9ac1 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -747,11 +747,11 @@ export default class DhpActor extends Actor { return updates; } - async takeHealing(healings) { - if (Hooks.call(`${CONFIG.DH.id}.preTakeHealing`, this, healings) === false) return null; + async takeHealing(args) { + args = this.#parseDamageArgs({ resources: 'resources' in args ? args.resources : args }); + if (Hooks.call(`${CONFIG.DH.id}.preTakeHealing`, this, args) === false) return null; - const resources = 'resources' in healings ? healings.resources : healings; - const updates = this.#parseDamageArgs({ resources }).resourceUpdates; + const updates = args.resourceUpdates; for (const u of updates) { const shouldFlip = !(u.key === 'fear' || this.system?.resources?.[u.key]?.isReversed === false); u.value = shouldFlip ? u.value * -1 : u.value;