I am newbie in game development, I want to create a multiplayer game server with node.js I want to know, what is the most common techniques and patterns to keep and change game state on the server
My game state size has little size, So I think the best place is memory to store it
I want to scale up and out my server game, so each player can connect to different server
I am worry about simultaneous events that change state of game in different servers, So having single source of truth is somehow complex, because potentially the state on each server can be get out of sync
In nutshell, What is the common approach to build a multiplayer turn based games that server has to implement some logic to control game flow such as changing turn, changing state of game in case in inactivity of the player, ...
I also don't know how to protect state against restating server, May be a redis can save the state, But how to control the game flow after losing the controller
Firstly, I think it's bettert to start from a little model with central server, the thing about "change state of game in different servers" may not fit your game, even if it's fit, you can do it after the simple try. The first important thing is to make the game run as you wish and as simple as possible.
Then we foucs on the how to build a multiplayer turn based game. For such a game, you need at least several things like below
After that, here is the central logic of server. We need at least following functions:
And that is the simplist model of a central controller, you can change it to other ways as long as they can work. After that, you can make it more and more complicated to realised your game.