Fix journey end calculation and hope reduction when gaining scars (#1900)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run

This commit is contained in:
Carlos Fernandez 2026-05-19 05:13:59 -04:00 committed by GitHub
parent d152bfc906
commit 4504379fcf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View file

@ -57,6 +57,7 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
let returnMessage = game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.avoidScar'); let returnMessage = game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.avoidScar');
if (config.roll.fate.value <= this.actor.system.levelData.level.current) { if (config.roll.fate.value <= this.actor.system.levelData.level.current) {
const maxHope = this.actor.system.resources.hope.max + this.actor.system.scars;
const newScarAmount = this.actor.system.scars + 1; const newScarAmount = this.actor.system.scars + 1;
await this.actor.update({ await this.actor.update({
system: { system: {
@ -64,7 +65,7 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
} }
}); });
if (newScarAmount >= this.actor.system.resources.hope.max) { if (newScarAmount >= maxHope) {
await this.actor.setDeathMoveDefeated(CONFIG.DH.GENERAL.defeatedConditionChoices.dead.id); await this.actor.setDeathMoveDefeated(CONFIG.DH.GENERAL.defeatedConditionChoices.dead.id);
return game.i18n.format('DAGGERHEART.UI.Chat.deathMove.journeysEnd', { scars: newScarAmount }); return game.i18n.format('DAGGERHEART.UI.Chat.deathMove.journeysEnd', { scars: newScarAmount });
} }

View file

@ -840,12 +840,13 @@ export default class DhCharacter extends DhCreature {
const newHopeMax = this.resources.hope.max + diff; const newHopeMax = this.resources.hope.max + diff;
const newHopeValue = Math.min(newHopeMax, this.resources.hope.value); const newHopeValue = Math.min(newHopeMax, this.resources.hope.value);
if (newHopeValue != this.resources.hope.value) { if (newHopeValue != this.resources.hope.value) {
if (!changes.system.resources.hope) changes.system.resources.hope = { value: 0 }; changes.system = foundry.utils.mergeObject(changes.system ?? {}, {
resources: {
changes.system.resources.hope = { hope: {
...changes.system.resources.hope, value: (changes.system?.resources?.hope?.value ?? 0) + newHopeMax
value: changes.system.resources.hope.value + newHopeValue }
}; }
});
} }
} }