Help me design simple networking for turn-based game

Hi,



I am in the process of making an adaptation of a monopoly-like board game in which players switch turns.



Each player first rolls the dice, moves his token and then can do a number of actions (or nothing).



I read the basic tutorial for SpiderMonkey, but it doesn’t really say how to distribute the game between the server and client.



What I think would be a good idea:



Client

  • Takes care of rendering and displaying the game

  • Recieves input from the player

  • Sends actions to server

  • Let's the server know when the player is finished


Server
  • Keeps the list of all clients

  • Keeps status of each player (money, position on the board)

  • Receives actions from clients and performs them

  • Lets clients know when is their turn


Do you think this could work? I also want to make sure, that you can add players who can play on one computer and make it compatible with players over the net. For example 2 players on 1 computer and other 2 players on their own computers. Do you think this could be done?

Also the server should be the computer from which the player creates the game, right? I think it would be better if it didn't require any other action (such as running another app) so it could be done from the same application.

Any suggestions?
Do you think this could work?


this is how most of such servers work... so why not.

I also want to make sure, that you can add players who can play on one computer and make it compatible with players over the net. For example 2 players on 1 computer and other 2 players on their own computers. Do you think this could be done?


it can, you just need to make it possible to play 2 players on 1 computer...

Also the server should be the computer from which the player creates the game, right?


should be, but don't need to be. There are many ways.

I think it would be better if it didn’t require any other action (such as running another app) so it could be done from the same application.


if you don't want to run dedicated Server, then you make it like you said:
Run server on Player(which want to host) Application. Others join.

There are a number of things you need to think about like how much you are worried about cheating/hacks etc - but the general concept sounds fine.

@zarch said:
There are a number of things you need to think about like how much you are worried about cheating/hacks etc - but the general concept sounds fine.


My approach to this particular subject is, ensure that they are possible, write the tool for exploiting them, make it available on certain servers... track exploit usage on servers that don't allow it. This way, people who enjoy playing in this fashion have the choice to do so... and a place to do it, separate from people who do not.

It's not hard to narrow down exploits considering the type of game you are developing... in my case, an MMO. The exploits never change... and if you try to take the... "I'll ensure this will never happen in my game" approach, you're bound to find out exactly how wrong you are a week after you launch. :)

Well, there is stuff you can do. Never send data to the client unless its visible to the player - wipes out map hacks - etc.

Thanks for the suggestions.



I am not worried about hacks or cheats because I can hardly imagine anyone cheating in a board game :slight_smile:



Do you have any links where I could start learning about networking in JME or is the one page tutorial the only thing there is?

@vojta-polivka said:
Thanks for the suggestions.

I am not worried about hacks or cheats because I can hardly imagine anyone cheating in a board game :)

Do you have any links where I could start learning about networking in JME or is the one page tutorial the only thing there is?


Look at the TestChatClient and TestChatServer... especially in a turn based game, as an example it should have everything you need.