@@ -186,12 +186,6 @@ export function Flow({
186186 *
187187 * @param {...object } setActionPlayers - Set to true to enable the `setActionPlayers` event.
188188 *
189- * @param {...object } allowedMoves - List of moves that are allowed.
190- * This can be either a list of
191- * move names or a function with the
192- * signature (G, ctx) => [].
193- * (default: null, i.e. all moves are allowed).
194- *
195189 * @param {...object } undoableMoves - List of moves that are undoable,
196190 * (default: null, i.e. all moves are undoable).
197191 *
@@ -250,10 +244,6 @@ export function Flow({
250244 * // A phase-specific movesPerTurn.
251245 * movesPerTurn: integer,
252246 *
253- * // List of moves or a function that returns a list of moves
254- * // that are allowed in this phase.
255- * allowedMoves: (G, ctx) => ['moveA', ...],
256- *
257247 * // List of moves that are undoable.
258248 * undoableMoves: ['moveA', ...],
259249 * }
@@ -273,7 +263,6 @@ export function FlowWithPhases({
273263 endGame,
274264 setActionPlayers,
275265 undoableMoves,
276- allowedMoves,
277266 redactedMoves,
278267 optimisticUpdate,
279268 game,
@@ -305,7 +294,6 @@ export function FlowWithPhases({
305294 if ( ! onTurnEnd ) onTurnEnd = G => G ;
306295 if ( ! onMove ) onMove = G => G ;
307296 if ( ! turnOrder ) turnOrder = TurnOrder . DEFAULT ;
308- if ( allowedMoves === undefined ) allowedMoves = null ;
309297 if ( undoableMoves === undefined ) undoableMoves = null ;
310298
311299 const phaseMap = phases ;
@@ -365,13 +353,6 @@ export function FlowWithPhases({
365353 if ( conf . undoableMoves === undefined ) {
366354 conf . undoableMoves = undoableMoves ;
367355 }
368- if ( conf . allowedMoves === undefined ) {
369- conf . allowedMoves = allowedMoves ;
370- }
371- if ( typeof conf . allowedMoves !== 'function' ) {
372- const t = conf . allowedMoves ;
373- conf . allowedMoves = ( ) => t ;
374- }
375356 }
376357
377358 const shouldEndPhase = ( { G, ctx } ) => {
@@ -408,8 +389,7 @@ export function FlowWithPhases({
408389 } ,
409390 } ;
410391
411- const allowedMoves = config . allowedMoves ( G , ctx ) ;
412- return { ...state , G, ctx : { ...ctx , allowedMoves } } ;
392+ return { ...state , G, ctx } ;
413393 } ;
414394
415395 const startTurn = function ( state , config ) {
@@ -419,7 +399,6 @@ export function FlowWithPhases({
419399 const _undo = [ { G, ctx : plainCtx } ] ;
420400
421401 const ctx = { ...state . ctx } ;
422- ctx . allowedMoves = config . allowedMoves ( G , ctx ) ;
423402
424403 // Reset stats.
425404 ctx . stats = {
@@ -678,10 +657,6 @@ export function FlowWithPhases({
678657 return { ...state , ctx : { ...state . ctx , gameover } } ;
679658 }
680659
681- // Update allowedMoves.
682- const allowedMoves = conf . allowedMoves ( state . G , state . ctx ) ;
683- state = { ...state , ctx : { ...state . ctx , allowedMoves } } ;
684-
685660 // Update undo / redo state.
686661 if ( ! endTurn ) {
687662 const undo = state . _undo || [ ] ;
@@ -700,10 +675,14 @@ export function FlowWithPhases({
700675 }
701676
702677 const canMakeMove = ( G , ctx , moveName ) => {
703- const conf = phaseMap [ ctx . phase ] ;
704- const moves = conf . allowedMoves ( G , ctx ) ;
705- if ( ! moves ) return true ;
706- return moves . includes ( moveName ) ;
678+ // If this is a namespaced move, verify that
679+ // we are in the correct phase.
680+ if ( moveName . includes ( '.' ) ) {
681+ const tokens = moveName . split ( '.' ) ;
682+ return tokens [ 0 ] == ctx . phase ;
683+ }
684+ // If not, then the move is allowed.
685+ return true ;
707686 } ;
708687
709688 const canUndoMove = ( G , ctx , moveName ) => {
0 commit comments