From d65c0f91fccd2f27d86fd09525778b89169582fa Mon Sep 17 00:00:00 2001 From: WBHarry Date: Wed, 16 Jul 2025 00:53:58 +0200 Subject: [PATCH] More fixes --- module/data/actor/character.mjs | 3 ++- module/data/actor/companion.mjs | 6 ------ module/dice/d20Roll.mjs | 4 ++-- module/dice/dhRoll.mjs | 13 +++++++++++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index e25dba85..68901b35 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -407,7 +407,8 @@ export default class DhCharacter extends BaseDataActor { } prepareDerivedData() { - this.resources.hope.value = Math.min(this.resources.hope.value, this.resources.hope.max); + const baseHope = this.resources.hope.value + (this.companion?.system?.resources?.hope ?? 0); + this.resources.hope.value = Math.min(baseHope, this.resources.hope.max); } getRollData() { diff --git a/module/data/actor/companion.mjs b/module/data/actor/companion.mjs index e10f739b..fc8195d8 100644 --- a/module/data/actor/companion.mjs +++ b/module/data/actor/companion.mjs @@ -124,12 +124,6 @@ export default class DhCompanion extends BaseDataActor { } } - prepareDerivedData() { - if (this.partner) { - this.partner.system.resources.hope.max += this.resources.hope; - } - } - async _preDelete() { if (this.partner) { await this.partner.update({ 'system.companion': null }); diff --git a/module/dice/d20Roll.mjs b/module/dice/d20Roll.mjs index 004e4806..0c29fc42 100644 --- a/module/dice/d20Roll.mjs +++ b/module/dice/d20Roll.mjs @@ -130,9 +130,9 @@ export default class D20Roll extends DHRoll { value: this.options.roll.bonus }); - modifiers.push(...this.getBonus(`roll.${this.options.type}`, `${this.options.type.capitalize()} Bonus`)); + modifiers.push(...this.getBonus(`roll.${this.options.type}`, `${this.options.type?.capitalize()} Bonus`)); modifiers.push( - ...this.getBonus(`roll.${this.options.roll.type}`, `${this.options.roll.type.capitalize()} Bonus`) + ...this.getBonus(`roll.${this.options.roll.type}`, `${this.options.roll.type?.capitalize()} Bonus`) ); return modifiers; diff --git a/module/dice/dhRoll.mjs b/module/dice/dhRoll.mjs index 27288f15..b14f1391 100644 --- a/module/dice/dhRoll.mjs +++ b/module/dice/dhRoll.mjs @@ -184,12 +184,21 @@ export const registerRollDiceHooks = () => { return; const actor = await fromUuid(config.source.actor), - updates = []; + updates = [], + hopeUpdates = []; if (!actor) return; - if (config.roll.isCritical || config.roll.result.duality === 1) updates.push({ key: 'hope', value: 1 }); + if (config.roll.isCritical || config.roll.result.duality === 1) hopeUpdates.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 (hopeUpdates.length) { + if (actor.system.partner) { + actor.system.partner.modifyResource(hopeUpdates); + } else { + updates.push(...hopeUpdates); + } + } + if (updates.length) actor.modifyResource(updates); if (!config.roll.hasOwnProperty('success') && !config.targets?.length) return;