const preact = require('preact'); const range = require('lodash/range'); const reactStringReplace = require('react-string-replace'); const { INFO } = require('./../constants'); const { convertItem } = require('../utils'); const shapes = require('./shapes'); function InfoComponent(args) { const { itemInfo, player, info, } = args; // args.info = 'Life'; // const { info } = args; function Info() { if (!info) { return (

VBOX phase

in this phase you strengthen and specialise your constructs by equipping items to them.

double clicking items in the VBOX will purchase and move them to your INVENTORY.

hover over an item to see its effects and combinations.
combine a SKILL or SPEC with 2 COLOURS to create an item.
combine 3 of the same item to upgrade it.
click an item and then click a construct to equip that item to it.

click the READY button on the right to progress to the GAME PHASE.

); } const fullInfo = itemInfo.items.find(i => i.item === info) || INFO[info]; if (!fullInfo) return false; const isSkill = fullInfo.skill; const isSpec = fullInfo.spec; if (isSkill) { const regEx = /(RedPower|BluePower|GreenPower|RedLife|BlueLife|GreenLife|SpeedStat)/; const infoDescription = reactStringReplace(fullInfo.description, regEx, match => shapes[match]()); return (

{fullInfo.item}

SKILL

{infoDescription}
); } if (isSpec) { let red = 0; let blue = 0; let green = 0; player.constructs.forEach(construct => { red += construct.colours.red; blue += construct.colours.blue; green += construct.colours.green; }); const teamColours = { red, blue, green }; const colourReqs = fullInfo.values.bonuses || []; const thresholds = colourReqs.map((bonus, i) => { const colours = ['red', 'green', 'blue']; const colourGoals = { red: [], green: [], blue: [], }; const overFlow = []; colours.forEach(c => { const colourReq = bonus.req[c]; if (colourReqs === 0) return false; const start = i === 0 ? 0 : colourReqs[i - 1].req[c]; const dots = range(start, colourReq).map(j => { const unmet = teamColours[c] < j + 1; const reqClass = unmet ? 'unmet' : ''; if (j - start > 4) { overFlow.push(
{shapes.vboxColour(c)}
); } else { colourGoals[c].push(
{shapes.vboxColour(c)}
); } return true; }); return dots; }); const reqsMet = colours.every(c => teamColours[c] >= bonus.req[c]); const reqClass = reqsMet ? '' : 'unmet'; const goals = colours.map((c, j) => { if (colourGoals[c].length) { return (
{colourGoals[c]}
); } return false; }); const overFlowObj = overFlow.length ?
{overFlow}
: null; return (
{goals} {overFlowObj}
+ {bonus.bonus}
); }); const regEx = /(RedPower|BluePower|GreenPower|RedLife|BlueLife|GreenLife|SpeedStat)/; const infoDescription = reactStringReplace(fullInfo.description, regEx, match => shapes[match]()); return (

{info}

SPEC

{infoDescription}
{thresholds}
); } return (

{fullInfo.item}

{fullInfo.description}
); } function Combos() { if (!player) return false; if (!info) return false; const vboxCombos = itemInfo.combos.filter(c => c.components.includes(info)); if (vboxCombos.length > 6) return false; return ( {vboxCombos.map((c, i) => {c.components.map((u, j) => )} )}
{convertItem(c.item)}{convertItem(u)}
); } return (
); } module.exports = InfoComponent;