-
My game has an end-of-round phase that applies to only a subset of players. That means I need to set a new phase and the next player at the same time. I tried to do that with:
It appears that "1" gets set as the current player, then that player's turn ends when setPhase ends the phase. I also tried setting the current player with endTurn inside of onBegin in the new phase. That didn't have any effect that I could see. The workaround I discovered was this:
That's more than a little bit of a hack and will break if any of the above behavior changes. Much better would be for endPhase/setPhase to take an optional player ID and sets that player as current when the phase starts. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Currently the best way to do this is using the phase’s Docs: https://boardgame.io/documentation/#/turn-order?id=creating-a-custom-turn-order |
Beta Was this translation helpful? Give feedback.
Currently the best way to do this is using the phase’s
turn.order.first
method. If the heuristic of who starts the end-of-round phase is predictable, you can have all the logic there and be guaranteed that entering the phase always results in the correct starting player. If it’s essential to set the player from the same place as thesetPhase
event, you can store the starting player temporarily inG
and then read that in yourfirst
method. (As a side note, if only some players are in this end of round phase, you may also wish to useturn.order.playOrder
to only include those. Then your actual move logic can be as simple asendTurn
with no need fornext
or other logic.)Docs: https://boardg…