chain-reaction icon indicating copy to clipboard operation
chain-reaction copied to clipboard

Online multiplayer support

Open PlytonRexus opened this issue 3 years ago • 5 comments

Using socket.io and node.js, it would be possible to create an online multiplayer version of this game. I agree this might make things unnecessarily complicated for the beauty of chain reaction is in its simplicity. But consider the improved utility. I had difficulty in sharing my mouse while playing. Might others have had similar problems?

If not over the internet, then a local setup can be created to play over LAN.

PlytonRexus avatar Aug 12 '20 13:08 PlytonRexus

So what could be the plan? MySQL, simple APIs and FCM + background jobs to clean up abandoned games? @PlytonRexus

geetp98 avatar Oct 04 '20 15:10 geetp98

So what could be the plan? MySQL, simple APIs and FCM + background jobs to clean up abandoned games?

@geetp98 Let me just confirm this FCM is Firebase Cloud Messaging? I guess that's a fair model. Like I mentioned in the OP, a more barebones approach could be using sockets with/without a database. By the way, I recently created a version.

But your approach could be cleaner!

PlytonRexus avatar Oct 05 '20 14:10 PlytonRexus

Yes, FCM = firebase cloud messaging. With a sockets model, we could run into trouble of one of the players disconnecting and need of creating a robust model to handle that. With fcm, it should be easy considering if a message is not sent successfully, the player has disconnected. We can let all the players know, and the game can continue. Although as of now, I haven't dived into game logic properly, but we would potentially need a nosql to store the game state as well.

geetp98 avatar Oct 05 '20 15:10 geetp98

@geetp98 I guess that's true about disconnecting. However, even FCM, uses a socket-based model. That is, if instead of socket IDs, we use Usernames/UIDs to track players, recreating a game state for that username should be easy enough.

For storing a game state, yes, we will need a database. I was thinking we could just make a simple map and store states corresponding to rooms in it. Of course, this will erase data once the server is turned off and will, I guess, keep a child process running indefinitely. The database solution is more elegant.

May I ask, are you making a version?

PlytonRexus avatar Oct 07 '20 12:10 PlytonRexus

@geetp98 Oh, I didn't see a game state sort of thing in this version of Chain Reaction. So, making a multiplayer version is slightly difficult with this one.

PlytonRexus avatar Oct 07 '20 12:10 PlytonRexus