Skip to content

Commit

Permalink
docs: Document setting next phase with method as added in #972
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Aug 7, 2021
1 parent bfaf983 commit d8fc8f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/documentation/api/Game.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
start: true,

// Set the phase to enter when this phase ends.
// Can also be a function: (G, ctx) => 'nextPhaseName'
next: 'nextPhaseName',
},

Expand Down
15 changes: 10 additions & 5 deletions docs/documentation/phases.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,27 @@ phases: {
},
```

If you need to specify the next phase dynamically, you can return
an object containing a `next` field from your `endIf`:
!> Whenever a phase ends, the current player's turn is first ended automatically.


### Setting the next phase dynamically

Instead of setting a phase’s `next` option with a string, you can
provide a function that will return the next phase based on game
state at the end of the phase:

```js
phases: {
phaseA: {
endIf: (G, ctx) => {
return { next: G.condition ? 'phaseB' : 'phaseC' }
next: (G, ctx) => {
return G.condition ? 'phaseC' : 'phaseB';
},
},
phaseB: { ... },
phaseC: { ... },
},
```

!> Whenever a phase ends, the current player's turn is first ended automatically.

### Override Behavior

Expand Down

0 comments on commit d8fc8f5

Please sign in to comment.