@@ -103,6 +103,8 @@ export function Flow({ ctx, events, init, validator, processMove }) {
103103 * @param {...object } onTurnEnd - Any code to run when a turn ends.
104104 * (G, ctx) => G
105105 *
106+ * @param {...object } turnOrder - Customize the turn order (see turn-order.js).
107+ *
106108 * @param {...object } triggers - An array of objects with the format:
107109 * {
108110 * condition: (G, ctx) => boolean,
@@ -149,15 +151,8 @@ export function Flow({ ctx, events, init, validator, processMove }) {
149151 * // A phase-specific movesPerTurn.
150152 * movesPerTurn: integer,
151153 *
152- * // Called when `endTurn` is processed, and returns the next player.
153- * // If not specified, TurnOrder.DEFAULT is used.
154- * turnOrder: {
155- * // The first player.
156- * first: (G, ctx) => playerID,
157- * // Called whenever `endTurn` is processed to determine
158- * // the next player.
159- * next: (G, ctx) => playerID,
160- * },
154+ * // A phase-specific turnOrder.
155+ * turnOrder: TurnOrder.DEFAULT,
161156 *
162157 * // List of moves that are allowed in this phase.
163158 * allowedMoves: ['moveA', ...],
@@ -169,6 +164,7 @@ export function FlowWithPhases({
169164 endTurnIf,
170165 endGameIf,
171166 onTurnEnd,
167+ turnOrder,
172168 triggers,
173169 events,
174170} ) {
@@ -184,6 +180,7 @@ export function FlowWithPhases({
184180 if ( ! endTurnIf ) endTurnIf = ( ) => false ;
185181 if ( ! endGameIf ) endGameIf = ( ) => undefined ;
186182 if ( ! onTurnEnd ) onTurnEnd = G => G ;
183+ if ( ! turnOrder ) turnOrder = TurnOrder . DEFAULT ;
187184 if ( ! triggers ) triggers = [ ] ;
188185
189186 let phaseKeys = [ ] ;
@@ -194,7 +191,7 @@ export function FlowWithPhases({
194191 phaseMap [ conf . name ] = conf ;
195192
196193 if ( ! conf . turnOrder ) {
197- conf . turnOrder = TurnOrder . DEFAULT ;
194+ conf . turnOrder = turnOrder ;
198195 }
199196 if ( ! conf . endPhaseIf ) {
200197 conf . endPhaseIf = ( ) => false ;
0 commit comments