Fix usable checks on adversary features and locked compendium actors (#1934)

This commit is contained in:
Carlos Fernandez 2026-05-26 09:41:26 -04:00 committed by GitHub
parent ccc4186e42
commit b9416ead5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 5 deletions

View file

@ -148,10 +148,14 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
: null; : null;
} }
/** Returns true if the action is usable */ /**
* Returns true if the action is usable.
* An action is usable on any actor type. For example, an adversary might have a base attack action.
*/
get usable() { get usable() {
const actor = this.actor; const actor = this.actor;
return this.isOwner && actor?.type === 'character'; const pack = actor?.pack ? game.packs.get(actor.pack) : null;
return !pack?.locked && this.isOwner;
} }
static getRollType(parent) { static getRollType(parent) {

View file

@ -73,8 +73,10 @@ export default class DHItem extends foundry.documents.Item {
/** Returns true if the item can be used */ /** Returns true if the item can be used */
get usable() { get usable() {
const actor = this.actor; const actor = this.actor;
const actionsList = this.system.actionsList; const pack = actor?.pack ? game.packs.get(actor.pack) : null;
return this.isOwner && actor?.type === 'character' && (actionsList?.size || actionsList?.length); const hasActions = this.system.actionsList?.size || this.system.actionsList?.length;
const isValidType = actor?.type === 'character' || this.type === 'feature';
return !pack?.locked && this.isOwner && isValidType && hasActions;
} }
/** @inheritdoc */ /** @inheritdoc */

View file

@ -5,7 +5,7 @@
(hasProperty item "toChat" ) "toChat" "editDoc" ) }}' {{#unless hideTooltip}} {{#if (eq type 'attack' )}} (hasProperty item "toChat" ) "toChat" "editDoc" ) }}' {{#unless hideTooltip}} {{#if (eq type 'attack' )}}
data-tooltip="#attack#{{item.actor.uuid}}" {{else}} data-tooltip="#item#{{item.uuid}}" {{/if}} {{/unless}}> data-tooltip="#attack#{{item.actor.uuid}}" {{else}} data-tooltip="#item#{{item.uuid}}" {{/if}} {{/unless}}>
<img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" /> <img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" />
{{#if (or item.system.actionsList.size item.system.actionsList.length item.actionType)}} {{#if item.usable}}
{{#if @root.isNPC}} {{#if @root.isNPC}}
<img class="roll-img d20" src="systems/daggerheart/assets/icons/dice/default/d20.svg" alt="d20"> <img class="roll-img d20" src="systems/daggerheart/assets/icons/dice/default/d20.svg" alt="d20">
{{else}} {{else}}