Some issues come out of nowhere
May. 5th, 2021 05:34 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Almost had a working turn, but then ran into this major bug:
Each Toon (Heroes and Armies) gets their own dice pool at creation. Once created these are put into the archive for the rest of the game to access.
Then I saw during turn processing that the battling Toons were rolling the same value every time. Very strange.
After some exploring around the Toon dice pools I realized that serialization/deserialization of the archive process was resulting in all Toons having the same dice pool.
The fix was to save the serialized binary state of the dice pool in the Toon. When the game accesses their dice pool, the state reconstitutes the Random object, provides the next die roll in the series, then serializes that new state instead of keeping the Random object.
Now each Toon is rolling its own dice.
Onward to reporting turn results to the player!
//$$$$$ todo: How to Save/Restore Rnd objects in toons???
Each Toon (Heroes and Armies) gets their own dice pool at creation. Once created these are put into the archive for the rest of the game to access.
Then I saw during turn processing that the battling Toons were rolling the same value every time. Very strange.
After some exploring around the Toon dice pools I realized that serialization/deserialization of the archive process was resulting in all Toons having the same dice pool.
The fix was to save the serialized binary state of the dice pool in the Toon. When the game accesses their dice pool, the state reconstitutes the Random object, provides the next die roll in the series, then serializes that new state instead of keeping the Random object.
Now each Toon is rolling its own dice.
Onward to reporting turn results to the player!