Show equipped specs

This commit is contained in:
Mashy 2019-04-03 23:14:51 +10:00
parent 0839cd5efc
commit ab78b41047
3 changed files with 36 additions and 28 deletions

View File

@ -8,13 +8,20 @@ function Info(args) {
} = args; } = args;
if (!info) return (<div className="instance-info">&nbsp;</div>); if (!info) return (<div className="instance-info">&nbsp;</div>);
if (info.type === 'item') {
return (
<div className="instance-info">
{info.value} - what does it do?
</div>
);
}
if (info.type === 'skill') { if (info.type === 'skill') {
return ( return (
<div className="instance-info"> <div className="instance-info">
<div> <div>
<div> {info.value.skill} </div> <div> {info.value.skill} </div>
<div> {SKILLS[info.value.skill].description} </div> <div> {SKILLS[info.value.skill].description} </div>
<div> {SKILLS[info.value.skill].upgrades} </div>
</div> </div>
<button onClick={() => sendUnequip(info.value.cryp.id, info.value.skill)}> <button onClick={() => sendUnequip(info.value.cryp.id, info.value.skill)}>
unequip unequip
@ -22,6 +29,20 @@ function Info(args) {
</div> </div>
); );
} }
if (info.type === 'spec') {
return (
<div className="instance-info">
<div>
<div> {info.value.spec} </div>
<div> {SPECS[info.value.spec].description} </div>
</div>
<button onClick={() => sendUnequip(info.value.cryp.id, info.value.spec)}>
unequip
</button>
</div>
);
}
if (info.type === 'cryp') { if (info.type === 'cryp') {
const stats = [ const stats = [
{ stat: 'hp', disp: 'Hp', colour: '#1FF01F' }, { stat: 'hp', disp: 'Hp', colour: '#1FF01F' },
@ -32,35 +53,16 @@ function Info(args) {
{ stat: 'green_damage', disp: 'Green Damage', colour: '#1FF01F' }, { stat: 'green_damage', disp: 'Green Damage', colour: '#1FF01F' },
{ stat: 'speed', disp: 'Speed', colour: '#FFD123' }, { stat: 'speed', disp: 'Speed', colour: '#FFD123' },
].map((s, i) => ( ].map((s, i) => (
<div key={i}>{s.disp}: {info.value[s.stat].max}</div> <div key={i}>{s.disp}: {info.value[s.stat].base} -> {info.value[s.stat].max}</div>
)); ));
const skills = info.value.skills.map((s, i) => <button key={i} onClick={() => sendUnequip(info.value.id, s.skill)}> {s.skill} </button>);
return ( return (
<div className="instance-info"> <div className="instance-info">
<h5> {info.value.name} </h5> <h5> {info.value.name} </h5>
{stats} {stats}
{skills}
</div> </div>
); );
} }
/*if (info.item) {
if (SKILLS[info.item]) {
itemDetails = SKILLS[info.item];
} else if (SPECS[info.item]) {
itemDetails = SPECS[info.item];
} else if (COLOURS[info.item]) {
itemDetails = COLOURS[info.item];
}
}*/
/* const unequip = (itemDetails && info.cryp)
? <button onClick={() => sendUnequip(info.cryp.id, info.item)}> unequip </button>
: null;
*/
} }
module.exports = Info; module.exports = Info;

View File

@ -7,7 +7,7 @@ const InfoContainer = require('./info.container');
const molecule = require('./molecule'); const molecule = require('./molecule');
const shapes = require('./shapes'); const shapes = require('./shapes');
const { STATS } = require('../utils'); const { STATS, SPECS } = require('../utils');
function Cryp(cryp, sendVboxApply, setInfo) { function Cryp(cryp, sendVboxApply, setInfo) {
const skills = range(0, 4).map(i => { const skills = range(0, 4).map(i => {
@ -29,11 +29,10 @@ function Cryp(cryp, sendVboxApply, setInfo) {
const item = parseInt(e.dataTransfer.getData('text'), 10); const item = parseInt(e.dataTransfer.getData('text'), 10);
return sendVboxApply(cryp.id, item); return sendVboxApply(cryp.id, item);
} }
const specs = cryp.specs.map((s, i) => (
const stats = Object.values(STATS).map((s, i) => ( <figure key={i} onClick={() => setInfo('spec', { spec: s, cryp })}>
<figure key={i} alt={s.stat}> {SPECS[s].svg(`stat-icon ${SPECS[s].colour}`)}
{s.svg(`stat-icon ${s.colour}`)} <figcaption>{i}</figcaption>
<figcaption>{cryp[s.stat].value}</figcaption>
</figure> </figure>
)); ));
@ -54,7 +53,7 @@ function Cryp(cryp, sendVboxApply, setInfo) {
</div> </div>
</div> </div>
<div className="stats"> <div className="stats">
{stats} {specs}
</div> </div>
</div> </div>
); );

View File

@ -64,6 +64,12 @@ const STATS = {
speed: { stat: 'speed', colour: 'yellow', svg: shapes.triangle }, speed: { stat: 'speed', colour: 'yellow', svg: shapes.triangle },
}; };
const SPECS = {
Hp: { colour: 'green', svg: shapes.square },
Damage: { colour: 'red', svg: shapes.hexagon },
Speed: { colour: 'yellow', svg: shapes.diamond },
};
module.exports = { module.exports = {
stringSort, stringSort,
numSort, numSort,
@ -71,4 +77,5 @@ module.exports = {
requestAvatar, requestAvatar,
NULL_UUID, NULL_UUID,
STATS, STATS,
SPECS,
}; };