Resource effects do not work correctly on non-linked token sheets

Issue #221 resolved
Ben Freeland created an issue

Test Version Info

OS Browser Foundry Version DnD5e Version Obsidian Version
Windows 10 Foundry App 0.7.9 1.2.0 4.3.3

Test Prerequisites

  • Obsidian module enabled
  • Default Sheet for Items set to Obsidian Item Sheet
  • Default Sheet for NPC set to Obsidian NPC Sheet

Steps to Reproduce

  1. Create Actor
  2. Add Custom item with type Weapon to actor
  3. Edit newly added weapon and select the top level effect
  4. Click Add Resource
  5. Set Fixed Calculation value for the newly added resource to any positive number (e.g. 4)
  6. Close weapon editor menu
  7. Click Action to attack with weapon and observe that roll functions normally
  8. Create a scene with default settings
  9. Drag test actor created in step 1 to scene
  10. Double click the created token to open the (non-linked) token’s sheet
  11. Click Action to attack with weapon

Expected:

Attack rolls normally just like in step 7.

Observed:

The first roll outputs but the console dumps the following error:

actor.js:147 Uncaught (in promise) TypeError: effects is not iterable
at ObsidianActor._collateOwnedItems (actor.js:147)
at ObsidianActor.prepareDerivedData (actor.js:194)
at ObsidianActor.prepareData (foundry.js:30700)
at ObsidianActor._onUpdate (foundry.js:31039)
at Token._onUpdateTokenActor (foundry.js:45246)
at Token._onUpdate (foundry.js:45138)
at Scene._onUpdateEmbeddedEntity (foundry.js:34253)
at Function._handleUpdateEmbeddedEntity (foundry.js:30046)
at Function._handleUpdateEmbeddedEntity (foundry.js:34301)
at Scene.updateEmbeddedEntity (foundry.js:30015)

Attempting to use the attack again produces no roll output and the following error in the console:

items.js:375 Uncaught (in promise) TypeError: Cannot read property 'length' of undefined
at Object.rollItem (items.js:375)
at Object.roll (items.js:296)
at HTMLHeadingElement.<anonymous> (sheet.js:97)
at HTMLHeadingElement.dispatch (jquery.min.js:2)
at HTMLHeadingElement.v.handle (jquery.min.js:2)

After this attempting to open the editor for the test weapon on the token’s sheet fails with the following error in the console:

TypeError: An error occurred while rendering ObsidianEffectSheet 53: item.flags?.obsidian?.effects?.some is not a function
at hasResource (effect.js:170)
at Array.filter (<anonymous>)
at ObsidianEffectSheet.getData (effect.js:175)
at ObsidianEffectSheet._render (foundry.js:4509)
at ObsidianEffectSheet._render (foundry.js:5157)
at ObsidianEffectSheet._render (effect.js:771)
at ObsidianEffectSheet.render (foundry.js:4479)
at ObsidianEffectSheet.render (foundry.js:5621)
at ObsidianNPC._onItemEdit (base.js:729)
at HTMLAnchorElement.dispatch (jquery.min.js:2)

Attached are the resulting actor.db and scene.db from following these steps on a fresh empty world.

Comments (1)

  1. Log in to comment