From 2e1b298bbf0eed10cc38a4db4767dec979f21be6 Mon Sep 17 00:00:00 2001 From: Mashy Date: Wed, 23 Oct 2019 12:08:21 +1000 Subject: [PATCH 1/9] remove client from deciding event stages wip --- client/src/animations.utils.jsx | 2 -- client/src/events.jsx | 2 -- server/src/skill.rs | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/client/src/animations.utils.jsx b/client/src/animations.utils.jsx index 38da27d5..95389eeb 100644 --- a/client/src/animations.utils.jsx +++ b/client/src/animations.utils.jsx @@ -75,8 +75,6 @@ function getObjects(resolution, stages, game, account) { function getSequence(resolution) { if (!resolution.event) return []; if (resolution.event[0] === 'Inversion') return []; - if (['TargetKo', 'Ko'].includes(resolution.event[0])) return []; - if (['Skill', 'AoeSkill'].includes(resolution.event[0])) return ['START_SKILL', 'END_SKILL']; switch (resolution.stages) { case 'AllStages': return ['START_SKILL', 'END_SKILL', 'POST_SKILL']; diff --git a/client/src/events.jsx b/client/src/events.jsx index 3db2ce7b..945c2b59 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -67,8 +67,6 @@ function registerEvents(store) { // stop fetching the game state til animations are done const newRes = game.resolved.slice(currentGame.resolved.length); return eachSeries(newRes, (r, cb) => { - if (['Disable', 'TargetKo'].includes(r.event[0])) return cb(); - // convert server enum into anims keywords // todo make serersideonly const sequence = animations.getSequence(r); diff --git a/server/src/skill.rs b/server/src/skill.rs index d4685c2a..f7254101 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -342,7 +342,7 @@ fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) -> }; if target.is_ko() { - resolutions.push(Resolution::new(&source, &target).event(Event::Ko())); + resolutions.push(Resolution::new(&source, &target).event(Event::Ko()).stages(EventStages::PostOnly)); target.effects.clear(); } From 14cb0751616a508848eb649276cf0c6d1641144d Mon Sep 17 00:00:00 2001 From: Mashy Date: Wed, 23 Oct 2019 15:49:46 +1000 Subject: [PATCH 2/9] fix animCb logic from stalling --- client/src/animations.utils.jsx | 15 +++++++++++---- client/src/events.jsx | 8 ++++---- client/src/utils.jsx | 1 + server/src/skill.rs | 4 ++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/client/src/animations.utils.jsx b/client/src/animations.utils.jsx index 95389eeb..2e525c86 100644 --- a/client/src/animations.utils.jsx +++ b/client/src/animations.utils.jsx @@ -1,4 +1,5 @@ const { TIMES } = require('./constants'); +const { removeTier } = require('./utils'); function none() { return { @@ -200,14 +201,20 @@ function getText(resolution, sequence) { }; } +function isCbAnim(skill) { + return ['Attack', 'Blast', 'Siphon', 'SiphonTick', 'Strike', 'Chaos', 'Slay', 'Heal', + 'Buff', 'Amplify', 'Haste', 'Triage', 'TriageTick', 'Link', 'Hybrid', 'Intercept', + 'Debuff', 'Curse', 'Decay', 'DecayTick', 'Purge', 'Silence', 'Restrict', + 'Stun', 'Bash', 'Absorb', 'Sleep', 'Break', 'Ruin', + 'Block', 'Sustain', 'Electrify', 'Electrocute', 'ElectrocuteTick', + 'Counter', 'CounterAttack', 'Purify', 'Recharge', 'Reflect'].includes(removeTier(skill)); +} + module.exports = { getFocusTargets, getObjects, getTime, getSequence, getText, + isCbAnim, }; - - - // if (!(resolution.target.id === construct.id) - // && !(resolution.event[0] === 'AoeSkill' && targetTeam.includes(construct.id))) return false; diff --git a/client/src/events.jsx b/client/src/events.jsx index 945c2b59..b70d2221 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -7,7 +7,7 @@ const sample = require('lodash/sample'); const actions = require('./actions'); const { TIMES } = require('./constants'); const animations = require('./animations.utils'); -const { infoToast, errorToast, removeTier } = require('./utils'); +const { infoToast, errorToast } = require('./utils'); function registerEvents(store) { function notify(msg) { @@ -79,7 +79,7 @@ function registerEvents(store) { if (sequence.includes('START_SKILL') && anims.animSource) store.dispatch(actions.setAnimSource(anims.animSource)); if (sequence.includes('END_SKILL') && anims.animTarget) { store.dispatch(actions.setAnimTarget(anims.animTarget)); - if (!['Banish', 'Invert'].includes(removeTier(anims.animTarget.skill))) store.dispatch(actions.setAnimCb(cb)); + if (animations.isCbAnim(anims.animSkill)) store.dispatch(actions.setAnimCb(cb)); } if (sequence.includes('POST_SKILL') && text) { // timeout to prevent text classes from being added too soon @@ -98,8 +98,8 @@ function registerEvents(store) { store.dispatch(actions.setAnimTarget(null)); store.dispatch(actions.setAnimText(null)); store.dispatch(actions.setAnimFocus([])); - if (!sequence.includes('END_SKILL') || (anims.animSkill && ['Banish', 'Invert'].includes(anims.animSkill))) return cb(); - return true; + if (sequence.includes('END_SKILL') && animations.isCbAnim(anims.animSkill)) return true; + return cb(); }, timeout); }, err => { if (err) return console.error(err); diff --git a/client/src/utils.jsx b/client/src/utils.jsx index ca66fd54..88719c34 100644 --- a/client/src/utils.jsx +++ b/client/src/utils.jsx @@ -142,6 +142,7 @@ function randomPoints(numPoints, radius, dimensions) { } const removeTier = skill => { + if (!skill) return skill; if (skill.includes('SiphonTick')) return 'SiphonTick'; if (skill.includes('TriageTick')) return 'TriageTick'; if (skill.includes('DecayTick')) return 'DecayTick'; diff --git a/server/src/skill.rs b/server/src/skill.rs index f7254101..998cb178 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -69,12 +69,12 @@ pub fn pre_resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) - pub fn resolve(skill: Skill, source: &mut Construct, target: &mut Construct, mut resolutions: Vec) -> Resolutions { if let Some(disable) = source.disabled(skill) { - resolutions.push(Resolution::new(source, target).event(Event::Disable { disable, skill })); + resolutions.push(Resolution::new(source, target).event(Event::Disable { disable, skill }).stages(EventStages::PostOnly)); return resolutions; } if target.is_ko() { - resolutions.push(Resolution::new(source, target).event(Event::TargetKo { skill })); + resolutions.push(Resolution::new(source, target).event(Event::TargetKo { skill }).stages(EventStages::PostOnly)); return resolutions; } From c203727d2508fbe059bdb956ebe149a8e0c7924a Mon Sep 17 00:00:00 2001 From: Mashy Date: Wed, 23 Oct 2019 16:03:33 +1000 Subject: [PATCH 3/9] fix animation stages --- server/src/skill.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/skill.rs b/server/src/skill.rs index 998cb178..ed594c4d 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -16,7 +16,7 @@ pub fn dev_resolve(a_id: Uuid, b_id: Uuid, skill: Skill) -> Resolutions { let mut b = Construct::new(); b.id = b_id; if skill.aoe() { // Send an aoe skill event for anims - resolutions.push(Resolution::new(&a, &b).event(Event::AoeSkill { skill })); + resolutions.push(Resolution::new(&a, &b).event(Event::AoeSkill { skill }).stages(EventStages::StartEnd)); } return resolve(skill, &mut a, &mut b, resolutions); } @@ -36,7 +36,7 @@ pub fn pre_resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) - if skill.aoe() { // Send an aoe skill event for anims resolutions.push(Resolution::new(&source, - &game.construct_by_id(cast.target_construct_id).unwrap().clone()).event(Event::AoeSkill { skill })); + &game.construct_by_id(cast.target_construct_id).unwrap().clone()).event(Event::AoeSkill { skill }).stages(EventStages::StartEnd)); } for target_id in targets { @@ -68,13 +68,13 @@ pub fn pre_resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) - } pub fn resolve(skill: Skill, source: &mut Construct, target: &mut Construct, mut resolutions: Vec) -> Resolutions { - if let Some(disable) = source.disabled(skill) { - resolutions.push(Resolution::new(source, target).event(Event::Disable { disable, skill }).stages(EventStages::PostOnly)); + if let Some(_disable) = source.disabled(skill) { + // resolutions.push(Resolution::new(source, target).event(Event::Disable { disable, skill }).stages(EventStages::PostOnly)); return resolutions; } if target.is_ko() { - resolutions.push(Resolution::new(source, target).event(Event::TargetKo { skill }).stages(EventStages::PostOnly)); + // resolutions.push(Resolution::new(source, target).event(Event::TargetKo { skill }).stages(EventStages::PostOnly)); return resolutions; } @@ -1811,7 +1811,7 @@ fn silence(source: &mut Construct, target: &mut Construct, mut results: Resoluti } fn purge(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { - results.push(Resolution::new(source, target).event(Event::Skill { skill })); + results.push(Resolution::new(source, target).event(Event::Skill { skill }).stages(EventStages::StartEnd)); while let Some(i) = target.effects .iter() .position(|ce| { @@ -1845,7 +1845,7 @@ fn purge(source: &mut Construct, target: &mut Construct, mut results: Resolution } fn purify(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { - results.push(Resolution::new(source, target).event(Event::Skill { skill })); + results.push(Resolution::new(source, target).event(Event::Skill { skill }).stages(EventStages::StartEnd)); let amount = source.green_power().pct(skill.multiplier()); while let Some(i) = target.effects .iter() @@ -1869,7 +1869,7 @@ fn purify(source: &mut Construct, target: &mut Construct, mut results: Resolutio } fn banish(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { - results.push(Resolution::new(source, target).event(Event::Skill { skill })); + results.push(Resolution::new(source, target).event(Event::Skill { skill }).stages(EventStages::StartEnd)); let red_damage = target.red_life().pct(skill.multiplier()); let blue_damage = target.blue_life().pct(skill.multiplier()); From e6e7713539e5c18fb6899231503b5441978a9142 Mon Sep 17 00:00:00 2001 From: Mashy Date: Wed, 23 Oct 2019 19:17:57 +1000 Subject: [PATCH 4/9] remove inversion event --- client/src/animations.utils.jsx | 2 -- server/src/construct.rs | 6 +++--- server/src/skill.rs | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/client/src/animations.utils.jsx b/client/src/animations.utils.jsx index 2e525c86..09cf7fa8 100644 --- a/client/src/animations.utils.jsx +++ b/client/src/animations.utils.jsx @@ -75,8 +75,6 @@ function getObjects(resolution, stages, game, account) { function getSequence(resolution) { if (!resolution.event) return []; - if (resolution.event[0] === 'Inversion') return []; - switch (resolution.stages) { case 'AllStages': return ['START_SKILL', 'END_SKILL', 'POST_SKILL']; case 'StartEnd': return ['START_SKILL', 'END_SKILL']; diff --git a/server/src/construct.rs b/server/src/construct.rs index d1f5eab9..325e6d5e 100644 --- a/server/src/construct.rs +++ b/server/src/construct.rs @@ -606,7 +606,7 @@ impl Construct { }); }, true => { - events.push(Event::Inversion { skill }); + // events.push(Event::Inversion { skill }); // there is no green shield (yet) let current_green_life = self.green_life(); @@ -669,7 +669,7 @@ impl Construct { }); }, true => { - events.push(Event::Inversion { skill }); + // events.push(Event::Inversion { skill }); let current_green_life = self.green_life(); self.green_life.increase(modified_power); @@ -738,7 +738,7 @@ impl Construct { }); }, true => { - events.push(Event::Inversion { skill }); + // events.push(Event::Inversion { skill }); let current_green_life = self.green_life(); self.green_life.increase(modified_power); diff --git a/server/src/skill.rs b/server/src/skill.rs index ed594c4d..3aab4aa8 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -2004,10 +2004,10 @@ mod tests { // attack should heal and recharge red shield let mut results = attack(&mut x, &mut y, vec![], Skill::Attack); - match results.remove(0).event { - Event::Inversion { skill } => assert_eq!(skill, Skill::Attack), - _ => panic!("not inversion"), - }; + // match results.remove(0).event { + // Event::Inversion { skill } => assert_eq!(skill, Skill::Attack), + // _ => panic!("not inversion"), + //}; match results.remove(0).event { Event::Healing { skill: _, overhealing: _, amount } => assert!(amount > 0), From d9563f8a9a0596f791b2c4bc5efe134975d5c057 Mon Sep 17 00:00:00 2001 From: Mashy Date: Thu, 24 Oct 2019 08:50:24 +1000 Subject: [PATCH 5/9] convert server enum into anims keywords --- client/src/animations.utils.jsx | 8 ++++---- client/src/events.jsx | 22 ++++++++++++---------- server/src/skill.rs | 8 ++++++++ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/client/src/animations.utils.jsx b/client/src/animations.utils.jsx index 09cf7fa8..05ca0e8a 100644 --- a/client/src/animations.utils.jsx +++ b/client/src/animations.utils.jsx @@ -8,7 +8,7 @@ function none() { }; } -function getObjects(resolution, stages, game, account) { +function getObjects(resolution, game, account) { if (!resolution) 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; const animSource = skipSource @@ -118,10 +118,10 @@ function getFocusTargets(resolution, game) { return [target]; } -function getText(resolution, sequence) { +function getText(resolution) { const nullText = { text: null, constructId: null, life: null }; if (!resolution) return nullText; - if (!sequence.includes('POST_SKILL')) return nullText; + if (!resolution.stages.includes('POST_SKILL')) return nullText; function generatePostSkill() { const [type, event] = resolution.event; diff --git a/client/src/events.jsx b/client/src/events.jsx index b70d2221..972ea9d0 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -67,21 +67,22 @@ function registerEvents(store) { // stop fetching the game state til animations are done const newRes = game.resolved.slice(currentGame.resolved.length); return eachSeries(newRes, (r, cb) => { - // convert server enum into anims keywords - // todo make serersideonly - const sequence = animations.getSequence(r); - const timeout = animations.getTime(sequence); - const anims = animations.getObjects(r, sequence, game, account); - const text = animations.getText(r, sequence); + const timeout = animations.getTime(r.stages); + const anims = animations.getObjects(r, game, account); + const text = animations.getText(r); store.dispatch(actions.setAnimFocus(animations.getFocusTargets(r, game))); if (anims.animSkill) store.dispatch(actions.setAnimSkill(anims.animSkill)); - if (sequence.includes('START_SKILL') && anims.animSource) store.dispatch(actions.setAnimSource(anims.animSource)); - if (sequence.includes('END_SKILL') && anims.animTarget) { + if (r.stages.includes('START_SKILL') && anims.animSource) { + store.dispatch(actions.setAnimSource(anims.animSource)); + } + + if (r.stages.includes('END_SKILL') && anims.animTarget) { store.dispatch(actions.setAnimTarget(anims.animTarget)); 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 if (timeout === TIMES.POST_SKILL_DURATION_MS) { store.dispatch(actions.setAnimText(text)); @@ -92,13 +93,14 @@ function registerEvents(store) { ); } } + return setTimeout(() => { store.dispatch(actions.setAnimSkill(null)); store.dispatch(actions.setAnimSource(null)); store.dispatch(actions.setAnimTarget(null)); store.dispatch(actions.setAnimText(null)); 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(); }, timeout); }, err => { diff --git a/server/src/skill.rs b/server/src/skill.rs index 3aab4aa8..75a6094d 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -408,13 +408,21 @@ pub struct EventConstruct { #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] pub enum EventStages { + #[serde(rename = "START_SKILL END_SKILL POST_SKILL")] AllStages, // Anim Anim Anim + #[serde(rename = "START_SKILL END_SKILL")] StartEnd, // Anim Anim Skip + #[serde(rename = "START_SKILL POST_SKILL")] StartPost, // Anim Skip Anim + #[serde(rename = "START_SKILL")] StartOnly, // Anim Skip Skip + #[serde(rename = "END_SKILL POST_SKILL")] EndPost, // Skip Anim Anim + #[serde(rename = "END_SKILL")] EndOnly, // Skip Anim Skip + #[serde(rename = "POST_SKILL")] PostOnly, // Skip Skip Anim + #[serde(rename = "")] NoStages, // Skip Skip Skip } From e0cae50cc65d6642d7628eb171f810ccec90f955 Mon Sep 17 00:00:00 2001 From: Mashy Date: Thu, 24 Oct 2019 08:53:04 +1000 Subject: [PATCH 6/9] anim cleanup --- client/src/animations.utils.jsx | 16 ---------------- client/src/events.jsx | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/client/src/animations.utils.jsx b/client/src/animations.utils.jsx index 05ca0e8a..8e2818c7 100644 --- a/client/src/animations.utils.jsx +++ b/client/src/animations.utils.jsx @@ -73,21 +73,6 @@ function getObjects(resolution, game, account) { }; } -function getSequence(resolution) { - if (!resolution.event) return []; - switch (resolution.stages) { - case 'AllStages': return ['START_SKILL', 'END_SKILL', 'POST_SKILL']; - case 'StartEnd': return ['START_SKILL', 'END_SKILL']; - case 'StartPost': return ['START_SKILL', 'POST_SKILL']; - case 'StartOnly': return ['START_SKILL']; - case 'EndPost': return ['END_SKILL', 'POST_SKILL']; - case 'EndOnly': return ['END_SKILL']; - case 'PostOnly': return ['POST_SKILL']; - case 'NoStages': return []; - default: return ['START_SKILL', 'END_SKILL', 'POST_SKILL']; - } -} - function getTime(stages) { let time = 0; if (stages.includes('START_SKILL') && stages.includes('END_SKILL')) { @@ -212,7 +197,6 @@ module.exports = { getFocusTargets, getObjects, getTime, - getSequence, getText, isCbAnim, }; diff --git a/client/src/events.jsx b/client/src/events.jsx index 972ea9d0..b09cb57c 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -63,10 +63,10 @@ function registerEvents(store) { if (game.resolved.length !== currentGame.resolved.length) { store.dispatch(actions.setAnimating(true)); store.dispatch(actions.setGameSkillInfo(null)); - // stop fetching the game state til animations are done const newRes = game.resolved.slice(currentGame.resolved.length); return eachSeries(newRes, (r, cb) => { + if (!r.event) return cb; const timeout = animations.getTime(r.stages); const anims = animations.getObjects(r, game, account); const text = animations.getText(r); From a388a3427020717a6fe356076690c0102b05971b Mon Sep 17 00:00:00 2001 From: Mashy Date: Thu, 24 Oct 2019 09:01:40 +1000 Subject: [PATCH 7/9] bailout for no stages --- client/src/events.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/events.jsx b/client/src/events.jsx index b09cb57c..66832af9 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -66,7 +66,7 @@ function registerEvents(store) { // stop fetching the game state til animations are done const newRes = game.resolved.slice(currentGame.resolved.length); return eachSeries(newRes, (r, cb) => { - if (!r.event) return cb; + if (!r.event || r.stages === '') return cb; const timeout = animations.getTime(r.stages); const anims = animations.getObjects(r, game, account); const text = animations.getText(r); From 657d0950f64631034d9219333885cc92624f83b1 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 24 Oct 2019 11:09:43 +1100 Subject: [PATCH 8/9] v1.6.4 --- VERSION | 2 +- acp/package.json | 2 +- client/package.json | 2 +- ops/package.json | 2 +- server/Cargo.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index f5d2a585..6463e95e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6.3 \ No newline at end of file +1.6.4 \ No newline at end of file diff --git a/acp/package.json b/acp/package.json index b0f4f97b..58c51770 100644 --- a/acp/package.json +++ b/acp/package.json @@ -1,6 +1,6 @@ { "name": "mnml-client", - "version": "1.6.3", + "version": "1.6.4", "description": "", "main": "index.js", "scripts": { diff --git a/client/package.json b/client/package.json index c2b00a0b..79c60238 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "mnml-client", - "version": "1.6.3", + "version": "1.6.4", "description": "", "main": "index.js", "scripts": { diff --git a/ops/package.json b/ops/package.json index 07c68e1e..32dfed42 100755 --- a/ops/package.json +++ b/ops/package.json @@ -1,6 +1,6 @@ { "name": "mnml-ops", - "version": "1.6.3", + "version": "1.6.4", "description": "", "main": "index.js", "scripts": { diff --git a/server/Cargo.toml b/server/Cargo.toml index 80e33093..07d3812c 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mnml" -version = "1.6.3" +version = "1.6.4" authors = ["ntr "] [dependencies] From dc62b45a33a101aa6dd4a8222feacaeca2c50692 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 24 Oct 2019 18:03:58 +1100 Subject: [PATCH 9/9] changelog --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9be80477..807de0fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [1.6.3] - 2019-10-23 +## [1.6.4] - 2019-10-24 +### Changed +- Animations processing on client side reduced. +## [1.6.3] - 2019-10-23 ### Added - MNNI: the MNML guide - Delivers the message of the day