From a88031e27925dbfc68bffbdb601c64fc25b73181 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sat, 18 Jul 2026 23:06:39 +0200 Subject: [PATCH] Fixed ChatMessage damage view --- module/applications/ui/chatLog.mjs | 6 +- templates/ui/chat/parts/damage-part.hbs | 118 ++++++++++++++---------- 2 files changed, 75 insertions(+), 49 deletions(-) diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index e29ed990..e3a628f2 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -251,15 +251,17 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo } const message = game.messages.get(messageData._id); - const target = event.target.closest('[data-die-index]'); + const target = event.target.closest('[data-result]'); if (target.dataset.type === 'damage') { const { isResource, damageType, dice, result } = target.dataset; await message.system.damage.rerollDamageDie(isResource, damageType, dice, result); const updatePath = isResource ? `system.damage.resources.${damageType}` : 'system.damage.main'; + const updateValue = isResource ? + message.system.damage.resources[damageType] : message.system.damage.main; await message.update({ - [updatePath]: message.system.damage.types[damageType].toJSON() + [updatePath]: updateValue.toJSON() }); } else { const rerollDice = message.system.roll.dice[target.dataset.dieIndex]; diff --git a/templates/ui/chat/parts/damage-part.hbs b/templates/ui/chat/parts/damage-part.hbs index d4d1c9fe..ab27187d 100644 --- a/templates/ui/chat/parts/damage-part.hbs +++ b/templates/ui/chat/parts/damage-part.hbs @@ -10,60 +10,84 @@
- {{#each damage.types as | roll index | }} -
{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.inChatRoll')}}: {{roll.total}}
+ {{#if damage.main}} + {{> formula roll=damage.main label=(ifThen hasHealing (localize "DAGGERHEART.GENERAL.healing") (localize "DAGGERHEART.GENERAL.damage")) }} + {{/if}} + {{#each damage.resources as | roll index | }} + {{> formula roll=roll label=(ifThen ../hasHealing (localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.name')) (localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.inChatRoll'))) }} {{/each}}
-
- {{#each damage.types as | roll index | }} -
- - {{#if ../hasHealing}}{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.name')}}{{else}}{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.inChatRoll')}}{{/if}}
{{localize "DAGGERHEART.GENERAL.total"}}: {{roll.total}}
{{#if (and (eq index "hitPoints") ../isDirect)}}
{{localize "DAGGERHEART.CONFIG.DamageType.direct.short"}}
{{/if}} -
+
+ {{#if damage.main}} + {{> damage + label=(ifThen hasHealing (localize "DAGGERHEART.GENERAL.healing") (localize "DAGGERHEART.GENERAL.damage")) + roll=damage.main + index=0 + }} + {{/if}} - {{#if (and (not @root.hasHealing) roll.options.damageTypes.length)}} - - {{/if}} -
- {{#if roll.dice.length}} - {{#each roll.dice}} - {{#each results}} - {{#if active}} -
-
- {{#if hasRerolls}}{{/if}} - {{result}} -
-
- {{/if}} - {{/each}} - {{/each}} - - {{#if roll.modifierTotal}} -
-
{{roll.modifierTotal}}
-
- {{/if}} - {{else}} -
-
{{roll.total}}
-
- {{/if}} -
-
+ {{#each damage.resources as | roll index | }} + {{> damage + label=(ifThen ../hasHealing (localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.name')) (localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.inChatRoll'))) + roll=roll + index=index + isResource=true + }} {{/each}}
- \ No newline at end of file + + +{{#*inline "formula"}} +
{{label}}: {{roll.total}}
+{{/inline}} + +{{#*inline "damage"}} +
+ + {{label}} +
{{localize "DAGGERHEART.GENERAL.total"}}: {{roll.total}}
{{#if (and (eq index "hitPoints") ../isDirect)}}
{{localize "DAGGERHEART.CONFIG.DamageType.direct.short"}}
{{/if}} +
+ {{#if (and (not @root.hasHealing) roll.options.damageTypes.length)}} + + {{/if}} +
+ {{#if roll.dice.length}} + {{#each roll.dice}} + {{#each results}} + {{#if active}} +
+
+ {{#if hasRerolls}}{{/if}} + {{result}} +
+
+ {{/if}} + {{/each}} + {{/each}} + + {{#if roll.modifierTotal}} +
+
{{roll.modifierTotal}}
+
+ {{/if}} + {{else}} +
+
{{roll.total}}
+
+ {{/if}} +
+
+{{/inline}} \ No newline at end of file