2
\$\begingroup\$

I'm making my first online board game. After the two players accept to play with each other, I want to show a get ready message for 3 seconds, then both start playing together, each has 30 seconds to do an action in his turn.

But I don't know the process.

  • Should I pass to clients the time the game will start?
  • Should I check from server whether a player's 30 seconds is over? There may be a slight difference in server and client time, and I end a game from server while client still has 27 seconds for example.

What are the steps to have an accurate multiplayer game. Thanks.

\$\endgroup\$
  • \$\begingroup\$ Is it possible to end their turn before time runs out? Or does every player need to wait for it? \$\endgroup\$ – PSquall Oct 2 '17 at 8:22
  • \$\begingroup\$ @PSquall No need to wait the time run out, if the player do his action, it will be the other one's turn immediately. game is 9 men's morris . \$\endgroup\$ – Blendester Oct 2 '17 at 9:25
3
\$\begingroup\$

The most common and secure way to manage countdown synchronization in a multiplayer game is to make server the authoritative timekeeper. The clients then may request the remaining turn time every 1-5 seconds (arbitrary), which the server will pass down, and interpolate the received amount of seconds based on the ping time. That way, if it took 90 ms to process the request, then the final remaining time for the player to conduct his turn will be ReceivedAmount + 90 ms. It is not going to be the perfect synchronization, naturally, but it comes pretty close to it.

Since your server handles the time operations, you can be pretty sure that the clients won't be able to change the turn time and gain an advantage. It could be done from the server side, however, depending on the way you implement the feature. Considering the interpolation, you shouldn't run into ping-related desynchronization either.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.