boardgameio / boardgame.io

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

All active players should be able to call events #464

Closed delucis closed 4 years ago

delucis commented 4 years ago

As discussed in #458, now that active players and stages allow more complex multiplayer play within turns, it makes sense for any active player to be able to call an event (the stage-related events in particular) and not just the current player.

There are two parts:

I’d offer to tackle this, but I felt a little out of my depth reading the event and reducer logic, so it might be safer for someone who already understands how those work to make these changes.

nicolodavis commented 4 years ago

We'd also need to change setActivePlayers to operate on the player that called the event (playerID) rather that currentPlayer.

nicolodavis commented 4 years ago

After working on the documentation, I find that it's a bit confusing to have both setStage and setActivePlayers. I think we should merge the functionality of setActivePlayers into setStage.

EDIT: Implemented in https://github.com/nicolodavis/boardgame.io/commit/f3022716cfa5a51122a4a4d90b5a5c809e688748.

Open to ideas about how to make the arguments to the new setStage more intuitive. The semantics are currently:

  1. setStage('A'): take current player to stage.
  2. setStage({ stage: 'A', moveLimit: 2 }): same as the above, but also apply a moveLimit.
  3. everything else: delegate to setActivePlayers.

EDIT2: On second thought, I think this causes more confusion about semantics (setStage doesn't reset move counts but setActivePlayers does, and revert semantics only apply to setActivePlayers). I've reverted my change. Still open to merging the two into a single event, but we'd have to simplify them a bit and make sure that the semantics aren't confusing when implemented as one multi-purpose event.

nicolodavis commented 4 years ago

Looks like all the features discussed here are now done.