From 5940be499e22f27ce979692d0fe4976933a8b8c3 Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 13 Jan 2020 16:58:40 +1000 Subject: [PATCH] animate all turns that have happened since last game state --- client/src/events.jsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/client/src/events.jsx b/client/src/events.jsx index 48028205..e5d3a92b 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -77,21 +77,24 @@ function registerEvents(store) { if (game && currentGame) { if (game.resolutions.length !== currentGame.resolutions.length) { + // stop fetching the game state til animations are done store.dispatch(actions.setAnimating(true)); store.dispatch(actions.setGameSkillInfo(null)); - // stop fetching the game state til animations are done - const newRes = game.resolutions[game.resolutions.length - 1]; - return eachSeries(newRes, (r, cb) => { - if (r.delay === 0) return cb(); // TargetKo etc - setAnimations(r, store); - return setTimeout(cb, r.delay); + + const newTurns = game.resolutions.slice(currentGame.resolutions.length); + return eachSeries(newTurns, (turn, turnCb) => { + return eachSeries(turn, (r, cb) => { + if (r.delay === 0) return cb(); // TargetKo etc + setAnimations(r, store); + return setTimeout(cb, r.delay); + }, turnCb); }, err => { if (err) return console.error(err); clearAnimations(store); // set the game state so resolutions don't fire twice store.dispatch(actions.setGame(game)); ws.sendGameState(game.id); - return true; + return false; }); } }