convert server enum into anims keywords

This commit is contained in:
Mashy 2019-10-24 08:50:24 +10:00
parent e6e7713539
commit d9563f8a9a
3 changed files with 24 additions and 14 deletions

View File

@ -8,7 +8,7 @@ function none() {
}; };
} }
function getObjects(resolution, stages, game, account) { function getObjects(resolution, game, account) {
if (!resolution) return none(); if (!resolution) return none();
if (!resolution.target) return none(); if (!resolution.target) return none();
@ -53,7 +53,7 @@ function getObjects(resolution, stages, game, account) {
}; };
}; };
const skipSource = !stages.includes('START_SKILL') const skipSource = !resolution.stages.includes('START_SKILL')
|| resolution.source.id === resolution.target.id; || resolution.source.id === resolution.target.id;
const animSource = skipSource const animSource = skipSource
@ -118,10 +118,10 @@ function getFocusTargets(resolution, game) {
return [target]; return [target];
} }
function getText(resolution, sequence) { function getText(resolution) {
const nullText = { text: null, constructId: null, life: null }; const nullText = { text: null, constructId: null, life: null };
if (!resolution) return nullText; if (!resolution) return nullText;
if (!sequence.includes('POST_SKILL')) return nullText; if (!resolution.stages.includes('POST_SKILL')) return nullText;
function generatePostSkill() { function generatePostSkill() {
const [type, event] = resolution.event; const [type, event] = resolution.event;

View File

@ -67,21 +67,22 @@ function registerEvents(store) {
// stop fetching the game state til animations are done // stop fetching the game state til animations are done
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) => {
// convert server enum into anims keywords const timeout = animations.getTime(r.stages);
// todo make serersideonly const anims = animations.getObjects(r, game, account);
const sequence = animations.getSequence(r); const text = animations.getText(r);
const timeout = animations.getTime(sequence);
const anims = animations.getObjects(r, sequence, game, account);
const text = animations.getText(r, sequence);
store.dispatch(actions.setAnimFocus(animations.getFocusTargets(r, game))); store.dispatch(actions.setAnimFocus(animations.getFocusTargets(r, game)));
if (anims.animSkill) store.dispatch(actions.setAnimSkill(anims.animSkill)); if (anims.animSkill) store.dispatch(actions.setAnimSkill(anims.animSkill));
if (sequence.includes('START_SKILL') && anims.animSource) store.dispatch(actions.setAnimSource(anims.animSource)); if (r.stages.includes('START_SKILL') && anims.animSource) {
if (sequence.includes('END_SKILL') && anims.animTarget) { store.dispatch(actions.setAnimSource(anims.animSource));
}
if (r.stages.includes('END_SKILL') && anims.animTarget) {
store.dispatch(actions.setAnimTarget(anims.animTarget)); store.dispatch(actions.setAnimTarget(anims.animTarget));
if (animations.isCbAnim(anims.animSkill)) store.dispatch(actions.setAnimCb(cb)); if (animations.isCbAnim(anims.animSkill)) store.dispatch(actions.setAnimCb(cb));
} }
if (sequence.includes('POST_SKILL') && text) {
if (r.stages.includes('POST_SKILL') && text) {
// timeout to prevent text classes from being added too soon // timeout to prevent text classes from being added too soon
if (timeout === TIMES.POST_SKILL_DURATION_MS) { if (timeout === TIMES.POST_SKILL_DURATION_MS) {
store.dispatch(actions.setAnimText(text)); store.dispatch(actions.setAnimText(text));
@ -92,13 +93,14 @@ function registerEvents(store) {
); );
} }
} }
return setTimeout(() => { return setTimeout(() => {
store.dispatch(actions.setAnimSkill(null)); store.dispatch(actions.setAnimSkill(null));
store.dispatch(actions.setAnimSource(null)); store.dispatch(actions.setAnimSource(null));
store.dispatch(actions.setAnimTarget(null)); store.dispatch(actions.setAnimTarget(null));
store.dispatch(actions.setAnimText(null)); store.dispatch(actions.setAnimText(null));
store.dispatch(actions.setAnimFocus([])); store.dispatch(actions.setAnimFocus([]));
if (sequence.includes('END_SKILL') && animations.isCbAnim(anims.animSkill)) return true; if (r.stages.includes('END_SKILL') && animations.isCbAnim(anims.animSkill)) return true;
return cb(); return cb();
}, timeout); }, timeout);
}, err => { }, err => {

View File

@ -408,13 +408,21 @@ pub struct EventConstruct {
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub enum EventStages { pub enum EventStages {
#[serde(rename = "START_SKILL END_SKILL POST_SKILL")]
AllStages, // Anim Anim Anim AllStages, // Anim Anim Anim
#[serde(rename = "START_SKILL END_SKILL")]
StartEnd, // Anim Anim Skip StartEnd, // Anim Anim Skip
#[serde(rename = "START_SKILL POST_SKILL")]
StartPost, // Anim Skip Anim StartPost, // Anim Skip Anim
#[serde(rename = "START_SKILL")]
StartOnly, // Anim Skip Skip StartOnly, // Anim Skip Skip
#[serde(rename = "END_SKILL POST_SKILL")]
EndPost, // Skip Anim Anim EndPost, // Skip Anim Anim
#[serde(rename = "END_SKILL")]
EndOnly, // Skip Anim Skip EndOnly, // Skip Anim Skip
#[serde(rename = "POST_SKILL")]
PostOnly, // Skip Skip Anim PostOnly, // Skip Skip Anim
#[serde(rename = "")]
NoStages, // Skip Skip Skip NoStages, // Skip Skip Skip
} }