3
\$\begingroup\$

I'm working on a project which allows players to take actions in time-limited turns. All players are connected to a central server, which is authoritative. That means the server sends info that a turn for given player has started and the time remaining to take an action. This leads to problems when client-side animations are involved. Each action has an associated animation, which takes some time to complete. The player should be able to initiate the action within given time, and the next player show start his turn when any animations complete. Obviously, the server has no notion of animations, but still needs to take them into account and start the next turn at proper time point. I'm not sure how to solve this problem. Possible solutions I came up with:

Constant animation time and built-in delay

The server will have a built-in delay after an action has been taken, before starting the next turn. Problems:

  • seems an artificial construct
  • animation times need to be exact

Not waiting for animations

The server can simply broadcast action effects without any delay, and go to the next turn. Problems:

  • will look very strange for the players since the effects will become visible before the animation completes
  • possible overlapping animations across turns

Sending actions along with animation times

The client can send the animation time for given action, which the server will use as a delay for the next turn. Problems:

  • obvious cheating possibility (players can use the delay for "extra time")

So, given above, all my ideas are simply bad. Therefore the question remains: is there an existing solution for such class of problems?

\$\endgroup\$
0
\$\begingroup\$

Solution 1 et 2 seems legit to me ! It goes like this :

  1. Player A choose an action / animation starts on his client.
  2. Server receive the information and send it to Player B.
  3. Player B receive the information and animation starts on his client.

Even if you don't know the length of your animations, which you should, just wait for the animations to be over client side to know when the turn is over.

Hope this help !

\$\endgroup\$
  • \$\begingroup\$ That requires the server to know about client animations. Maybe it is a good way to proceed, but mixing those two concerns seems a bit strange. \$\endgroup\$ – krojew Jan 18 '18 at 5:57
  • \$\begingroup\$ Not even, when server receive action from player A, he knows that after the animation, player A turn will be over. So he can tell player B that player A has done an action. Then when player B receive the information, server is done. The player B client launch the animation. And when animation is done, both clients knows that turn is over. \$\endgroup\$ – Sebastien Servouze Jan 18 '18 at 16:11
  • \$\begingroup\$ Yes, but still is makes the server aware of client side animations, which doesn't feel right, yet might be the only option. I was hoping there's a way to keep the server client -agnostic. \$\endgroup\$ – krojew Jan 18 '18 at 16:24
  • \$\begingroup\$ Hmm, in this scenario, server is not aware of animations. It just tell states to the clients. And those clients knows what to do in those states. \$\endgroup\$ – Sebastien Servouze Jan 18 '18 at 16:47
  • \$\begingroup\$ The turn ends when an action is taken, but the client sends the action when the animation is done. Which means the timeout must be paused when the animation is playing, otherwise the player might taken an action and see the animation, but there will be no effect, because his time ran out. \$\endgroup\$ – krojew Jan 18 '18 at 17:49

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.