@@ -21,9 +21,10 @@ import * as logging from './logger';
2121 * Helper to create a reducer that manages ctx (with the
2222 * ability to also update G).
2323 *
24- * You probably want to use FlowWithPhases below, but you might
25- * need to use this directly if you are creating a very customized
26- * game flow that it cannot handle.
24+ * This is mostly around for legacy reasons. The original plan
25+ * was to have two flows, one with phases etc. and another
26+ * simpler one like this. The current state is such that this
27+ * is merely an internal function of FlowWithPhases below.
2728 *
2829 * @param {...object } ctx - Function with the signature
2930 * numPlayers => ctx
@@ -67,6 +68,7 @@ export function Flow({
6768 canMakeMove,
6869 canUndoMove,
6970 redactedMoves,
71+ moveMap,
7072} ) {
7173 if ( ! ctx ) ctx = ( ) => ( { } ) ;
7274 if ( ! events ) events = { } ;
@@ -103,6 +105,7 @@ export function Flow({
103105 init,
104106 canUndoMove,
105107 redactedMoves,
108+ moveMap,
106109
107110 eventNames : Object . getOwnPropertyNames ( events ) ,
108111 enabledEventNames : Object . getOwnPropertyNames ( enabledEvents ) ,
@@ -313,9 +316,17 @@ export function FlowWithPhases({
313316
314317 phaseMap [ 'default' ] = { } ;
315318
319+ let moveMap = { } ;
320+
316321 for ( let phase in phaseMap ) {
317322 const conf = phaseMap [ phase ] ;
318323
324+ if ( conf . moves !== undefined ) {
325+ for ( let move of Object . keys ( conf . moves ) ) {
326+ moveMap [ phase + '.' + move ] = conf . moves [ move ] ;
327+ }
328+ }
329+
319330 if ( conf . endPhaseIf === undefined ) {
320331 conf . endPhaseIf = ( ) => undefined ;
321332 }
@@ -752,5 +763,6 @@ export function FlowWithPhases({
752763 canMakeMove,
753764 canUndoMove,
754765 redactedMoves,
766+ moveMap,
755767 } ) ;
756768}
0 commit comments