what a goddamn nightmare

This commit is contained in:
ntr 2019-05-28 17:00:37 +10:00
parent 52bec725f7
commit a2b1e2d3ff
4 changed files with 72 additions and 39 deletions

View File

@ -420,19 +420,25 @@ button.equipping {
.thresholds { .thresholds {
display: flex; display: flex;
flex-flow: row-wrap; flex-flow: column;
/*align-items: center;*/ text-align: center;
}
.thresholds hr {
margin: 1em 0;
}
.colour-reqs {
display: flex;
flex-flow: row;
justify-content: space-around; justify-content: space-around;
} }
.spec-goals { .thresholds figure svg {
}
.spec-goals figure svg {
height: 2em; height: 2em;
} }
.spec-goals .unmet { .thresholds .unmet {
opacity: 0.5; opacity: 0.5;
} }

View File

@ -1,4 +1,5 @@
const preact = require('preact'); const preact = require('preact');
const { Fragment } = require('preact');
const range = require('lodash/range'); const range = require('lodash/range');
const { INFO } = require('./../constants'); const { INFO } = require('./../constants');
@ -43,16 +44,20 @@ function InfoComponent(args) {
}); });
const teamColours = { red, blue, green }; const teamColours = { red, blue, green };
const breaks = fullInfo.values; const colourReqs = fullInfo.values.bonuses || [];
const colourReqs = fullInfo.values || [];
const thresholdEl = colourReqs.map((c, i) => { const thresholds = colourReqs.map((bonus, i) => {
const numIcons = Math.max(...breaks); const colours = ['red', 'green', 'blue'];
const dots = range(0, numIcons).map(j => { const colourGoals = colours.map(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 unmet = teamColours[c] < j + 1;
const caption = breaks.includes(j + 1)
? '+ x'
: '';
const reqClass = unmet const reqClass = unmet
? 'unmet' ? 'unmet'
@ -61,24 +66,42 @@ function InfoComponent(args) {
return ( return (
<figure key={j} alt={c.colour} className={reqClass} > <figure key={j} alt={c.colour} className={reqClass} >
{COLOUR_ICONS[c].svg(`stat-icon ${COLOUR_ICONS[c].colour}`)} {COLOUR_ICONS[c].svg(`stat-icon ${COLOUR_ICONS[c].colour}`)}
<figcaption>{caption}</figcaption>
</figure> </figure>
); );
}); });
return ( return (
<div key={i} className="spec-goals"> <div key={c}>
{dots} {dots}
</div> </div>
); );
}); });
const reqsMet = colours.every(c => teamColours[c] >= bonus.req[c]);
const reqClass = reqsMet
? ''
: 'unmet';
return (
<div key={i} className="spec-goal">
<div className="colour-reqs">
{colourGoals}
</div>
<div className={reqClass}>
+ {bonus.bonus}
<hr />
</div>
</div>
);
});
return ( return (
<div className="info-spec"> <div className="info-spec">
<h2>{info}</h2> <h2>{info}</h2>
<div>{fullInfo.description}</div> <div>{fullInfo.description}</div>
<div className="thresholds"> <div className="thresholds">
{thresholdEl} {thresholds}
</div> </div>
</div> </div>
); );

View File

@ -3,7 +3,7 @@ const preact = require('preact');
const range = require('lodash/range'); const range = require('lodash/range');
const shapes = require('./shapes'); const shapes = require('./shapes');
const { SPECS, STATS, instanceConstruct } = require('../utils'); const { STATS, instanceConstruct } = require('../utils');
const actions = require('../actions'); const actions = require('../actions');
const addState = connect( const addState = connect(
@ -152,6 +152,8 @@ function Construct(props) {
); );
} }
const specInfo = itemInfo.items.find(i => i.item === s);
function specClick(e) { function specClick(e) {
e.stopPropagation(); e.stopPropagation();
setItemUnequip(s); setItemUnequip(s);
@ -174,8 +176,8 @@ function Construct(props) {
onClick={specClick} onClick={specClick}
onDblClick={specDblClick} onDblClick={specDblClick}
onMouseOver={e => hoverInfo(e, s)} > onMouseOver={e => hoverInfo(e, s)} >
{SPECS[s].svg(`stat-icon ${SPECS[s].colour}`)} {shapes[specInfo.values.shape.toLowerCase()](`stat-icon ${specInfo.values.colour}`)}
<figcaption>{SPECS[s].caption}</figcaption> <figcaption>{s}</figcaption>
</figure> </figure>
); );
}); });

View File

@ -64,9 +64,11 @@ function Equipment(props) {
const isSkill = fullInfo && fullInfo.skill; const isSkill = fullInfo && fullInfo.skill;
const isSpec = fullInfo && fullInfo.spec; const isSpec = fullInfo && fullInfo.spec;
console.log('isSkill', isSkill, fullInfo);
function skillClick(e, i) { function skillClick(e, i) {
if (itemUnequip && activeConstruct) return false; if (itemUnequip && activeConstruct) return false;
const value = vbox.bound[i]; // const value = vbox.bound[i];
setItemEquip(i); setItemEquip(i);
return false; return false;
} }
@ -87,31 +89,31 @@ function Equipment(props) {
const skillClass = isSkill ? 'skills highlight' : 'skills'; const skillClass = isSkill ? 'skills highlight' : 'skills';
const specClass = isSpec ? 'specs highlight' : 'specs'; const specClass = isSpec ? 'specs highlight' : 'specs';
const skillList = itemInfo.items.filter(v => v.skill).map(v => v.item);
const specList = itemInfo.items.filter(v => v.spec).map(v => v.item);
const skills = range(0, 9).map(i => { const skills = range(0, 9).map(i => {
const item = convertItem(vbox.bound[i]); const item = convertItem(vbox.bound[i]);
if (skillList.includes(item)) { const skillInfo = itemInfo.items.find(i => i.item === item);
if (skillInfo && skillInfo.skill) {
return ( return (
<button key={i} onClick={e => skillClick(e, i)} onMouseOver={e => hoverInfo(e, item)}> <button key={i} onClick={e => skillClick(e, i)} onMouseOver={e => hoverInfo(e, item)}>
{item} {item}
</button> </button>
); );
} return false; }
return false;
}); });
const specs = range(0, 9).map(i => { const specs = range(0, 9).map(i => {
const item = convertItem(vbox.bound[i]); const item = convertItem(vbox.bound[i]);
const fullInfo = itemInfo.items.find(i => i.item === item); const specInfo = itemInfo.items.find(i => i.item === item);
if (fullInfo.spec) { if (specInfo && specInfo.spec) {
return ( return (
<figure key={i} onClick={e => skillClick(e, i)} onMouseOver={e => hoverInfo(e, item)} > <figure key={i} onClick={e => skillClick(e, i)} onMouseOver={e => hoverInfo(e, item)} >
{shapes[fullInfo.values.shape.toLowerCase()](`stat-icon ${itemInfo[item].colour}`)} {shapes[specInfo.values.shape.toLowerCase()](`stat-icon ${specInfo.values.colour}`)}
<figcaption>{item}</figcaption> <figcaption>{item}</figcaption>
</figure> </figure>
); );
} return false; }
return false;
}); });
if (skills.every(s => !s)) skills.push(<button disabled={true}>&nbsp;</button>); if (skills.every(s => !s)) skills.push(<button disabled={true}>&nbsp;</button>);