diff --git a/src/core/flow.js b/src/core/flow.js index 79cc26353..963341597 100644 --- a/src/core/flow.js +++ b/src/core/flow.js @@ -559,7 +559,7 @@ export function Flow({ moves, phases, endIf, turn, events, plugins }) { G = conf.onEnd(G, ctx); // Reset the phase. - ctx = { ...ctx, phase: null, playOrderPos: 0 }; + ctx = { ...ctx, phase: null }; // Add log entry. const action = gameEvent('endPhase', arg); diff --git a/src/core/flow.test.js b/src/core/flow.test.js index e8c559eff..4218f14a5 100644 --- a/src/core/flow.test.js +++ b/src/core/flow.test.js @@ -165,6 +165,20 @@ describe('phases', () => { state = flow.processGameEvent(state, gameEvent('endPhase')); expect(state.ctx.phase).toBe(null); }); + + test('maintain playOrderPos on phase end', () => { + const flow = Flow({ + phases: { A: { start: true, next: 'B' }, B: { next: 'A' } }, + }); + let state = { G: {}, ctx: flow.ctx(3) }; + state = flow.init(state); + + expect(state.ctx.playOrderPos).toBe(0); + state = flow.processGameEvent(state, gameEvent('endTurn')); + expect(state.ctx.playOrderPos).toBe(1); + state = flow.processGameEvent(state, gameEvent('endPhase')); + expect(state.ctx.playOrderPos).toBe(1); + }); }); describe('turn', () => { @@ -357,7 +371,7 @@ describe('turn', () => { state = flow.processMove(state, makeMove().payload); expect(state.ctx.phase).toBe('B'); - expect(state.ctx.currentPlayer).toBe('0'); + expect(state.ctx.currentPlayer).toBe('1'); expect(state.ctx.turn).toBe(3); }); });