From 2e366e2ecad6210d50624293a5d364a34fa1d92f Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 20 Sep 2019 15:34:09 +1000 Subject: [PATCH 1/2] speed fix, counter fix, client side anim fix --- client/src/events.jsx | 2 +- server/src/game.rs | 2 +- server/src/item.rs | 30 ++++++++++++++++++++++-------- server/src/skill.rs | 23 ++++++++++++----------- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/client/src/events.jsx b/client/src/events.jsx index 216af011..f088c057 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -91,7 +91,7 @@ function registerEvents(store) { store.dispatch(actions.setAnimTarget(null)); store.dispatch(actions.setAnimText(null)); store.dispatch(actions.setAnimFocus([])); - if (!sequence.includes('END_SKILL') + if (!sequence.includes('END_SKILL' && anims.animTarget) || ['Banish', 'Invert'].includes(removeTier(anims.animTarget.skill))) return cb(); return true; }, timeout); diff --git a/server/src/game.rs b/server/src/game.rs index 222ab0f6..b96d15ad 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -322,7 +322,7 @@ impl Game { return Err(err_msg("game not in skill phase")); } let mut game_state = self.clone(); - self.stack.retain(|s| game_state.construct_by_id(s.source_construct_id).unwrap().account == player_id); + self.stack.retain(|s| game_state.construct_by_id(s.source_construct_id).unwrap().account != player_id); return Ok(self); } diff --git a/server/src/item.rs b/server/src/item.rs index 6a1266c2..2242f23b 100644 --- a/server/src/item.rs +++ b/server/src/item.rs @@ -337,13 +337,27 @@ impl Item { } } - pub fn speed(&self) -> u64 { + pub fn base_speed(&self) -> u64 { match self { Item::Attack => 1, Item::Stun => 2, Item::Block => 3, Item::Buff | Item::Debuff => 4, + Item::Blue => 1, + Item::Green => 2, + Item::Red => 3, + _ => 0, + } + } + + pub fn speed(&self) -> u64 { + match self { + Item::Attack | + Item::Stun | + Item::Block | + Item::Buff | + Item::Debuff => 24 + self.base_speed(), _ => { let combos = get_combos(); let combo = combos.iter().find(|c| c.item == *self) @@ -355,17 +369,17 @@ impl Item { combo.components.iter().for_each(|unit| { colour_speed += match unit { - Item::Red => 3, - Item::Green => 2, - Item::Blue => 1, + Item::Red | + Item::Green | + Item::Blue => unit.base_speed(), _ => 0, }; skill_speed += match unit { - Item::Attack => 1, - Item::Stun => 2, - Item::Block => 3, + Item::Attack | + Item::Stun | + Item::Block | Item::Buff | - Item::Debuff => 4, + Item::Debuff => unit.base_speed(), _ => 0, }; if colour_speed == 0 && skill_speed == 0 { diff --git a/server/src/skill.rs b/server/src/skill.rs index e66ab6a4..4d5ba5d6 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -293,7 +293,7 @@ fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) -> let mut target = game.construct_by_id(target.id).unwrap().clone(); match event { - Event::Damage { amount, skill, mitigation: _, colour: _ } => { + Event::Damage { amount, skill, mitigation: _, colour: c } => { if target.affected(Effect::Electric) { let ConstructEffect { effect: _, duration: _, meta, tick: _ } = target.effects.iter() .find(|e| e.effect == Effect::Electric).unwrap().clone(); @@ -315,16 +315,17 @@ fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) -> _ => panic!("no absorb skill"), }; } - - if target.affected(Effect::Counter) { - let ConstructEffect { effect: _, duration: _, meta, tick: _ } = target.effects.iter() - .find(|e| e.effect == Effect::Counter).unwrap().clone(); - match meta { - Some(EffectMeta::Skill(s)) => { - resolutions = counter_attack(&mut target, &mut source, resolutions, s); - }, - _ => panic!("no counter skill"), - }; + if c == Colour::Red { + if target.affected(Effect::Counter) { + let ConstructEffect { effect: _, duration: _, meta, tick: _ } = target.effects.iter() + .find(|e| e.effect == Effect::Counter).unwrap().clone(); + match meta { + Some(EffectMeta::Skill(s)) => { + resolutions = counter_attack(&mut target, &mut source, resolutions, s); + }, + _ => panic!("no counter skill"), + }; + } } }, _ => (), From 67654cbbab8b49e7b453580663d2ac00e5b59094 Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 20 Sep 2019 15:40:53 +1000 Subject: [PATCH 2/2] use server calc speeds --- client/src/components/info.component.jsx | 7 ++----- client/src/utils.jsx | 14 -------------- server/src/item.rs | 5 +++++ 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/client/src/components/info.component.jsx b/client/src/components/info.component.jsx index 372de462..32b059b3 100644 --- a/client/src/components/info.component.jsx +++ b/client/src/components/info.component.jsx @@ -3,7 +3,7 @@ const range = require('lodash/range'); const reactStringReplace = require('react-string-replace'); const { INFO } = require('./../constants'); -const { convertItem, removeTier, itemSpeed } = require('../utils'); +const { convertItem, removeTier } = require('../utils'); const shapes = require('./shapes'); function InfoComponent(args) { @@ -46,10 +46,7 @@ function InfoComponent(args) { : false; const itemRegEx = /(Red|Blue|Green)/; const itemSourceDescription = reactStringReplace(itemSourceInfo, itemRegEx, match => shapes[match]()); - const calcSpeed = itemSource.length - ? (24 + (itemSpeed(itemSource[0].components[0]) + itemSpeed(itemSource[0].components[1])) * itemSpeed(itemSource[0].components[2])) * 4 - : (24 + itemSpeed(info)) * 4; - const speed =
Speed {shapes.SpeedStat()} multiplier {calcSpeed}%
; + const speed =
Speed {shapes.SpeedStat()} multiplier {fullInfo.speed * 4}%
; const cooldown = fullInfo.cooldown ? `${fullInfo.cooldown} Turn delay` : null; return (
diff --git a/client/src/utils.jsx b/client/src/utils.jsx index ab3a6f4c..b829eb94 100644 --- a/client/src/utils.jsx +++ b/client/src/utils.jsx @@ -187,20 +187,6 @@ const removeTier = skill => { return skill; }; -function itemSpeed(item) { - switch (item) { - case 'Attack': return 1; - case 'Stun': return 2; - case 'Block': return 3; - case 'Buff': return 4; - case 'Debuff': return 4; - case 'Red': return 3; - case 'Green': return 2; - case 'Blue': return 1; - default: return 0; - } -} - function postData(url = '/', data = {}) { // Default options are marked with * return fetch(`/api${url}`, { diff --git a/server/src/item.rs b/server/src/item.rs index 2242f23b..581c6b5f 100644 --- a/server/src/item.rs +++ b/server/src/item.rs @@ -1455,6 +1455,7 @@ pub struct ItemInfo { pub spec: bool, pub values: Option, pub skill: bool, + pub speed: Option, pub cooldown: Cooldown, pub description: String, } @@ -1491,6 +1492,10 @@ pub fn item_info() -> ItemInfoCtr { }, skill: v.into_skill().is_some(), description: v.into_description(), + speed: match v.into_skill() { + Some(s) => Some(s.speed()), + None => None + }, cooldown: match v.into_skill() { Some(s) => s.base_cd(), None => None