Multiplayer Game Architecture in node.js - Government Management & Synchronization with Redux

I am using an online TCG game (think Hearthstone / Magic) as a pet project and I decided to go to React / Redux for the client UI. This got me thinking about the possibility of using Redux on the server as well as maintaining global state for each client / game.

The way it works is that players in the game send events (via socket.io) to the server, which will be checked according to the game state + rules, which will then trigger a server state change and propagate this to the appropriate clients.

Thing is, I feel like I will have to jump over a lot of hoops to get all the game / logic rules to follow the more functional / immutable Redux approach instead of modeling all my game objects as classes.Also, since each player has limited information about them opponents (for example, you cannot see the hand of another player), I will have to have special logic to filter the state information depending on which player is receiving the data.

On the other hand, I like the idea of ​​sharing a centralized state for different handlers for each domain, predictable data flow, and the ability to roll back to previous states. Also, actions in Redux fit neatly into the command pattern, which is useful for such games.

Should I just implement a custom dispatcher similar to Redux but give up the immutability part? Is there a more "tried and true" approach for these situations?

+3


source to share





All Articles