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 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/client/src/animations.utils.jsx b/client/src/animations.utils.jsx index 38da27d5..8e2818c7 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 { @@ -7,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(); @@ -52,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 @@ -72,25 +73,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']; - 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')) { @@ -121,10 +103,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; @@ -202,14 +184,19 @@ 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 3db2ce7b..66832af9 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) { @@ -63,27 +63,26 @@ 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 (['Disable', 'TargetKo'].includes(r.event[0])) return 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); + 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); 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) { - store.dispatch(actions.setAnimTarget(anims.animTarget)); - if (!['Banish', 'Invert'].includes(removeTier(anims.animTarget.skill))) store.dispatch(actions.setAnimCb(cb)); + if (r.stages.includes('START_SKILL') && anims.animSource) { + store.dispatch(actions.setAnimSource(anims.animSource)); } - if (sequence.includes('POST_SKILL') && text) { + + 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 (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)); @@ -94,14 +93,15 @@ 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') || (anims.animSkill && ['Banish', 'Invert'].includes(anims.animSkill))) return cb(); - return true; + if (r.stages.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/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] 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 d4685c2a..75a6094d 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 })); + 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 })); + // resolutions.push(Resolution::new(source, target).event(Event::TargetKo { skill }).stages(EventStages::PostOnly)); return resolutions; } @@ -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(); } @@ -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 } @@ -1811,7 +1819,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 +1853,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 +1877,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()); @@ -2004,10 +2012,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),