BeastformAction now respects and handles costs (#484)

This commit is contained in:
WBHarry 2025-07-31 03:25:09 +02:00 committed by GitHub
parent 23b8363dd2
commit bb9036ee7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View file

@ -2225,7 +2225,8 @@
"beastformToManyAdvantages": "You cannot select any more advantages.", "beastformToManyAdvantages": "You cannot select any more advantages.",
"beastformToManyFeatures": "You cannot select any more features.", "beastformToManyFeatures": "You cannot select any more features.",
"beastformEquipWeapon": "You cannot use weapons while in a Beastform.", "beastformEquipWeapon": "You cannot use weapons while in a Beastform.",
"loadoutMaxReached": "You already have {max} cards in your loadout. Move atleast one to your vault before adding a new one." "loadoutMaxReached": "You already have {max} cards in your loadout. Move atleast one to your vault before adding a new one.",
"insufficientResources": "You have insufficient resources"
}, },
"Tooltip": { "Tooltip": {
"disableEffect": "Disable Effect", "disableEffect": "Disable Effect",

View file

@ -224,7 +224,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
keyIsID: resource.keyIsID keyIsID: resource.keyIsID
}; };
}); });
console.log(resources);
await this.actor.modifyResource(resources); await this.actor.modifyResource(resources);
if (config.uses?.enabled) this.update({ 'uses.value': this.uses.value + 1 }); if (config.uses?.enabled) this.update({ 'uses.value': this.uses.value + 1 });
} }

View file

@ -4,15 +4,25 @@ import DHBaseAction from './baseAction.mjs';
export default class DhBeastformAction extends DHBaseAction { export default class DhBeastformAction extends DHBaseAction {
static extraSchemas = [...super.extraSchemas, 'beastform']; static extraSchemas = [...super.extraSchemas, 'beastform'];
async use(_event, ...args) { async use(event, ...args) {
const beastformConfig = this.prepareBeastformConfig(); const beastformConfig = this.prepareBeastformConfig();
const abort = await this.handleActiveTransformations(); const abort = await this.handleActiveTransformations();
if (abort) return; if (abort) return;
const calcCosts = game.system.api.fields.ActionFields.CostField.calcCosts.call(this, this.cost);
const hasCost = game.system.api.fields.ActionFields.CostField.hasCost.call(this, calcCosts);
if (!hasCost) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.insufficientResources'));
return;
}
const { selected, evolved, hybrid } = await BeastformDialog.configure(beastformConfig, this.item); const { selected, evolved, hybrid } = await BeastformDialog.configure(beastformConfig, this.item);
if (!selected) return; if (!selected) return;
const result = await super.use(event, args);
if (!result) return;
await this.transform(selected, evolved, hybrid); await this.transform(selected, evolved, hybrid);
} }