boardgameio / boardgame.io

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

allow setting the next player (and phase) via endPhase #180

Closed sladwig closed 6 years ago

sladwig commented 6 years ago

analogous to this commit (allow setting the next player via endTurn), I would want to use similar API for setting the next player via endPhase. I think it could clean up my turnOrder code a bit, since I wouldn't have to save the result of the first phase in G, to check in turnOrderfunction whose turn it is.

Since with endPhase you can return the next phase, which is kind of cool by itself. Maybe being able to return an object like {nextPhase: 'next_phase', nextPlayer: 'next_player'} could be a solution? So either way endPhase or endTurn would be able to change nextPlayer and/or nextPhase.

nicolodavis commented 6 years ago

I like this in principle, but I think it would complicate the semantics and the implementation. For example:

I think it's cleaner for endPhase to only deal with phase related stuff and endTurn to deal with turn related stuff.

For your case, can't you use the Events API to change the player from the ctx object?

sladwig commented 6 years ago

have been trying to update boardgame.io (from v0.20.1), which somehow doesn't work as smooth as expected and trough that stumbled on the commit above and thought it would be nice for consistency... haven't thought about/tried the Events API, will try it and close for now.