boardgameio / boardgame.io

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

Proposal for restructuring game creation and lobby. #377

Closed lunedis closed 5 years ago

lunedis commented 5 years ago

I have a question / proposal regarding the game creation API endpoints as well as the generic lobby. The way I see it right now, the actual boardgame.io game instance gets created when you call /create endpoint, then both players join in separately, at which point they maybe could already play even if there is no other player? (as seen from server).

The "play" button in the lobby is only client side and doesn't actually talk to the server. (https://github.com/nicolodavis/boardgame.io/blob/master/src/lobby/react.js#L169)

In my use case, I'd like the players to have the option to chose something (e.g. a faction, compare to black/white in chess) before entering a lobby. I'd rather not implement it as "starting moves", as it is (in my opinion) not actually part of the game.

Currently you can only give a game some "setupData" when creating it. My proposal would still support that, but also the option for each player to specify some "userData" when joining a game.

The game instance would then be created in a seperate /start call, considering the already saved userData (same place as player metadata like name and credentials).

Discussion point: who is "allowed" to call /start? Every Player? Alternative: gets created when room is full.

I think as long as people only used a custom lobby renderer, and not implemented the whole lobby towards the endpoints themselves, this could also be implemented fully backwards-compatible, by making all userData things optional.

If this feature is something that seems desirable, I'd start working on it and submit a pull request. I wanted to get some feedback first though.

vdfdev commented 5 years ago

+1, lobby needs to be more flexible. I also think we should decouple the game itself from the lobby, as we might have the concept of "party"... We have multiple games in FreeBoardGame.org and we want people to easily play another different type of game after one match is done with the same group of people.

vdfdev commented 5 years ago

I think we are hearing a lot of different requirements, and I think if we just hack something together, don't give a step back and design the API, this wont solve most use cases.

I propose we create a document where we can share an API proposal, and then after everybody raises concerns, we pick the set of trade-offs we want.

The next big thing I want to fix in my project is the lobby, so I will have more time to it soon

nicolodavis commented 5 years ago

Starting a document sounds good to me! The lobby has grown somewhat organically and perhaps now is a good time to take a step back and determine a good feature set with various tradeoffs.

vdfdev commented 5 years ago

Hey folks, I started the document as I mentioned before: https://docs.google.com/document/d/1K0xDlyS_80WJic7GfNobl-SujfC8_LiB55-JJnAawNM/edit?usp=drivesdk

Still WIP, I will update with the design and let you know when it is ready for review

@nicolodavis, can we mark this issue duplicate of #354