From d136593968fcbf80ed742814bbe651d068fd9b66 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Tue, 29 Jul 2025 19:54:16 +0200 Subject: [PATCH] Removed isReversed on item resources --- module/data/action/baseAction.mjs | 23 +++++++++++------------ module/data/fields/action/costField.mjs | 11 +++++------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index a21b162b..649ee855 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -299,17 +299,16 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel /* SAVE */ async rollSave(actor, event, message) { if (!actor) return; - return actor - .diceRoll({ - event, - title: 'Roll Save', - roll: { - trait: this.save.trait, - difficulty: this.save.difficulty ?? this.actor?.baseSaveDifficulty, - type: 'reaction' - }, - data: actor.getRollData() - }); + return actor.diceRoll({ + event, + title: 'Roll Save', + roll: { + trait: this.save.trait, + difficulty: this.save.difficulty ?? this.actor?.baseSaveDifficulty, + type: 'reaction' + }, + data: actor.getRollData() + }); } updateSaveMessage(result, message, targetId) { @@ -322,7 +321,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel else updateMsg(); } - static rollSaveQuery({ actionId, actorId, event, message }) { + static rollSaveQuery({ actionId, actorId, event, message }) { return new Promise(async (resolve, reject) => { const actor = await fromUuid(actorId), action = await fromUuid(actionId); diff --git a/module/data/fields/action/costField.mjs b/module/data/fields/action/costField.mjs index 79ecd51f..5f67f25f 100644 --- a/module/data/fields/action/costField.mjs +++ b/module/data/fields/action/costField.mjs @@ -54,8 +54,8 @@ export default class CostField extends fields.ArrayField { !resources[c.key] ? a : a && resources[c.key].isReversed - ? resources[c.key].value + (c.total ?? c.value) <= resources[c.key].max - : resources[c.key]?.value >= (c.total ?? c.value), + ? resources[c.key].value + (c.total ?? c.value) <= resources[c.key].max + : resources[c.key]?.value >= (c.total ?? c.value), true ); } @@ -67,8 +67,7 @@ export default class CostField extends fields.ArrayField { if (itemResource.keyIsID) { itemResources[itemResource.key] = { value: this.parent.resource.value ?? 0, - max: CostField.formatMax.call(this, this.parent?.resource?.max), - isReversed: true + max: CostField.formatMax.call(this, this.parent?.resource?.max) }; } } @@ -86,10 +85,10 @@ export default class CostField extends fields.ArrayField { static formatMax(max) { max ??= 0; - if(isNaN(max)) { + if (isNaN(max)) { const roll = Roll.replaceFormulaData(max, this.getRollData()); max = roll.total; } - return max; + return Number(max); } }