kakaroto / Beyond20

D&D Beyond Character Sheet Integration in Roll20
GNU General Public License v3.0
484 stars 141 forks source link

Homebrew monster damage values carried over to another monster #1118

Open lplayer12893 opened 2 months ago

lplayer12893 commented 2 months ago

All of the following is done in the dndbeyond Combat Tracker. When I select my homebrew monster (an NPC very similar to a drow mage) which has a Staff attack with one and two-handed damage values, then select another monster (a shadow demon which the NPC can summon) WITHOUT selecting the 'X' icon to close the first sheet, then the damage done by the second monster's attack is replaced with the damages from the first monster (the shadow demon's 2d6+3 becomes 1d6-1, and its 4d6+3 becomes 1d6-8). The attached images are what is displayed when the homebrew NPC is selected, when the shadow demon is selected without closing ('X') the NPC, and when the shadow demon is selected when you do close ('X') the NPC first. Finally, a short output from the browser console after the NPC and shadow demon were selected (w/o closing the NPC). beyond20_bug1 beyond20_bug2 beyond20_bug3 beyond20_bug4

The problem also occurs using a non-homebrew drow mage with the shadow demon.

Browser:

jtbg commented 2 months ago

Confirmed as reproducible. It's not consistent, though. I'll try to figure out what specifically about the monsters/encounters triggers it

https://github.com/kakaroto/Beyond20/assets/10716475/3ef12b8d-fd30-4cb3-b319-f45914873cc0

jtbg commented 2 months ago

looks like this occurs whenever you switch

kakaroto commented 2 months ago

Hi, Unfortunately, that's not a Beyond20 bug, but a DDB bug. When you switch tabs, it doesn't remove the statblock and put the new statblock in.. it looks like (likely for optimization reasons), it instead replaces the stats in the statblock and removes/edits the action texts, so as soon as Beyond20 modifies it (by adding the roll button), the ddb code can't find the blocks to edit and leaves them unmodified. You also get the issue between some other monsters where you'd get an action/attack from one monster remaining in the statblock of another monster which doesn't have that attack at all. One use case I found last week is if you have a Ghoul and a Beholder in the same encounter, the "random" digital dice button to roll for the beholder eye rays will change from a 1d4 or whatever, into a 1d20 + 5 when you switch from the ghoul to the beholder. I think the only solution for this might be that if we detect the statblock changed, we force the complete removal of the statblock and re-creation of it (by emulating clicking twice on the monster name to hide/show the statblock). I'll need to test how we could achieve that and if it would work. Ideally, DDB would fix the bug from their side.

jtbg commented 2 months ago

The fact that it only occurs with negative damage modifiers is what has me curious. Possibly a regex that is looking for \u002d but some statblocks send \u2212 (or vice versa)?

kakaroto commented 2 months ago

The fact that it only occurs with negative damage modifiers is what has me curious. Possibly a regex that is looking for \u002d but some statblocks send \u2212 (or vice versa)?

yeah, that's weird, I never noticed something that triggers that bug, unless maybe two statblocks are similar enough that DDB modifies the html instead of replacing it. To investigate!