based coop game that will need to communicate to the server to handle the game process. Basically I need to be able to invite to the game, progress through turns (one player at a time) and finish in win or loss. Also players could drop off from the game and the game should continue. Is there a known basic schema for this or a set of standards?

  • \$\begingroup\$ This is a rather broad question. Is there something you've tried that has failed? Is there some part of this you're having particular trouble with? \$\endgroup\$
    – Anko
    Oct 28 '15 at 12:05
  • \$\begingroup\$ In my initial design I was only using server to relay the messages between clients, but then I thought it has a potential for cheating. I also would like the game to be auto-saved on every event if possible. Is there any trick that would ensure to certain degree that cheaters will have hard time? \$\endgroup\$
    – serge
    Oct 28 '15 at 13:15

Generally I would say "No, there is no schema for this and no set of standards". This is because this purely is based on the needs of the specific game (which data is sent) and the used protocols (how the data is sent).

You can use this via plain UDP/TCP packages and write your own protocol using binary data transmission, you can use HTTP/S and send your data wrapped as XML or json. This depends on your specific needs and your existing server implementation. Altough a HTTP/S fallback will be very usefull once you game should be played on public wifis or something compareable (Admins can block unknown protocols).

Based on your short description I will try to give a small schema for this.

Lets assume the server is always/already running somewhere and waits for clients to connect. Once they connect they go into the lobby. There you can handle invites, messaging, player matching or whatever you need to "invite to the game".

Once you have your players together you can start a game session with them. In many online games this will be the part where you click play and see the "joining game" message. The session will be controlled by the server. He knows the state of every player and the total game state. For a round based game some rough state machine concept will save you a lot of troubles. This does not mean you have to implement a complete state machine framework (switch, if) should be enough for the beginning.

Clients also have such a state machine where transitions are controlled by the server. Clients start in state idle until the server knows everybody joined is ready. Then the server sends "a player X your turn" message and the client X knows he is allowed to accept game relevant input. The client waits for user action. Once the player has made his turn the client sends the action to the server which distributes them amoung the other players. The client also blocks input for the player to prevent further actions. The server receives the actions of the player and sends the client "a your turn is over message" and sends the next player "a player X your turn" message. And so on and so on.

Feel free to leave comments on which part I should go into detail. :-)

  • \$\begingroup\$ I there any way to prevent users from cheating? (for example going out of their turns or sending fake actions to the server) \$\endgroup\$
    – serge
    Oct 28 '15 at 13:20
  • 1
    \$\begingroup\$ If all the relevant logic is done and evaluated by the server cheating would only be possible when the cheater has access to (hacking) your server directly. Example: the player manages to send a "do action X" request to the server although it is not the players turn the server can decide to ignore this message/action because the server state machine knows this is an illegal action. Rule of thumb: all relevant logic is done and evaluated by the server. The clients only display the current state and changes delivered by the server. \$\endgroup\$
    – monty
    Oct 28 '15 at 13:24
  • \$\begingroup\$ I guess I need to put more logic on the server. I'll accept the answer because I understand there is no standard other then "relevant logic is done and evaluated by the server". I was hoping that there is some kind of generic schema out there(I see that I need to do my own design) \$\endgroup\$
    – serge
    Oct 28 '15 at 13:41
  • \$\begingroup\$ If we find a private communication channel and if you want to I may can assist in more detail if you have further questions or need help to design a protocol and game server logic. \$\endgroup\$
    – monty
    Oct 28 '15 at 13:44
  • \$\begingroup\$ I forgot one thing to mention when it comes to prevent players from cheating. Make sure that the clients only have data they should have. Imagine a card game where the player sees his cards uncovered and the cards of the other players covered. If the information which cards are covered is in the memory a plugin could uncover the cards. Only the server should now all cards. \$\endgroup\$
    – monty
    Oct 29 '15 at 14:02

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.