1
\$\begingroup\$

I'm currently developing a pool-like browser game. I'm stuck on where should I handle the turn changing, timer, etc.

Currently, turn timer (i.e. 15 seconds left to do action, then turn will change) is handled by the server. But the changing of turns itself is handled by the client (the browser itself).

Now in my current setup, whenever a player leaves window focus, the game gets out of sync. Should I migrate the turn change handling to the server instead?

\$\endgroup\$
2
\$\begingroup\$

The general rule of thumb for handling multiplayer games is that any game mechanics which can be handled on the server should be handled on the server. There are two reasons for that:

  1. The less the client is responsible for, the easier it is to develop a new client for a different platform
  2. It makes it a lot harder to cheat

The server should be the one who decides what state the game is currently in and reject any commands which aren't valid in the current state.

| improve this answer | |
\$\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.