Dear fellow devs,
I come to you with a problem I am experiencing regarding private states.
I'll start by describing the states themselves:
3 => playersDraft, multiactiveplayer state with initialprivate pointing to 31. In it's action I setAllPlayersMultiactive and initializePrivateStateForAllActivePlayers
31 => spellChoice, first private state where players pick a spell to play
32 => spellDestinationChoice, where players choose what to do with picked spell
33 => waitingForOtherPlayersToPickSpell, where players wait patiently for others to finish
Action for "waitingForOtherPlayersToPickSpell" checks whether everyone finished their drafts. The last player to enter this state will trigger a transition outside the private states.
Then, after doing some computations, the game comes back to state "playersDraft" and the whole private process starts again.
Problem:
I am testing it with 2 players. The first player properly goes through the states and waits in "waitingForOtherPlayersToPickSpell" state. The second and last player goes through the states as well, upon entering "waitingForOtherPlayersToPickSpell" a transition is invoked, but then problem arises. While first player properly starts in state 31("spellChoice"), the second player is cycled through all the private states and ends up in "waitingForOtherPlayersToPickSpell". There is no automatic way to do this without clicking in the UI.
Funny enough, it only happens on frontend. I confirmed it in the DB, and both players properly end up in state 31 ("spellChoice"). It's just that on frontend I get all the "state left"/"state entered" messages and frontend is moved to the last state. When I refresh it, it starts working fine again until the next time.
What could be the reason for this? Some hanging click listeners on frontend get activated and moved the second player through the states? But then it wouldn't come back to 31 after refresh.
Maybe my idea of waiting for other players to finish in the last private state is wrong and it should be done differently? If so, how?
I went through the documentation pages for private states and state management in general. I found some ideas there, but they didn't work in the end.
Best regards and wish you good day (or night),
Tomasz
I come to you with a problem I am experiencing regarding private states.
I'll start by describing the states themselves:
3 => playersDraft, multiactiveplayer state with initialprivate pointing to 31. In it's action I setAllPlayersMultiactive and initializePrivateStateForAllActivePlayers
31 => spellChoice, first private state where players pick a spell to play
32 => spellDestinationChoice, where players choose what to do with picked spell
33 => waitingForOtherPlayersToPickSpell, where players wait patiently for others to finish
Action for "waitingForOtherPlayersToPickSpell" checks whether everyone finished their drafts. The last player to enter this state will trigger a transition outside the private states.
Then, after doing some computations, the game comes back to state "playersDraft" and the whole private process starts again.
Problem:
I am testing it with 2 players. The first player properly goes through the states and waits in "waitingForOtherPlayersToPickSpell" state. The second and last player goes through the states as well, upon entering "waitingForOtherPlayersToPickSpell" a transition is invoked, but then problem arises. While first player properly starts in state 31("spellChoice"), the second player is cycled through all the private states and ends up in "waitingForOtherPlayersToPickSpell". There is no automatic way to do this without clicking in the UI.
Funny enough, it only happens on frontend. I confirmed it in the DB, and both players properly end up in state 31 ("spellChoice"). It's just that on frontend I get all the "state left"/"state entered" messages and frontend is moved to the last state. When I refresh it, it starts working fine again until the next time.
What could be the reason for this? Some hanging click listeners on frontend get activated and moved the second player through the states? But then it wouldn't come back to 31 after refresh.
Maybe my idea of waiting for other players to finish in the last private state is wrong and it should be done differently? If so, how?
I went through the documentation pages for private states and state management in general. I found some ideas there, but they didn't work in the end.
Best regards and wish you good day (or night),
Tomasz