epic-power-rpg / roll20

Apache License 2.0
0 stars 0 forks source link

If a character has no Defend skill, their Block ability is coming up as Nan. #78

Closed johnlamping closed 1 year ago

johnlamping commented 1 year ago

The code used to give the default ability of DX - 3 - 5 (With any Defense discipline added in).

jazeee commented 1 year ago

I believe this issue is resolved now (or at least, I can't replicate the issue.) Can you screen shot an example if you see it?

johnlamping commented 1 year ago

I just reproduced it.

I created a new character, and their Dodge showed as Nan. I gave them an irrelevant skill, and Dodge was still Nan I then quit, and re-launched the game, and then they showed -7, like they should for having no training.

Maybe there is some sort of race between initializing something the Dodge computation needs and when it is run the very first time.

jazeee commented 1 year ago

Testing now. I suspect that we need to add one more event listener related to create character.

jazeee commented 1 year ago

Ahh, I see. This does appear to be a bit of an order of operations topic, and possibly a race condition. The updateCopiedAbilities function updates defend, but not on sheet:opened, whereas updateArmorValue does. I can easily fix the NaN issue, but am also looking at how to address the order of operations/race condition.

jazeee commented 1 year ago

https://wiki.roll20.net/Sheet_Worker_Scripts#setAttrs.28values.2Coptions.2Ccallback.29

When setAttrs is called, I believe it doesn't trigger change listeners. (Probably to protect from circular or infinite loops). setAttrs does have a callback function, and I can use that to fix the issue. Testing now...

jazeee commented 1 year ago

Also, I was slightly wrong above - both functions have sheet:opened. One was just buried.

jazeee commented 1 year ago

Fixed in #85