Skip to content

Commit

Permalink
reset deltalog properly
Browse files Browse the repository at this point in the history
  • Loading branch information
darthfiddler committed Aug 25, 2018
1 parent 858975c commit 9b9d735
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export function CreateGameReducer({ game, numPlayers, multiplayer }) {
return (state = initial, action) => {
switch (action.type) {
case Actions.GAME_EVENT: {
state = { ...state, deltalog: [] };

// Process game events only on the server.
// These events like `endTurn` typically
// contain code that may rely on secret state
Expand All @@ -135,8 +137,6 @@ export function CreateGameReducer({ game, numPlayers, multiplayer }) {
return state;
}

state = { ...state, deltalog: undefined };

const apiCtx = new ContextEnhancer(
state.ctx,
game,
Expand All @@ -152,6 +152,8 @@ export function CreateGameReducer({ game, numPlayers, multiplayer }) {
}

case Actions.MAKE_MOVE: {
state = { ...state, deltalog: [] };

// Check whether the game knows the move at all.
if (!game.moveNames.includes(action.payload.type)) {
return state;
Expand All @@ -175,8 +177,6 @@ export function CreateGameReducer({ game, numPlayers, multiplayer }) {
return state;
}

state = { ...state, deltalog: undefined };

const apiCtx = new ContextEnhancer(
state.ctx,
game,
Expand Down

0 comments on commit 9b9d735

Please sign in to comment.