diff --git a/client/src/animations.socket.jsx b/client/src/animations.socket.jsx index bdf2915c..424114b1 100644 --- a/client/src/animations.socket.jsx +++ b/client/src/animations.socket.jsx @@ -57,7 +57,6 @@ function createSocket(store) { store.dispatch(actions.setGame(currentGame)); return true; }); - } const handlers = { diff --git a/client/src/events.jsx b/client/src/events.jsx index 88f1f1b6..2c6119d0 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -60,14 +60,20 @@ function registerEvents(store) { if (['Disable', 'TargetKo'].includes(r.event[0])) return cb(); // Create sub events for combat animations const sequence = getCombatSequence(r); - return eachSeries(sequence, (stage, sCb) => { - const { skip } = store.getState(); - if (skip) return sCb('skip'); + return eachSeries(sequence, (stages, sCb) => { const stagedR = Object.create(r); - stagedR.stage = stage; + stagedR.sequence = sequence; + stagedR.stages = stages; + + let timeout = 0; + if (stages.includes('START_SKILL') && stages.includes('END_SKILL')) { + timeout = TIMES.SOURCE_AND_TARGET_TOTAL_DURATION; + } else if (stages.includes('START_SKILL')) timeout = TIMES.SOURCE_DURATION_MS; + else if (stages.includes('END_SKILL')) timeout = TIMES.TARGET_DURATION_MS; + else if (stages.includes('POST_SKILL')) timeout = TIMES.POST_SKILL_DURATION_MS; store.dispatch(actions.setResolution(stagedR)); - return setTimeout(sCb, TIMES[stage]); + return setTimeout(sCb, timeout); }, err => { if (err) console.error(err); // Finished this resolution @@ -79,9 +85,7 @@ function registerEvents(store) { // stop skipping resolutions store.dispatch(actions.setSkip(false)); // update the game - store.dispatch(actions.setGame(game)); - // get the latest state and restart polling - ws.sendGameState(currentGame.id); + store.dispatch(actions.setGame(currentGame)); return true; }); }