I’m creating a turn-based, two-player game similar to checkers, using Cloud Code and Cloud Save to handle moves. At the end of each turn, players will receive push notifications with the current state of the game board. I’m now tasked with implementing a turn timer, such as 20 seconds per turn. What would be the best approach to achieve this?
Hey, to clarify, what happens when the player’s turn timer runs out? Will the turn be handed over to the other player? And will this handing over keep repeating if both players do not make a move? Or will the player lose the game?
Thank you for the quick response! The entire game lasts a set amount of time, 10 minutes. If a player doesn’t make a move in time, the turn simply passes to the other player.
I also plan to implement a “Finish Turn” button, which would allow the turn to end early and pass to the other player.
It’s important that the transition between turns is seamless. I mean, when the timer hits 00:00, the other player should immediately start their turn without any delay. I’d appreciate any ideas or suggestions on how to achieve this!
Did you ever find a solution to this that is not client authoritative? A potential cheater might never send the “EndTurn” or “Timeout” message and this will make the game hanging. I suppose the non-cheating client could poke the backend and force it to make a choice, which could be acceptable even if kinda smells. I think this is safe enough as the backend can check the last time a move was made and determine if is a valid “poke request” (as in, hey has the other guy disconnected/not played/cheating kind of thing).
This is probably fine for reconnections too as if the other person has disconnected instead will be possible to pick back up from where he left even if he skipped a turn.
Any better ideas?
I switched to Colyseus. I need a turn timer in the game and for the game state to sync instantly between clients. Coliseum is perfect for this. Cloud Code isn’t very suitable for this task. https://colyseus.io/
Hi!
I’d like to just mention that Colyseus is a server provider, as opposed to serverless. The equivalent offering for Unity is Multiplayer Hosting (docs) , not cloudcode which is serverless/ stateless.
Cheers