Skip to content

Commit

Permalink
Merge pull request #81 from addtheletters/external-effect-deletion-di…
Browse files Browse the repository at this point in the history
…sallow

Disallow deleting effects if not owned by actor
  • Loading branch information
Larkinabout authored Mar 30, 2024
2 parents 3080772 + 28fb5da commit b74f8c7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/roll-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,12 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
const effects = 'find' in actor.effects.entries ? actor.effects.entries : actor.effects
let effect = effects.find(effect => effect.id === actionId)

// only allow deletion if effect is directly on this actor
let internalEffect = true

// if the effect isn't directly on the actor, search all applicable effects for it
if (!effect) {
internalEffect = false
for (const e of actor.allApplicableEffects()) {
if (e.id === actionId) {
effect = e
Expand All @@ -428,7 +432,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {

const isRightClick = this.isRightClick(event)

if (isRightClick) {
if (isRightClick && internalEffect) {
await effect.delete()
} else {
await effect.update({ disabled: !effect.disabled })
Expand Down

0 comments on commit b74f8c7

Please sign in to comment.