jkomoros / boardgame

An in-progress framework in golang to easily build boardgame Progressive Web Apps
Apache License 2.0
31 stars 4 forks source link

Some way to allow reordering players #758

Open jkomoros opened 4 years ago

jkomoros commented 4 years ago

Related to #752 .

Right now the order of players is always set. But in different rounds, you want a different order for players, and you might want to swap it based on roles, etc.

This can get really complex if you allow the order to change lots of thing.

The best way to do it is likely just have a GameDelegate.CustomPlayerOrder() []PlayerIndex .

That must return either nil (default) or each player index from 0 to len(players) -1, in whatever order it wants. The only effect it has is that PlayerIndex.Next() and Prev() will have their order changed. Now those will look up the current player's index in that, then increment the index within THAT and see which player that means is now active.

And you can imagine a behavior for GameState that you can embed that has the player Index slice and that GameDelegate's CustomPlayerOrder uses if it exists.

Ideally this player order and grouping would show up in the player roster rendering. That's probably better handled in e.g. #749

jkomoros commented 4 years ago

Another (complementary?) option is to have GameDelegate have ReversePlayerOrder(state ImmutableState) bool (originally captured in #755)