From 362facae76c84c5ab8c3a0d08b07d47735f73fad Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 24 Aug 2025 18:35:05 +0200 Subject: [PATCH] Initial damage message --- module/documents/actor.mjs | 7 +++- module/documents/chatMessage.mjs | 22 ++++++++++- styles/less/ui/chat/damage-summary.less | 51 +++++++++++++++++++++++++ styles/less/ui/index.less | 1 + templates/ui/chat/damageSummary.hbs | 18 +++++++++ 5 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 styles/less/ui/chat/damage-summary.less create mode 100644 templates/ui/chat/damageSummary.hbs diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index 4ef8b3b0..ec503c26 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -597,7 +597,9 @@ export default class DhpActor extends Actor { await this.modifyResource(updates); - if (Hooks.call(`${CONFIG.DH.id}.postTakeDamage`, this, updates) === false) return null; + Hooks.call(`${CONFIG.DH.id}.postTakeDamage`, this, updates); + + return updates; } calculateDamage(baseDamage, type) { @@ -645,7 +647,8 @@ export default class DhpActor extends Actor { await this.modifyResource(updates); - if (Hooks.call(`${CONFIG.DH.id}.postTakeHealing`, this, updates) === false) return null; + Hooks.call(`${CONFIG.DH.id}.postTakeHealing`, this, updates); + return updates; } async modifyResource(resources) { diff --git a/module/documents/chatMessage.mjs b/module/documents/chatMessage.mjs index c7f30e48..89afbb61 100644 --- a/module/documents/chatMessage.mjs +++ b/module/documents/chatMessage.mjs @@ -156,6 +156,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { if (targets.length === 0) return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected')); + const targetDamage = []; for (let target of targets) { let damages = foundry.utils.deepClone(this.system.damage); if ( @@ -174,9 +175,26 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { } this.consumeOnSuccess(); - if (this.system.hasHealing) target.actor.takeHealing(damages); - else target.actor.takeDamage(damages, this.system.isDirect); + const updates = this.system.hasHealing + ? await target.actor.takeHealing(damages) + : await target.actor.takeDamage(damages, this.system.isDirect); + targetDamage.push({ token: target, updates: updates }); } + + const cls = getDocumentClass('ChatMessage'); + const msg = { + user: game.user.id, + speaker: cls.getSpeaker(), + title: game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.title'), + content: await foundry.applications.handlebars.renderTemplate( + 'systems/daggerheart/templates/ui/chat/damageSummary.hbs', + { + targets: targetDamage + } + ) + }; + + cls.create(msg); } getAction(actor, itemId, actionId) { diff --git a/styles/less/ui/chat/damage-summary.less b/styles/less/ui/chat/damage-summary.less new file mode 100644 index 00000000..10da88ce --- /dev/null +++ b/styles/less/ui/chat/damage-summary.less @@ -0,0 +1,51 @@ +.daggerheart.chat.damage-summary { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 4px; + + .target-container { + display: flex; + flex-direction: column; + gap: 2px; + border: 1px solid light-dark(@dark-blue, @golden); + border-radius: 6px; + + header { + display: flex; + align-items: center; + gap: 2px; + border-bottom: 1px solid light-dark(@dark-blue, @golden); + + img { + flex: 0; + width: 40px; + height: 40px; + padding: 0 0 0 2px; + } + + label { + flex: 1; + text-align: center; + padding: 0 2px 0 0; + } + } + + .damage-container { + display: flex; + flex-direction: column; + justify-content: center; + gap: 2px; + + .damage-row { + display: flex; + align-items: center; + padding: 0 2px; + gap: 4px; + + label { + font-weight: bold; + } + } + } + } +} diff --git a/styles/less/ui/index.less b/styles/less/ui/index.less index 49d1e009..360a30e3 100644 --- a/styles/less/ui/index.less +++ b/styles/less/ui/index.less @@ -1,6 +1,7 @@ @import './chat/ability-use.less'; @import './chat/action.less'; @import './chat/chat.less'; +@import './chat/damage-summary.less'; @import './chat/downtime.less'; @import './chat/sheet.less'; diff --git a/templates/ui/chat/damageSummary.hbs b/templates/ui/chat/damageSummary.hbs new file mode 100644 index 00000000..0677f234 --- /dev/null +++ b/templates/ui/chat/damageSummary.hbs @@ -0,0 +1,18 @@ +
+ {{#each targets}} +
+
+ + +
+
+ {{#each this.updates}} +
+ +
{{this.value}}
+
+ {{/each}} +
+
+ {{/each}} +
\ No newline at end of file