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 */
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);

View file

@ -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);
}
}