item description speeds

This commit is contained in:
Mashy 2019-09-12 16:17:13 +10:00
parent 70e66d1916
commit b1e18f68f2
3 changed files with 22 additions and 5 deletions

View File

@ -20,8 +20,6 @@
* msg pane * msg pane
* game invites * game invites
* add speed to descriptions
## SOON ## SOON
*SERVER* *SERVER*
* modules * modules

View File

@ -3,7 +3,7 @@ const range = require('lodash/range');
const reactStringReplace = require('react-string-replace'); const reactStringReplace = require('react-string-replace');
const { INFO } = require('./../constants'); const { INFO } = require('./../constants');
const { convertItem } = require('../utils'); const { convertItem, removeTier, itemSpeed } = require('../utils');
const shapes = require('./shapes'); const shapes = require('./shapes');
function InfoComponent(args) { function InfoComponent(args) {
@ -40,19 +40,23 @@ function InfoComponent(args) {
if (isSkill) { if (isSkill) {
const regEx = /(RedPower|BluePower|GreenPower|RedLife|BlueLife|GreenLife|SpeedStat)/; const regEx = /(RedPower|BluePower|GreenPower|RedLife|BlueLife|GreenLife|SpeedStat)/;
const infoDescription = reactStringReplace(fullInfo.description, regEx, match => shapes[match]()); 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 const itemSourceInfo = itemSource.length
? `${itemSource[0].components[0]} ${itemSource[0].components[1]} ${itemSource[0].components[2]}` ? `${itemSource[0].components[0]} ${itemSource[0].components[1]} ${itemSource[0].components[2]}`
: false; : false;
const itemRegEx = /(Red|Blue|Green)/; const itemRegEx = /(Red|Blue|Green)/;
const itemSourceDescription = reactStringReplace(itemSourceInfo, itemRegEx, match => shapes[match]()); 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 = <div> Speed {shapes.SpeedStat()} multiplier {calcSpeed}% </div>;
return ( return (
<div class="info-skill"> <div class="info-skill">
<h2>{fullInfo.item}</h2> <h2>{fullInfo.item}</h2>
<h3>SKILL</h3> <h3>SKILL</h3>
{itemSourceDescription} {itemSourceDescription}
<div>{infoDescription}</div> <div>{infoDescription}</div>
{speed}
</div> </div>
); );
} }

View File

@ -187,6 +187,20 @@ const removeTier = skill => {
return 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 = {}) { function postData(url = '/', data = {}) {
// Default options are marked with * // Default options are marked with *
return fetch(`/api${url}`, { return fetch(`/api${url}`, {
@ -250,5 +264,6 @@ module.exports = {
TARGET_COLOURS, TARGET_COLOURS,
randomPoints, randomPoints,
removeTier, removeTier,
itemSpeed,
match, match,
}; };