From b1e18f68f22902980dfc47ac082b29c1ced647f1 Mon Sep 17 00:00:00 2001 From: Mashy Date: Thu, 12 Sep 2019 16:17:13 +1000 Subject: [PATCH] item description speeds --- WORKLOG.md | 2 -- client/src/components/info.component.jsx | 10 +++++++--- client/src/utils.jsx | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/WORKLOG.md b/WORKLOG.md index f8bf9347..03ff4cbc 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -20,8 +20,6 @@ * msg pane * game invites -* add speed to descriptions - ## SOON *SERVER* * modules diff --git a/client/src/components/info.component.jsx b/client/src/components/info.component.jsx index 9b0d1c6d..8de69d77 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 } = require('../utils'); +const { convertItem, removeTier, itemSpeed } = require('../utils'); const shapes = require('./shapes'); function InfoComponent(args) { @@ -40,19 +40,23 @@ function InfoComponent(args) { if (isSkill) { const regEx = /(RedPower|BluePower|GreenPower|RedLife|BlueLife|GreenLife|SpeedStat)/; const infoDescription = reactStringReplace(fullInfo.description, regEx, match => shapes[match]()); - const itemSource = itemInfo.combos.filter(c => c.item === info); + const itemSource = itemInfo.combos.filter(c => c.item === removeTier(info)); const itemSourceInfo = itemSource.length ? `${itemSource[0].components[0]} ${itemSource[0].components[1]} ${itemSource[0].components[2]}` : 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}%
; return (

{fullInfo.item}

SKILL

{itemSourceDescription}
{infoDescription}
+ {speed}
); } diff --git a/client/src/utils.jsx b/client/src/utils.jsx index b78a2b44..ab3a6f4c 100644 --- a/client/src/utils.jsx +++ b/client/src/utils.jsx @@ -187,6 +187,20 @@ 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}`, { @@ -250,5 +264,6 @@ module.exports = { TARGET_COLOURS, randomPoints, removeTier, + itemSpeed, match, };