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

Implement revert, use array for _prevActivePlayers & remove activePlayersDone #449

Merged
merged 2 commits into from
Sep 4, 2019
Merged

Implement revert, use array for _prevActivePlayers & remove activePlayersDone #449

merged 2 commits into from
Sep 4, 2019

Conversation

delucis
Copy link
Member

@delucis delucis commented Sep 3, 2019

Contributes towards #445

  • Move reset behaviour behind a revert flag in setActivePlayers
  • Convert _prevActivePlayers to an array, which stores a stack of active player values
  • Remove activePlayersDone from ctx

Contributes towards #445.

`_prevActivePlayers` is now always an array, which will be empty unless 
`setActivePlayers` (or `turn.activePlayers`) is passed `{ revert: true 
}` at which point the previous state will be stored. If `activePlayers` 
becomes empty and there is something saved in `_prevActivePlayers`, the 
last item will be used to restore `activePlayers`.
activePlayers = state.ctx._prevActivePlayers[lastIndex];
_prevActivePlayers = state.ctx._prevActivePlayers.slice(0, lastIndex);
} else {
activePlayers = null;
_activePlayersOnce = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also be storing this on the stack, no?

You can have a series of setActivePlayer events that have different once: true options, and we should restore to the correct option at each revert step.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't once going away in favour of moveLimit in stages?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's true. Ok, feel free to leave this as is then.

@nicolodavis nicolodavis merged commit 6ecfd1f into boardgameio:phases-overhaul Sep 4, 2019
@delucis delucis deleted the delucis/active-players-flow branch September 4, 2019 07:52
nicolodavis pushed a commit that referenced this pull request Sep 10, 2019
…yersDone (#449)

* feat: Implement `revert` flag and use array for `_prevActivePlayers`

Contributes towards #445.

`_prevActivePlayers` is now always an array, which will be empty unless 
`setActivePlayers` (or `turn.activePlayers`) is passed `{ revert: true 
}` at which point the previous state will be stored. If `activePlayers` 
becomes empty and there is something saved in `_prevActivePlayers`, the 
last item will be used to restore `activePlayers`.

* feat: Remove `activePlayersDone`
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.

None yet

2 participants