From 67654cbbab8b49e7b453580663d2ac00e5b59094 Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 20 Sep 2019 15:40:53 +1000 Subject: [PATCH] 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