animate all turns that have happened since last game state
This commit is contained in:
parent
71b7f0b2b4
commit
5940be499e
@ -77,21 +77,24 @@ function registerEvents(store) {
|
|||||||
|
|
||||||
if (game && currentGame) {
|
if (game && currentGame) {
|
||||||
if (game.resolutions.length !== currentGame.resolutions.length) {
|
if (game.resolutions.length !== currentGame.resolutions.length) {
|
||||||
|
// stop fetching the game state til animations are done
|
||||||
store.dispatch(actions.setAnimating(true));
|
store.dispatch(actions.setAnimating(true));
|
||||||
store.dispatch(actions.setGameSkillInfo(null));
|
store.dispatch(actions.setGameSkillInfo(null));
|
||||||
// stop fetching the game state til animations are done
|
|
||||||
const newRes = game.resolutions[game.resolutions.length - 1];
|
const newTurns = game.resolutions.slice(currentGame.resolutions.length);
|
||||||
return eachSeries(newRes, (r, cb) => {
|
return eachSeries(newTurns, (turn, turnCb) => {
|
||||||
if (r.delay === 0) return cb(); // TargetKo etc
|
return eachSeries(turn, (r, cb) => {
|
||||||
setAnimations(r, store);
|
if (r.delay === 0) return cb(); // TargetKo etc
|
||||||
return setTimeout(cb, r.delay);
|
setAnimations(r, store);
|
||||||
|
return setTimeout(cb, r.delay);
|
||||||
|
}, turnCb);
|
||||||
}, err => {
|
}, err => {
|
||||||
if (err) return console.error(err);
|
if (err) return console.error(err);
|
||||||
clearAnimations(store);
|
clearAnimations(store);
|
||||||
// set the game state so resolutions don't fire twice
|
// set the game state so resolutions don't fire twice
|
||||||
store.dispatch(actions.setGame(game));
|
store.dispatch(actions.setGame(game));
|
||||||
ws.sendGameState(game.id);
|
ws.sendGameState(game.id);
|
||||||
return true;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user