boardgameio / boardgame.io

State Management and Multiplayer Networking for Turn-Based Games
https://boardgame.io
MIT License
10k stars 704 forks source link

SocketIO Server based game for solo player games #692

Open ugobrunet opened 4 years ago

ugobrunet commented 4 years ago

I am working on a Socket Server based game that can be played by many players or by a solo player (it's a collaborative ordering card game). Based on src/lobby/react.js line 185, Socket Server only work for at least 2 players games. So when someone create a 1 player room, the state of the game is not store remotely.

Also the behaviour of solo Local game seems to be buggy on my project because the UI receive a 2 player game despite the fact that this game was created with numPlayers = 1. I'll try to dig in this issue to give you more insight. Thanks

ugobrunet commented 4 years ago

Update: I find it weird that the ClientFactory constructor on line 202 of src/lobby/react.js is called without a numPlayers value. Maybe I misunderstood something

cynnfx commented 4 years ago

Hey I have the similar issue i want to create a 2+ player game (server socket.io) but the client's (react-native) ctx.numPlayers keep always 2 despite the numPlayers configuration at Client call

I managed to force it in dist/boardgame.io.js in Flow return line 1897.

I can misunderstood something too, I am using the proper way ?

ugobrunet commented 4 years ago

Not exactly the same for me. Mine is a 1+ player game. It's working fine with 2+ player, but 1 player always end up in a 2 player game (played locally I guess). Any idea?

cynnfx commented 4 years ago

Ok didn't try with 1 player cause my game isn't designed for it, I've opened an issue for my answer,