From 5d6eb4b1459fb21c46ef16e9ba7dd745aa8fba23 Mon Sep 17 00:00:00 2001 From: Dapoolp Date: Wed, 13 Aug 2025 02:00:27 +0200 Subject: [PATCH] k --- .../applications/sheets/actors/character.mjs | 6 ++--- module/data/action/baseAction.mjs | 2 ++ module/dice/dhRoll.mjs | 25 +++++++++++-------- module/documents/chatMessage.mjs | 2 +- templates/ui/chat/foundryRollTooltip.hbs | 2 +- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index ae597270..e3dad734 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -639,9 +639,9 @@ export default class CharacterSheet extends DHBaseActorSheet { }) }); - setTimeout(() => { - this.consumeResource(result?.costs); - }, 50); + // setTimeout(() => { + // this.consumeResource(result?.costs); + // }, 50); } async consumeResource(costs) { diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index a886bf49..4f201283 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -208,6 +208,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel } async consume(config, successCost = false) { + console.log("Action consume", config) const usefulResources = { ...foundry.utils.deepClone(this.actor.system.resources), fear: { @@ -246,6 +247,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel } }, []); + console.log(resources) await (this.actor.system.partner ?? this.actor).modifyResource(resources); if ( config.uses?.enabled && diff --git a/module/dice/dhRoll.mjs b/module/dice/dhRoll.mjs index 126a7944..8965b6c9 100644 --- a/module/dice/dhRoll.mjs +++ b/module/dice/dhRoll.mjs @@ -222,26 +222,29 @@ export const registerRollDiceHooks = () => { ) return; - const actor = await fromUuid(config.source.actor), - updates = []; + const actor = await fromUuid(config.source.actor); + let updates = []; if (!actor) return; - if (config.roll.isCritical || config.roll.result.duality === 1) updates.push({ key: 'hope', value: 1 }); - if (config.roll.isCritical) updates.push({ key: 'stress', value: -1 }); - if (config.roll.result.duality === -1) updates.push({ key: 'fear', value: 1 }); + if (config.roll.isCritical || config.roll.result.duality === 1) updates.push({ key: 'hope', value: 1, total: -1, enabled: true }); + if (config.roll.isCritical) updates.push({ key: 'stress', value: -1, total: 1, enabled: true }); + if (config.roll.result.duality === -1) updates.push({ key: 'fear', value: 1, total: -1, enabled: true }); if (config.rerolledRoll) { if (config.rerolledRoll.isCritical || config.rerolledRoll.result.duality === 1) - updates.push({ key: 'hope', value: -1 }); - if (config.rerolledRoll.isCritical) updates.push({ key: 'stress', value: 1 }); - if (config.rerolledRoll.result.duality === -1) updates.push({ key: 'fear', value: -1 }); + updates.push({ key: 'hope', value: -1, total: 1, enabled: true }); + if (config.rerolledRoll.isCritical) updates.push({ key: 'stress', value: 1, total: -1, enabled: true }); + if (config.rerolledRoll.result.duality === -1) updates.push({ key: 'fear', value: -1, total: 1, enabled: true }); } if (updates.length) { const target = actor.system.partner ?? actor; if (!['dead', 'unconscious'].some(x => actor.statuses.has(x))) { - setTimeout(() => { + console.log(config.costs, updates) + updates = [...(config.costs ?? []), ...updates]; + if(config.source.action) + config.costs = updates; + else target.modifyResource(updates); - }, 50); } } @@ -254,5 +257,7 @@ export const registerRollDiceHooks = () => { const currentCombatant = game.combat.combatants.get(game.combat.current?.combatantId); if (currentCombatant?.actorId == actor.id) ui.combat.setCombatantSpotlight(currentCombatant.id); } + + return; }); }; diff --git a/module/documents/chatMessage.mjs b/module/documents/chatMessage.mjs index 398bfcbe..9b878776 100644 --- a/module/documents/chatMessage.mjs +++ b/module/documents/chatMessage.mjs @@ -72,7 +72,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { if(!game.user.isGM) { const applyButtons = html.querySelector(".apply-buttons"); - applyButtons.remove(); + applyButtons?.remove(); if(!this.isAuthor && !this.speakerActor?.isOwner) { const buttons = html.querySelectorAll(".ability-card-footer > .ability-use-button"); buttons.forEach(b => b.remove()); diff --git a/templates/ui/chat/foundryRollTooltip.hbs b/templates/ui/chat/foundryRollTooltip.hbs index 8802c90b..158f5d47 100644 --- a/templates/ui/chat/foundryRollTooltip.hbs +++ b/templates/ui/chat/foundryRollTooltip.hbs @@ -5,7 +5,7 @@ {{localize "DAGGERHEART.UI.Chat.dicePool.title"}} -
+
{{log @root}} {{#each parts}} {{#each rolls}}