From bb9036ee7a6b218f0b3ac69d612aec2976328c0f Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Thu, 31 Jul 2025 03:25:09 +0200 Subject: [PATCH] BeastformAction now respects and handles costs (#484) --- lang/en.json | 3 ++- module/data/action/baseAction.mjs | 2 +- module/data/action/beastformAction.mjs | 12 +++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lang/en.json b/lang/en.json index efe04425..8846f995 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2225,7 +2225,8 @@ "beastformToManyAdvantages": "You cannot select any more advantages.", "beastformToManyFeatures": "You cannot select any more features.", "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": { "disableEffect": "Disable Effect", diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index 52b87dec..5114fa61 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -224,7 +224,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel keyIsID: resource.keyIsID }; }); - console.log(resources); + await this.actor.modifyResource(resources); if (config.uses?.enabled) this.update({ 'uses.value': this.uses.value + 1 }); } diff --git a/module/data/action/beastformAction.mjs b/module/data/action/beastformAction.mjs index ee5f3c6a..836024ff 100644 --- a/module/data/action/beastformAction.mjs +++ b/module/data/action/beastformAction.mjs @@ -4,15 +4,25 @@ import DHBaseAction from './baseAction.mjs'; export default class DhBeastformAction extends DHBaseAction { static extraSchemas = [...super.extraSchemas, 'beastform']; - async use(_event, ...args) { + async use(event, ...args) { const beastformConfig = this.prepareBeastformConfig(); const abort = await this.handleActiveTransformations(); 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); if (!selected) return; + const result = await super.use(event, args); + if (!result) return; + await this.transform(selected, evolved, hybrid); }