staging resolutions for future animations

This commit is contained in:
Mashy 2019-04-15 14:37:14 +10:00
parent 9217cf2a91
commit 5681b43b04
3 changed files with 19 additions and 6 deletions

View File

@ -1,6 +1,9 @@
module.exports = { module.exports = {
TIMES: { TIMES: {
RESOLUTION_TIME_MS: 2000, RESOLUTION_TIME_MS: 2000,
START_SKILL: 1000,
END_SKILL: 1000,
POST_SKILL: 1500,
}, },
ITEMS: { ITEMS: {

View File

@ -24,8 +24,18 @@ function registerEvents(store) {
const newRes = game.resolved.slice(currentGame.resolved.length); const newRes = game.resolved.slice(currentGame.resolved.length);
return eachSeries(newRes, (r, cb) => { return eachSeries(newRes, (r, cb) => {
if (['Disable', 'TargetKo'].includes(r.event[0])) return cb(); if (['Disable', 'TargetKo'].includes(r.event[0])) return cb();
store.dispatch(actions.setResolution(r)); // Create 3 new events for combat animations
return setTimeout(cb, TIMES.RESOLUTION_TIME_MS); const sequence = ['START_SKILL', 'END_SKILL', 'POST_SKILL'];
return eachSeries(sequence, (stage, sCb) => {
const stagedR = Object.create(r);
stagedR.stage = stage;
store.dispatch(actions.setResolution(stagedR));
return setTimeout(sCb, TIMES[stage]);
}, err => {
if (err) return console.error(err);
// Finished this resolution
return cb();
});
}, err => { }, err => {
if (err) return console.error(err); if (err) return console.error(err);
store.dispatch(actions.setResolution(null)); store.dispatch(actions.setResolution(null));

View File

@ -126,10 +126,9 @@ function eventClasses(resolution, cryp) {
if (type === 'Damage') { if (type === 'Damage') {
const { skill, amount, mitigation, colour } = event; const { skill, amount, mitigation, colour } = event;
if (colour === 'RedDamage' && resolution.stage === 'POST_SKILL') return 'red-damage';
if (colour === 'RedDamage') return 'red-damage'; if (colour === 'BlueDamage' && resolution.stage === 'POST_SKILL') return 'blue-damage';
if (colour === 'BlueDamage') return 'blue-damage'; if (colour === 'GreenDamage' && resolution.stage === 'POST_SKILL') return 'green-damage';
if (colour === 'GreenDamage') return 'green-damage';
} }
if (type === 'Healing') { if (type === 'Healing') {
@ -165,6 +164,7 @@ function eventClasses(resolution, cryp) {
function getCombatText(cryp, resolution) { function getCombatText(cryp, resolution) {
if (!resolution) return ''; if (!resolution) return '';
if (resolution.stage !== 'POST_SKILL') return '';
if (cryp.id !== resolution.target.id) return ''; if (cryp.id !== resolution.target.id) return '';
const [type, event] = resolution.event; const [type, event] = resolution.event;