javalent/initiative-tracker

๐Ÿž Encounter XP is 0 with more than one player in pf2e & dnd5e

Trantion897 opened this issue ยท 1 comments

Check for existing bug reports before submitting.

  • I searched for existing Bug Reports and found no similar reports.

Expected Behavior

Encounter XP should be non-zero (affects both inline encounter builder and side panel)

Current behaviour

Encounter XP is missing, summarised as "Trivial"
image

Reproduction

  1. Using a vault with Initiative Tracker set up (I found the bug using Pathfinder settings, but get the same with D&D settings)
  2. Set a default party with at least two characters (alternatively, add the characters directly to the encounter)
  3. Create an encounter with any number of enemies
  4. View the encounter inline - XP is missing
  5. Start the encounter - XP gauge is empty

Which Operating Systems are you using?

  • Android
  • iPhone/iPad
  • Linux
  • macOS
  • Windows

Obsidian Version Check

1.6.7 and 1.5.3

Plugin Version

13.0.12

Confirmation

  • I have disabled all other plugins and the issue still persists.

Possible solution

I debugged the plugin and found that the playerLevels parameter being passed to getCreatureDifficulty() in src/utils/rpg-system/pf2e.ts is an array of strings, so line 89 concatenates instead of adding, so after dividing by the number of PCs we get an invalid array index for return XP_CREATURE_DIFFERENCES[creature_differences] ?? 0;.

I made a quick fix to get it working for me (only for Pathfinder), but I think the root cause will be a change that's caused the playerLevels to be an array of strings, because I think this worked some time before. I haven't looked into where that array is coming from, or which version introduced the issue. Therefore I'm considering this commit a proof of concept rather than a pull request, though I might be able to investigate more later on.

This bug is caused because one of my characters (and the first one alphabetically, so the most likely to be included when I tested it) had all the frontmatter in the PC's note defined as text instead of numbers as they should be. Fixing the note fixes the issue, but I'm trying out a patch to add parseInt() when reading the player's note to save anyone this trouble in future. It will only work when the note is parsed, so for existing characters you'll need to delete and recreate the character in the initiative tracker settings.