@@ -15,6 +15,7 @@ import {
1515import { automaticGameEvent } from './action-creators' ;
1616import { ContextEnhancer } from './reducer' ;
1717import * as logging from './logger' ;
18+ import produce from 'immer' ;
1819
1920/**
2021 * Helper to create a reducer that manages ctx (with the
@@ -310,9 +311,11 @@ export function FlowWithPhases({
310311 if ( conf . onPhaseBegin === undefined ) {
311312 conf . onPhaseBegin = G => G ;
312313 }
314+ conf . onPhaseBegin = produce ( conf . onPhaseBegin ) ;
313315 if ( conf . onPhaseEnd === undefined ) {
314316 conf . onPhaseEnd = G => G ;
315317 }
318+ conf . onPhaseEnd = produce ( conf . onPhaseEnd ) ;
316319 if ( conf . movesPerTurn === undefined ) {
317320 conf . movesPerTurn = movesPerTurn ;
318321 }
@@ -325,12 +328,15 @@ export function FlowWithPhases({
325328 if ( conf . onTurnBegin === undefined ) {
326329 conf . onTurnBegin = onTurnBegin ;
327330 }
331+ conf . onTurnBegin = produce ( conf . onTurnBegin ) ;
328332 if ( conf . onTurnEnd === undefined ) {
329333 conf . onTurnEnd = onTurnEnd ;
330334 }
335+ conf . onTurnEnd = produce ( conf . onTurnEnd ) ;
331336 if ( conf . onMove === undefined ) {
332337 conf . onMove = onMove ;
333338 }
339+ conf . onMove = produce ( conf . onMove ) ;
334340 if ( conf . turnOrder === undefined ) {
335341 conf . turnOrder = turnOrder ;
336342 }
0 commit comments