Removed isReversed on item resources

This commit is contained in:
WBHarry 2025-07-29 19:54:16 +02:00
parent 28df395e89
commit d136593968
2 changed files with 16 additions and 18 deletions

View file

@ -299,17 +299,16 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
/* SAVE */ /* SAVE */
async rollSave(actor, event, message) { async rollSave(actor, event, message) {
if (!actor) return; if (!actor) return;
return actor return actor.diceRoll({
.diceRoll({ event,
event, title: 'Roll Save',
title: 'Roll Save', roll: {
roll: { trait: this.save.trait,
trait: this.save.trait, difficulty: this.save.difficulty ?? this.actor?.baseSaveDifficulty,
difficulty: this.save.difficulty ?? this.actor?.baseSaveDifficulty, type: 'reaction'
type: 'reaction' },
}, data: actor.getRollData()
data: actor.getRollData() });
});
} }
updateSaveMessage(result, message, targetId) { updateSaveMessage(result, message, targetId) {
@ -322,7 +321,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
else updateMsg(); else updateMsg();
} }
static rollSaveQuery({ actionId, actorId, event, message }) { static rollSaveQuery({ actionId, actorId, event, message }) {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
const actor = await fromUuid(actorId), const actor = await fromUuid(actorId),
action = await fromUuid(actionId); action = await fromUuid(actionId);

View file

@ -54,8 +54,8 @@ export default class CostField extends fields.ArrayField {
!resources[c.key] !resources[c.key]
? a ? a
: a && resources[c.key].isReversed : 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].max
: resources[c.key]?.value >= (c.total ?? c.value), : resources[c.key]?.value >= (c.total ?? c.value),
true true
); );
} }
@ -67,8 +67,7 @@ export default class CostField extends fields.ArrayField {
if (itemResource.keyIsID) { if (itemResource.keyIsID) {
itemResources[itemResource.key] = { itemResources[itemResource.key] = {
value: this.parent.resource.value ?? 0, value: this.parent.resource.value ?? 0,
max: CostField.formatMax.call(this, this.parent?.resource?.max), max: CostField.formatMax.call(this, this.parent?.resource?.max)
isReversed: true
}; };
} }
} }
@ -86,10 +85,10 @@ export default class CostField extends fields.ArrayField {
static formatMax(max) { static formatMax(max) {
max ??= 0; max ??= 0;
if(isNaN(max)) { if (isNaN(max)) {
const roll = Roll.replaceFormulaData(max, this.getRollData()); const roll = Roll.replaceFormulaData(max, this.getRollData());
max = roll.total; max = roll.total;
} }
return max; return Number(max);
} }
} }