Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace player with currentPlayer option in setActivePlayers #523

Merged
merged 4 commits into from
Nov 27, 2019
Merged

Replace player with currentPlayer option in setActivePlayers #523

merged 4 commits into from
Nov 27, 2019

Conversation

delucis
Copy link
Member

@delucis delucis commented Nov 27, 2019

Supersedes #514, related to #487.

In order to clarify who is being impacted by setActivePlayers calls — especially in hooks — this changes the syntax to require a currentPlayer option instead of a player option:

Breaking Changes

Anyone currently using the setActivePlayers event or the turn.activePlayers option in their game config, who is using a player option may see breaking changes.

Migrating will take one of two forms:

  1. Switching to using currentPlayer

    For turn.activePlayers or setActivePlayers calls where player was always the current player in any case, users will only have to rename the option:

    activePlayers: {
    - player: 'A',
    + currentPlayer: 'A'
    }
  2. Maintaining player behaviour

    For setActivePlayers calls where the behaviour impacted the player who triggered the move/event specifically, users will need to switch to using the value option, for example:

    ctx.events.setActivePlayers:({
    - player: 'A',
    + value: { [ctx.playerID]: 'A' }
    })

Further considerations

setStage and endStage still rely on playerID, which is unavoidable. These should probably be disabled in onBegin and onEnd hooks for clarity’s sake.

Instead of using a `player` argument inside `setActivePlayers`, use `currentPlayer`. This makes
`setActivePlayers` more predictable when used across hooks etc.

BREAKING CHANGE: Anyone who is using a `player` argument inside `setActivePlayers` will need to
adapt their usage to either `currentPlayer`, or if they require the `player` behaviour, replace
`player: 'stage'` with `value: { [ctx.playerID]: 'stage' }`.
@nicolodavis nicolodavis merged commit cae05fd into boardgameio:master Nov 27, 2019
@delucis delucis deleted the delucis/current-player-in-active-players branch November 27, 2019 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants