Closed fluxxdog closed 5 months ago
Nice catch. I think I have that and some other things handled better in the latest version.
You made your module version "1.3.1" instead of "1.4.1" so it refuses to downgrade.
Working better. Caught another issue. This one hit on Relentless Healing. It only heal 1 point of damage, but I think that was enough to cause an undefined on the const damageDice just before it.
Relentless Endurance 1 (2) ['1', 'healing']0: "1"1: "healing"length: 2[[Prototype]]: Array(0) CrCalculator.js:140 Uncaught (in promise) TypeError: undefined. Cannot read properties of null (reading 'length') [Detected 1 package: fvtt-challenge-calculator] at CrCalculator.js:140:29 at Array.forEach (<anonymous>) at CrCalculator.js:133:17 at Array.forEach (<anonymous>) at CrCalculator.calculateDamagePerRound (CrCalculator.js:116:20) at CrCalculator.calculateOffensiveCR (CrCalculator.js:68:24) at CrCalculator.calculateCRForActor (CrCalculator.js:20:30)
Ok, I added another edge case check along with a try catch that will show the error in the chat to the DM.
Not getting any crashes so far. Much improved.
Ran on a character and got this:
caught (in promise) TypeError: undefined. Cannot read properties of undefined (reading 'parts') [Detected 1 package: fvtt-challenge-calculator] at CrCalculator.js:76:42 at Array.forEach (<anonymous>) at CrCalculator.calculateOffensiveCR (CrCalculator.js:75:16) at CrCalculator.calculateCRForActor (CrCalculator.js:20:30)
Lines in question:
data.items.forEach((item) => { const damages = item.system.damage.parts; const atkBonus =
The character that tripped it has a Loot item (or LootData) that doesn't have a damage field, specifically a spellbook. LootData doesn't include the ActionTemplate so they will never have that field. In your calculateOffensiveCr method, you might want to filter items that don't have that damage field.