I'm wondering how a system can be made compatible with networking operations (client-server). By saying "networking operations" I mean a system that can handle online operations, multiple user interactions and client-server processes. For example, in programming term, lets imagine we created a Board class for our awesome board game and this game is played with multiple players but we don't know how to make this game online (This Board class to be online for multiple users) since we don't know how to convert our board game to online, we decided to make the board game be able to convertible to online board game. For example, you made this game and posted to github.com and someone found your game very interesting and said "I want to make this online with a game library or engine". In that case, the first (positive, good) scenario is that the person that wants to make this game online will say "Yeah this game's codes can be converted to online so I can do it" and the second (negative, bad) scenario is that the person will say "This game is quite nice but the codes are as terrible as that cannot be converted to online" So if we want first scenario to happen, we have to make the codes convertible to online. But I don't know what the requirements are and how to achieve this. But I have a theory.

My theory: the board class that represents whole game must be convertible to JSON to transfer the board from server to client or from client to server. So the board that is in client can easily be synchronized with server's board by JSON data transferring. So my board class must represent methods like named "getBoardAsJSON(), toJSON()" so the JSON data that is obtained from the board can be carried to client and to server.

My questions are:

  • What fundamentals, features are needed for my board game to be able to converted to online?

  • Is JSON convertible feature enough for my board game to be online?

  • 2
    \$\begingroup\$ Depends on how you coded your game. It can be as little with adding a few annotions and renaming the functions to work (Mirror makes it quite easy for such things) or a lot more work if you want to write the whole network code yourself. Is your game already seperated in logical parts or is it a single class that handles everything? Can your game as well support multiple players already or was it written for a single player and never considered any extra player (neither computer or otherwise). We can't answer your question with what we got so far without guessing. \$\endgroup\$
    – Zibelas
    Mar 15 '21 at 18:22
  • \$\begingroup\$ @Zibelas My game is divided a a bunch of classes but the main class is Board By using only Board and a few more classes (Player, Piece, Cell, etc...) you can play my game (multiplayer game). Do you know what json cannot do? And last thing: You can think my game as a game of chess because my game is a variant of chess. \$\endgroup\$ Mar 15 '21 at 19:10
  • 1
    \$\begingroup\$ JSON is just a format. It can't tell you if the person who is sending the request is allowed to do so for example. \$\endgroup\$
    – Zibelas
    Mar 15 '21 at 19:15
  • \$\begingroup\$ In order to understand the answer to this question, you would have to understand how online games are written, and if you understand how online games are written, you already know the answer. \$\endgroup\$
    – user253751
    Mar 16 '21 at 10:08
  • \$\begingroup\$ It is like asking "What fundamental features are needed for my game so that players can change the colour of their characters?" Well almost any game can have this feature, but how easy it is, depends on your game code. But it's not like there's a very simple cause-and-effect where we can say "do this and your colours will be changeable" \$\endgroup\$
    – user253751
    Mar 16 '21 at 10:11

First, what is your exact client-server model. Do you have a dedicated server or is one player acting as a host? In case you plan to go with a dedicated server, you could try to simulate it locally without any network code.

  • Make a server class/ container that contains your board and all the logic operations.
  • Have each player in your local game a copy of the board state.
  • You are not allowed to use your game board state from the server at any point directly from your player class. You can ask for a board state from server (in your json format if you want to test your serialization).
  • You are not allowed to update your server board state from the player. The only valid update is from a logic call inside the server. So even if your player made the move locally (he can have a duplication of server logic to assist what is a valid move or for rendering purposed), the server state can only be changed by instructions from client but not directly ("I want to move piece X to place Y" and the server is doing the move).
  • Checking for robustness, you could delete and recreate a player at runtime (similar to a disconnect). Is he getting the correct state again? What happens when a player tries to move a piece he does not own? When you try to move out of turn? Or when one player is not moving at all (is the next player getting a turn or does your game wait forever)

You did not state if you are using any engine or want to create everything on your own. You might want to consider a networking library that is taking care of most points by default and of the other things I could not think of yet.

  • \$\begingroup\$ How can I make a server class, if I don't know networking? \$\endgroup\$ Mar 16 '21 at 9:14
  • \$\begingroup\$ @1JustOnly1 You are not really making a working server, you just seperate the code you have done already. There won't be any networking in the first step but you can simulate it this way. \$\endgroup\$
    – Zibelas
    Mar 16 '21 at 9:34
  • \$\begingroup\$ Maybe, I should reask this question with source codes when I finish the project. \$\endgroup\$ Mar 16 '21 at 10:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .