WBHarry / pf2e-bestiary-tracking

A Foundry VTT Module to let players keep track monster information and statistics for the PF2E system
MIT License
5 stars 4 forks source link

[Bug] Problem in getBestiarySpellLevel #149

Open xdy opened 3 days ago

xdy commented 3 days ago

Got this last night when playing during a fight with the pcs, a haunt and some geists. Not sure what creature caused the problem as I just quickly patched the code.

2BestiaryTracking.js:356 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'spells')
[Detected 1 package: pf2e-bestiary-tracking(1.1.25)]
    at getBestiarySpellLevel (BestiaryTracking.js:356:31)
    at updateBestiaryData (BestiaryTracking.js:18358:13)

The patch I did was to change line 356 to this, but it's possibly spells should be checked earlier.

if (spells.levels && spells.levels[maxLevel].spells[id]) return maxLevel;

and change 360 to this

if (spells.levels[level]?.spells[id]) {
WBHarry commented 3 days ago

Heya. You don't happen to know the specific haunt/geists involved? The fixes you made would stop the errors, but it wouldn't make the functionality in that section of the code actually do what it's supposed to (automatically reveal the spells being cast in the Bestiary).

It seems whichever creatures were present didn't get their spells added to the Bestiary properly 🤔