Applied Effect with Applied On setting Target not working

Issue #291 resolved
Ben Freeland created an issue

Setup:

foundry: 0.8.9
dnd5e: 1.4.2
obsidian: 5.0.17

Steps to Reproduce

  1. Create character sheet
  2. Create custom feature
  3. Add Effect with Targets set to Self
  4. Add Effect with Applied Effect (Activated by first effect, Applied On: Target), Filter (Score, Ability, Any), and Bonus (constant 5)

Expected

Using feature should apply temporary effect to character that adds +5 to all ability scores

Observed

No effect is added and console prints this error:

duration.js:227 Uncaught (in promise) TypeError: Cannot read property 'actor' of undefined
    at dispatchUpdate (duration.js:227)
    at createActiveEffect (duration.js:216)
    at applyDuration (duration.js:36)
    at createDuration (duration.js:99)
    at handleDurations (duration.js:270)
    at Object.effectRoll (rolls.js:689)
    at Object.create (rolls.js:368)
    at Object.resolveEffect (items.js:252)
    at Object.rollEffect (items.js:353)
    at Object.roll (items.js:297)

Exported sheet with this setup is attached.

Notes:

I think the bug is caused by the target getting converted to it’s document class instance twice in js/module/duration.js, once in applyDuration on line 31:

target = target instanceof CONFIG.Token.documentClass ? target : target.document;

and again in dispatchUpdate on line 222:

    if (target instanceof CONFIG.Token.documentClass) {
        target = target.document;
    }

I suspect the real fix will be a little more involved, but I was able to get this particular test case to work correctly by removing the second conversion.

I first reproduced this on 0.8.8 before remembering there being some things in the 0.8.9 patch notes about fixes to TOKEN.Config and documentClass. Unfortunately I was still able to reproduce this after switching to 0.8.9.

Comments (2)

  1. Log in to comment