diff --git a/module/data/item/domainCard.mjs b/module/data/item/domainCard.mjs index 327dafce..129b0864 100644 --- a/module/data/item/domainCard.mjs +++ b/module/data/item/domainCard.mjs @@ -52,11 +52,11 @@ export default class DHDomainCard extends BaseDataItem { return game.i18n.localize(allDomainData[this.domain].label); } - get isVaultSupressed() { + get vaultSupressed() { return this.inVault && !this.vaultActive; } - get isDomainTouchedSuppressed() { + get domainTouchedSuppressed() { if (!this.parent.system.domainTouched || this.parent.parent?.type !== 'character') return false; const matchingDomainCards = this.parent.parent.items.filter( @@ -65,6 +65,17 @@ export default class DHDomainCard extends BaseDataItem { return matchingDomainCards < this.parent.system.domainTouched; } + get cannotUse() { + if (this.domainTouchedSuppressed) { + return ui.notifications.warn( + game.i18n.format('DAGGERHEART.UI.Notifications.domainTouchRequirement', { + nr: this.domainTouched, + domain: game.i18n.localize(CONFIG.DH.DOMAIN.allDomains()[this.domain].label) + }) + ); + } + } + /* -------------------------------------------- */ /**@override */ diff --git a/module/documents/activeEffect.mjs b/module/documents/activeEffect.mjs index caf99803..ad5a5d83 100644 --- a/module/documents/activeEffect.mjs +++ b/module/documents/activeEffect.mjs @@ -20,10 +20,10 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect { } if (this.parent?.type === 'domainCard') { - const isVaultSupressed = this.parent.system.isVaultSupressed; - const domainTouchedSupressed = this.parent.system.isDomainTouchedSuppressed; + const vaultSupressed = this.parent.system.vaultSupressed; + const domainTouchedSupressed = this.parent.system.domainTouchedSuppressed; - return isVaultSupressed || domainTouchedSupressed; + return vaultSupressed || domainTouchedSupressed; } return super.isSuppressed; diff --git a/module/documents/item.mjs b/module/documents/item.mjs index 7607658c..8fbe2929 100644 --- a/module/documents/item.mjs +++ b/module/documents/item.mjs @@ -146,15 +146,7 @@ export default class DHItem extends foundry.documents.Item { /* -------------------------------------------- */ async use(event) { - /* DomainCard check. Can be expanded or made neater */ - if (this.system.isDomainTouchedSuppressed) { - return ui.notifications.warn( - game.i18n.format('DAGGERHEART.UI.Notifications.domainTouchRequirement', { - nr: this.domainTouched, - domain: game.i18n.localize(CONFIG.DH.DOMAIN.allDomains()[this.domain].label) - }) - ); - } + if (this.system.cannotUse) return; const actions = new Set(this.system.actionsList); if (actions?.size) {