boardgameio / boardgame.io

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

Solitaire game with others watching over websockets? #57

Closed anton-107 closed 6 years ago

anton-107 commented 6 years ago

Hi, I'm designing a board game for single-player.

I was wondering if it's possible with boardgame.io to create a proper game with number of players to equal 1? (right now I'm automatically skipping a turn of other players)

I'm also interested if I can use boardgame.io 's multiplayer mechanism for other players to join watching the solitaire game in real-time?

nicolodavis commented 6 years ago

Yes, just set numPlayers to 1 and it should work. To have others spectate, use multiplayer: true when creating the client, set playedID = "0" on the client that is actually playing, and have other clients connect without a playerID.

There is an example to do just this in the repository. Have a look!

gk-patel commented 4 years ago

Are you sure that spectoator view is still allowed, considering,

https://github.com/nicolodavis/boardgame.io/blob/master/src/server/api.ts#L163

delucis commented 4 years ago

@gk-patel The /join endpoint is only for active players when they first join a game. Spectators should use the /games/:name/:id endpoint (source).