boardgameio / boardgame.io

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

How to achieve another game #643

Closed peacetrue closed 4 years ago

peacetrue commented 4 years ago

After the player has played a game, They want another game, Any good suggestions from boardgame.io?

delucis commented 4 years ago

@peacetrue Do you mean like a “Play Again” feature? If you’re using the Lobby API, you could either use the create and join endpoints to create a new game or use the playAgain endpoint.

If you’re not using a server, you can use the reset method of the client to reset the game to the beginning state and let the player play again.

peacetrue commented 4 years ago

@delucis I will try the the playAgain endpoint. , It doesn't seem to be updated in the document. use the create and join endpoints equivalent to restarting a new game, the experience is not very good. When the game is over, player 1 clicks to play again, player 2 receive the ask, start immediately when player 2 agrees.

delucis commented 4 years ago

@peacetrue Yes, create + join wouldn’t work so well for that use case but I think the playAgain endpoint might.

@flamecoals Are you still using the playAgain API? Would you be open to updating the documentation to include it?

peacetrue commented 4 years ago

@flamecoals When my test is complete, I will update the document. In addition to the interface documentation, Lobby's example also needs to be updated synchronously.

vdfdev commented 4 years ago

Hey, yes, we still use it. I will send a PR soon with documentation

On Sat, Apr 25, 2020, 1:55 PM 安宁 notifications@github.com wrote:

@flamecoals https://github.com/flamecoals When my test is complete, I will update the document. In addition to the interface documentation, Lobby's example also needs to be updated synchronously.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nicolodavis/boardgame.io/issues/643#issuecomment-619439512, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH4TB4OSBBU32CPWKWPMW3RONE4ZANCNFSM4MO4SLWQ .

peacetrue commented 4 years ago

@delucis I made some attempts. First of all, the playAgain interface is used, it looks not much different from the create interface, but nextRoomId is useful. After calling the playAgain interface, I want to see if the other player can receive the notification, but the result is no. Finally, try to poll on the client, by determining whether GameMetadata contains nextRoomId, but the result is no.

I read the interface of GameMetadata:


export interface GameMetadata {
    gameName: string;
    players: { [id: number]: PlayerMetadata };
    setupData: any;
    nextRoomID?: string;
  }
`` `
It seems that the current version has not been implemented.

Or my understanding is wrong, can you give me some suggestions?

PS:I refer to Lobby's implementation, but Lobby's style is too simple, I rewrote Lobby.
I think that the client interface of the lobby can be provided separately
delucis commented 4 years ago

@peacetrue Check out the documentation @flamecoals just added. You should get the nextRoomId as the response to a request to playAgain.

And you’re correct that this isn’t supported by the provided React Lobby component.

delucis commented 4 years ago

Going to close this now we have documentation. Let me know if you have any further questions.