fixed event

This commit is contained in:
Mashy 2019-07-05 18:28:00 +10:00
parent 47c1cffc7f
commit 5542efd62e
2 changed files with 12 additions and 9 deletions

View File

@ -57,7 +57,6 @@ function createSocket(store) {
store.dispatch(actions.setGame(currentGame));
return true;
});
}
const handlers = {

View File

@ -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;
});
}