Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- #126: Fix error when toggling effects.
- #127: Add option chain when looking for item uses.
  • Loading branch information
Larkinabout committed Oct 4, 2024
1 parent 88cd2da commit f9ff62b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion scripts/action-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ Hooks.once("tokenActionHudCoreApiReady", async coreModule => {
* @returns {boolean} Whether the item is usable
*/
#isUsableItem(item) {
return this.showUnchargedItems || item.system.uses.value || !item.system.uses.max;
return this.showUnchargedItems || !!item.system.uses?.value;
}

/**
Expand Down
7 changes: 2 additions & 5 deletions scripts/roll-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,12 @@ Hooks.once("tokenActionHudCoreApiReady", async coreModule => {
* @param {string} actionId The action id
*/
async toggleEffect(event, actor, actionId) {
const effects = actor.effects.entries ? actor.effects.entries : actor.effects;
const actorEffect = effects.find(effect => effect.id === actionId);

const effect = actorEffect ?? actor.allApplicableEffects().find(effect => effect.id === actionId);
const effect = actor.allApplicableEffects().find(effect => effect.id === actionId);
if (!effect) return;

const isRightClick = this.isRightClick(event);

if (isRightClick && actorEffect) {
if (isRightClick && !effect.transfer) {
await effect.delete();
} else {
await effect.update({ disabled: !effect.disabled });
Expand Down
2 changes: 1 addition & 1 deletion scripts/token-action-hud-dnd5e.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/token-action-hud-dnd5e.min.js.map

Large diffs are not rendered by default.

0 comments on commit f9ff62b

Please sign in to comment.