@@ -226,7 +226,7 @@ export function Flow({ moves, phases, endIf, turn, events, plugins }) {
226226
227227 let moveMap = { } ;
228228 let moveNames = new Set ( ) ;
229- let startingPhase = '' ;
229+ let startingPhase = null ;
230230
231231 Object . keys ( moves ) . forEach ( name => moveNames . add ( name ) ) ;
232232
@@ -294,7 +294,7 @@ export function Flow({ moves, phases, endIf, turn, events, plugins }) {
294294 }
295295
296296 function GetPhase ( ctx ) {
297- return phaseMap [ ctx . phase ] ;
297+ return ctx . phase ? phaseMap [ ctx . phase ] : phaseMap [ '' ] ;
298298 }
299299
300300 function OnMove ( s ) {
@@ -555,21 +555,21 @@ export function Flow({ moves, phases, endIf, turn, events, plugins }) {
555555 return state ;
556556 }
557557
558- // If we aren't in a phase, there is nothing to do.
559- // if (ctx.phase === '') {
560- // return state;
561- // }
558+ if ( next ) {
559+ next . push ( { fn : UpdatePhase , arg, phase : ctx . phase } ) ;
560+ }
561+
562+ // If we aren't in a phase, there is nothing else to do.
563+ if ( ctx . phase === null ) {
564+ return state ;
565+ }
562566
563567 // Run any cleanup code for the phase that is about to end.
564568 const conf = GetPhase ( ctx ) ;
565569 G = conf . onEnd ( G , ctx ) ;
566570
567- if ( next ) {
568- next . push ( { fn : UpdatePhase , arg, phase : ctx . phase } ) ;
569- }
570-
571571 // Reset the phase.
572- ctx = { ...ctx , phase : '' , playOrderPos : 0 } ;
572+ ctx = { ...ctx , phase : null , playOrderPos : 0 } ;
573573
574574 // Add log entry.
575575 const action = gameEvent ( 'endPhase' , arg ) ;
0 commit comments