Merge branch 'skilltiers'

This commit is contained in:
ntr 2019-05-28 18:32:18 +10:00
commit 50440a5452
17 changed files with 682 additions and 579 deletions

View File

@ -33,6 +33,9 @@
## NOW ## NOW
*CLIENT* *CLIENT*
* fix mobile menu
* make fullscreen
* disappear on touch
*SERVER* *SERVER*

View File

@ -289,14 +289,8 @@
margin: 0 1em; margin: 0 1em;
} }
.equip-icon { .icons figure {
height: 2em; flex: 1;
stroke-width: 5px;
fill: none;
}
.construct-list .stat-icon {
width: 100%;
} }
.construct-list .stats .damage-label { .construct-list .stats .damage-label {
@ -420,19 +414,29 @@ button.equipping {
.thresholds { .thresholds {
display: flex; display: flex;
flex-flow: row-wrap; flex-flow: column;
/*align-items: center;*/ text-align: center;
}
.thresholds svg {
stroke-width: 5px;
}
.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

@ -475,7 +475,7 @@ figure.gray {
stroke-color: #333; stroke-color: #333;
} }
.stat-icon { .stats svg, .specs svg {
height: 2em; height: 2em;
stroke-width: 5px; stroke-width: 5px;
fill: none; fill: none;

View File

@ -1,7 +1,8 @@
const preact = require('preact'); const preact = require('preact');
const { STATS, eventClasses, getCombatText, constructAvatar } = require('../utils'); const { STATS, eventClasses, getCombatText, constructAvatar } = require('../utils');
const { animationDivs } = require('../animations'); // const { animationDivs } = require('../animations');
const GameConstruct = require('./game.construct'); const GameConstruct = require('./game.construct');
const shapes = require('./shapes');
function GamePanel(props) { function GamePanel(props) {
const { const {
@ -121,11 +122,11 @@ function GamePanel(props) {
const ko = construct.green_life.value === 0 ? 'ko' : ''; const ko = construct.green_life.value === 0 ? 'ko' : '';
const classes = eventClasses(resolution, construct); const classes = eventClasses(resolution, construct);
const stats = [STATS.redLife, STATS.greenLife, STATS.blueLife].map((s, j) => ( const stats = ['RedLife', 'GreenLife', 'BlueLife'].map((s, j) => (
<div key={j} alt={s.stat}> <div key={j} alt={STATS[s].stat}>
{s.svg(`stat-icon ${s.colour}`)} {shapes[s]()}
<div className="max" >{construct[s.stat].value} / {construct[s.stat].max}</div> <div className="max" >{construct[STATS[s].stat].value} / {construct[STATS[s].stat].max}</div>
<div className="value" >{construct[s.stat].value}</div> <div className="value" >{construct[STATS[s].stat].value}</div>
</div> </div>
)); ));

View File

@ -5,6 +5,7 @@ const range = require('lodash/range');
const actions = require('../actions'); const actions = require('../actions');
const { STATS, eventClasses, getCombatText, constructAvatar } = require('../utils'); const { STATS, eventClasses, getCombatText, constructAvatar } = require('../utils');
const { animationDivs } = require('../animations'); const { animationDivs } = require('../animations');
const shapes = require('./shapes');
const SkillBtn = require('./skill.btn'); const SkillBtn = require('./skill.btn');
@ -57,11 +58,11 @@ function GameConstruct(props) {
const skills = range(0, 3) const skills = range(0, 3)
.map(i => <SkillBtn key={i} construct={construct} i={i} />); .map(i => <SkillBtn key={i} construct={construct} i={i} />);
const stats = [STATS.redLife, STATS.greenLife, STATS.blueLife].map((s, j) => ( const stats = ['RedLife', 'GreenLife', 'BlueLife'].map((s, j) => (
<div key={j} alt={s.stat}> <div key={j} alt={STATS[s].stat}>
{s.svg(`stat-icon ${s.colour}`)} {shapes[s]()}
<div className="max" >{construct[s.stat].value} / {construct[s.stat].max}</div> <div className="max" >{construct[STATS[s].stat].value} / {construct[STATS[s].stat].max}</div>
<div className="value" >{construct[s.stat].value}</div> <div className="value" >{construct[STATS[s].stat].value}</div>
</div> </div>
)); ));

View File

@ -2,10 +2,10 @@ const preact = require('preact');
const range = require('lodash/range'); const range = require('lodash/range');
const { INFO } = require('./../constants'); const { INFO } = require('./../constants');
const { SPECS } = require('./../utils'); const { convertItem } = require('../utils');
const { COLOUR_ICONS, convertItem } = require('../utils'); const shapes = require('./shapes');
function Info(args) { function InfoComponent(args) {
const { const {
info, info,
itemInfo, itemInfo,
@ -24,16 +24,6 @@ function Info(args) {
const isSkill = fullInfo.skill; const isSkill = fullInfo.skill;
const isSpec = fullInfo.spec; const isSpec = fullInfo.spec;
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 };
if (isSkill) { if (isSkill) {
return ( return (
<div className="info-skill"> <div className="info-skill">
@ -44,16 +34,30 @@ function Info(args) {
} }
if (isSpec) { if (isSpec) {
const breaks = SPECS[info].thresholds; let red = 0;
const colourReqs = SPECS[info].colours || []; 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 thresholdEl = colourReqs.map((c, i) => { const colourReqs = fullInfo.values.bonuses || [];
const numIcons = Math.max(...breaks);
const dots = range(0, numIcons).map(j => { const thresholds = colourReqs.map((bonus, i) => {
const colours = ['red', 'green', 'blue'];
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,25 +65,43 @@ function Info(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}`)} {shapes.square([c])}
<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>
); );
@ -142,4 +164,4 @@ function Info(args) {
); );
} }
module.exports = Info; module.exports = InfoComponent;

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(
@ -146,12 +146,14 @@ function Construct(props) {
const equip = specList.includes(vbox.bound[itemEquip]) ? 'equip-spec' : 'gray'; const equip = specList.includes(vbox.bound[itemEquip]) ? 'equip-spec' : 'gray';
return ( return (
<figure key={i} className={equip} > <figure key={i} className={equip} >
{shapes.diamond(`stat-icon ${equip}`)} {shapes.diamond(equip)}
<figcaption>&nbsp;</figcaption> <figcaption>&nbsp;</figcaption>
</figure> </figure>
); );
} }
const specInfo = itemInfo.items.find(i => i.item === s);
function specClick(e) { function specClick(e) {
e.stopPropagation(); e.stopPropagation();
setItemUnequip(s); setItemUnequip(s);
@ -174,35 +176,23 @@ 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[s]()}
<figcaption>{SPECS[s].caption}</figcaption> <figcaption>{s}</figcaption>
</figure> </figure>
); );
}); });
const stats = Object.values(STATS).map(s => ( const stats = Object.keys(STATS).map(s => {
<figure key={s.stat} alt={s.stat} className={s.stat}> const stat = STATS[s];
{s.svg(`stat-icon ${s.colour} stat`)} return <figure key={stat.stat} alt={stat.stat} className={stat.stat}>
<figcaption>{construct[s.stat].value}</figcaption> {shapes[s]()}
</figure> <figcaption>{construct[stat.stat].value}</figcaption>
)); </figure>;
});
const activeId = activeConstruct ? activeConstruct.id : false; const activeId = activeConstruct ? activeConstruct.id : false;
const constructClass = activeId === construct.id ? 'instance-construct-active' : 'instance-construct'; const constructClass = activeId === construct.id ? 'instance-construct-active' : 'instance-construct';
// const cTotal = construct.colours.red + construct.colours.blue + construct.colours.green;
// const colours = mapValues(construct.colours, c => {
// if (cTotal === 0) return 245;
// return Math.floor(c / cTotal * 255);
// });
// const alpha = cTotal === 0 ? 1 : 0.75;
// const thickness = total => {
// if (total < 3) return 1;
// if (total < 6) return 2;
// if (total < 9) return 3;
// return 4;
// };
// const border = { border: `${thickness(cTotal)}px solid rgba(${colours.red}, ${colours.green}, ${colours.blue}, ${alpha})` };
return ( return (
<div key={construct.id} className={constructClass} onClick={onClick} > <div key={construct.id} className={constructClass} onClick={onClick} >
{instanceConstruct(construct.name, construct.id)} {instanceConstruct(construct.name, construct.id)}

View File

@ -4,7 +4,7 @@ const range = require('lodash/range');
const actions = require('../actions'); const actions = require('../actions');
const shapes = require('./shapes'); const shapes = require('./shapes');
const { convertItem, SPECS } = require('./../utils'); const { convertItem } = require('./../utils');
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
@ -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,37 +89,38 @@ 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]);
if (specList.includes(item)) { const specInfo = itemInfo.items.find(i => i.item === item);
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)} >
{SPECS[item].svg(`stat-icon ${SPECS[item].colour}`)} {shapes[item]()}
<figcaption>{SPECS[item].caption}</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>);
if (specs.every(s => !s)) { if (specs.every(s => !s)) {
specs.push( specs.push(
<figure> <figure>
{shapes.diamond('stat-icon gray')} {shapes.diamond('gray')}
<figcaption>&nbsp;</figcaption> <figcaption>&nbsp;</figcaption>
</figure> </figure>
); );

View File

@ -18,4 +18,43 @@ module.exports = {
triangle, triangle,
saw, saw,
vboxColour, vboxColour,
// stats
RedLife: () => square(['red']),
GreenLife: () => square(['green']),
BlueLife: () => square(['blue']),
RedPower: () => circle(['red']),
GreenPower: () => circle(['green']),
BluePower: () => circle(['blue']),
Speed: () => triangle(['white']),
// specs
// Base
Power: () => circle(['white']),
Life: () => square(['white']),
// Speed,
// Lifes Upgrades
LifeGGI: () => square(['green']),
LifeRRI: () => square(['red']),
LifeBBI: () => square(['blue']),
LifeRGI: () => square(['red', 'green']),
LifeGBI: () => square(['green', 'blue']),
LifeRBI: () => square(['red', 'blue']),
// Power Upgrades
PowerGGI: () => circle(['green']),
PowerRRI: () => circle(['red']),
PowerBBI: () => circle(['blue']),
PowerRGI: () => circle(['red', 'green']),
PowerGBI: () => circle(['green', 'blue']),
PowerRBI: () => circle(['red', 'blue']),
// Speed Upgrades
SpeedGGI: () => triangle(['green']),
SpeedRRI: () => triangle(['red']),
SpeedBBI: () => triangle(['blue']),
SpeedRGI: () => triangle(['red', 'green']),
SpeedGBI: () => triangle(['green', 'blue']),
SpeedRBI: () => triangle(['red', 'blue']),
}; };

View File

@ -1,20 +1,38 @@
const preact = require('preact'); const preact = require('preact');
module.exports = function triangle(classes) { module.exports = function circle(colours) {
if (colours.length === 1) {
return ( return (
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 198.13 199.94" >
viewBox="0 0 198.13 199.94" style="enable-background:new 0 0 198.13 199.94;" className={classes} > <ellipse class={colours[0]} cx="99.07" cy="99.97" rx="97.6" ry="98.5"/>
<g> <path class={colours[0]} d="M99.07,177.35c-42.28,0-76.67-34.71-76.67-77.38s34.4-77.38,76.67-77.38c42.28,0,76.67,34.71,76.67,77.38 S141.34,177.35,99.07,177.35z"/>
<ellipse class="st2" cx="99.07" cy="99.97" rx="97.6" ry="98.5"/> <path class={colours[0]} d="M99.07,156.23c-30.74,0-55.75-25.24-55.75-56.26S68.33,43.7,99.07,43.7s55.75,25.24,55.75,56.26 S129.81,156.23,99.07,156.23z"/>
<path class="st2" d="M99.07,177.35c-42.28,0-76.67-34.71-76.67-77.38s34.4-77.38,76.67-77.38c42.28,0,76.67,34.71,76.67,77.38 <path class={colours[0]} d="M99.07,135.11c-19.2,0-34.82-15.77-34.82-35.15s15.62-35.15,34.82-35.15c19.2,0,34.83,15.77,34.83,35.15 S118.27,135.11,99.07,135.11z"/>
S141.34,177.35,99.07,177.35z"/> <path class={colours[0]} d="M99.07,114c-7.66,0-13.9-6.29-13.9-14.03s6.23-14.03,13.9-14.03s13.9,6.29,13.9,14.03S106.73,114,99.07,114z"/>
<path class="st2" d="M99.07,156.23c-30.74,0-55.75-25.24-55.75-56.26S68.33,43.7,99.07,43.7s55.75,25.24,55.75,56.26 </svg>
S129.81,156.23,99.07,156.23z"/> );
<path class="st2" d="M99.07,135.11c-19.2,0-34.82-15.77-34.82-35.15s15.62-35.15,34.82-35.15c19.2,0,34.83,15.77,34.83,35.15 }
S118.27,135.11,99.07,135.11z"/>
<path class="st2" d="M99.07,114c-7.66,0-13.9-6.29-13.9-14.03s6.23-14.03,13.9-14.03s13.9,6.29,13.9,14.03S106.73,114,99.07,114z" return (
/> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 198.13 199.94" >
</g> <clipPath id="firstColour">
<rect x="0" y="0" width="100" height="200" />
</clipPath>
<clipPath id="secondColour">
<rect x="100" y="0" width="100" height="200" />
</clipPath>
<ellipse clip-path="url(#firstColour)" class={colours[0]} cx="99.07" cy="99.97" rx="97.6" ry="98.5"/>
<path clip-path="url(#firstColour)" class={colours[0]} d="M99.07,177.35c-42.28,0-76.67-34.71-76.67-77.38s34.4-77.38,76.67-77.38c42.28,0,76.67,34.71,76.67,77.38 S141.34,177.35,99.07,177.35z"/>
<path clip-path="url(#firstColour)" class={colours[0]} d="M99.07,156.23c-30.74,0-55.75-25.24-55.75-56.26S68.33,43.7,99.07,43.7s55.75,25.24,55.75,56.26 S129.81,156.23,99.07,156.23z"/>
<path clip-path="url(#firstColour)" class={colours[0]} d="M99.07,135.11c-19.2,0-34.82-15.77-34.82-35.15s15.62-35.15,34.82-35.15c19.2,0,34.83,15.77,34.83,35.15 S118.27,135.11,99.07,135.11z"/>
<path clip-path="url(#firstColour)" class={colours[0]} d="M99.07,114c-7.66,0-13.9-6.29-13.9-14.03s6.23-14.03,13.9-14.03s13.9,6.29,13.9,14.03S106.73,114,99.07,114z"/>
<ellipse clip-path="url(#secondColour)" class={colours[1]} cx="99.07" cy="99.97" rx="97.6" ry="98.5"/>
<path clip-path="url(#secondColour)" class={colours[1]} d="M99.07,177.35c-42.28,0-76.67-34.71-76.67-77.38s34.4-77.38,76.67-77.38c42.28,0,76.67,34.71,76.67,77.38 S141.34,177.35,99.07,177.35z"/>
<path clip-path="url(#secondColour)" class={colours[1]} d="M99.07,156.23c-30.74,0-55.75-25.24-55.75-56.26S68.33,43.7,99.07,43.7s55.75,25.24,55.75,56.26 S129.81,156.23,99.07,156.23z"/>
<path clip-path="url(#secondColour)" class={colours[1]} d="M99.07,135.11c-19.2,0-34.82-15.77-34.82-35.15s15.62-35.15,34.82-35.15c19.2,0,34.83,15.77,34.83,35.15 S118.27,135.11,99.07,135.11z"/>
<path clip-path="url(#secondColour)" class={colours[1]} d="M99.07,114c-7.66,0-13.9-6.29-13.9-14.03s6.23-14.03,13.9-14.03s13.9,6.29,13.9,14.03S106.73,114,99.07,114z"/>
</svg> </svg>
); );
}; };

View File

@ -1,14 +1,40 @@
const preact = require('preact'); const preact = require('preact');
module.exports = function triangle(classes) { module.exports = function square(colours) {
if (colours.length === 1) {
return ( return (
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
viewBox="0 0 199.33 199.99" style="enable-background:new 0 0 199.33 199.99;" className={classes} > viewBox="0 0 199.33 199.99" >
<rect x="1.47" y="1.47" class="st0" width="196.39" height="197.05"/> <rect x="1.47" y="1.47" class={colours[0]} width="196.39" height="197.05"/>
<rect x="21.63" y="22.22" transform="matrix(-1.836970e-16 1 -1 -1.836970e-16 199.6583 0.3317)" class="st0" width="156.07" height="155.55"/> <rect x="21.63" y="22.22" class={colours[0]} width="156.07" height="155.55"/>
<rect x="42.12" y="42.64" transform="matrix(-1.836970e-16 1 -1 -1.836970e-16 199.6583 0.3317)" class="st0" width="115.09" height="114.71"/> <rect x="42.12" y="42.64" class={colours[0]} width="115.09" height="114.71"/>
<rect x="62.61" y="63.06" transform="matrix(-1.836970e-16 1 -1 -1.836970e-16 199.6583 0.3317)" class="st0" width="74.11" height="73.86"/> <rect x="62.61" y="63.06" class={colours[0]} width="74.11" height="73.86"/>
<rect x="83.1" y="83.48" transform="matrix(-1.836970e-16 1 -1 -1.836970e-16 199.6578 0.3322)" class="st0" width="33.13" height="33.02"/> <rect x="83.1" y="83.48" class={colours[0]} width="33.13" height="33.02"/>
</svg>
);
}
return (
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
viewBox="0 0 199.33 199.99" >
<clipPath id="firstColour">
<rect x="0" y="0" width="100" height="200" />
</clipPath>
<clipPath id="secondColour">
<rect x="100" y="0" width="100" height="200" />
</clipPath>
<rect clip-path="url(#firstColour)" x="1.47" y="1.47" class={colours[0]} width="196.39" height="197.05"/>
<rect clip-path="url(#firstColour)" x="21.63" y="22.22" class={colours[0]} width="156.07" height="155.55"/>
<rect clip-path="url(#firstColour)" x="42.12" y="42.64" class={colours[0]} width="115.09" height="114.71"/>
<rect clip-path="url(#firstColour)" x="62.61" y="63.06" class={colours[0]} width="74.11" height="73.86"/>
<rect clip-path="url(#firstColour)" x="83.1" y="83.48" class={colours[0]} width="33.13" height="33.02"/>
<rect clip-path="url(#secondColour)" x="1.47" y="1.47" class={colours[1]} width="196.39" height="197.05"/>
<rect clip-path="url(#secondColour)" x="21.63" y="22.22" class={colours[1]} width="156.07" height="155.55"/>
<rect clip-path="url(#secondColour)" x="42.12" y="42.64" class={colours[1]} width="115.09" height="114.71"/>
<rect clip-path="url(#secondColour)" x="62.61" y="63.06" class={colours[1]} width="74.11" height="73.86"/>
<rect clip-path="url(#secondColour)" x="83.1" y="83.48" class={colours[1]} width="33.13" height="33.02"/>
</svg> </svg>
); );
} }

View File

@ -1,16 +1,38 @@
const preact = require('preact'); const preact = require('preact');
module.exports = function triangle(classes) { module.exports = function triangle(colours) {
if (colours.length === 1) {
return ( return (
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 202.69 177.29" >
viewBox="0 0 202.69 177.29" style="enable-background:new 0 0 202.69 177.29;" className={classes}> <polygon class={colours[0]} points="1.77,176.25 100.7,2.08 200.9,176.25 "/>
<g> <polygon class={colours[0]} points="23.99,163.23 100.78,28.05 178.54,163.23 "/>
<polygon class="st1" points="1.77,176.25 100.7,2.08 200.9,176.25 "/> <polygon class={colours[0]} points="46.21,150.21 100.85,54.03 156.18,150.21 "/>
<polygon class="st1" points="23.99,163.23 100.78,28.05 178.54,163.23 "/> <polygon class={colours[0]} points="68.43,137.19 100.92,80 133.82,137.19 "/>
<polygon class="st1" points="46.21,150.21 100.85,54.03 156.18,150.21 "/> <polygon class={colours[0]} points="90.65,124.17 100.99,105.98 111.46,124.17 "/>
<polygon class="st1" points="68.43,137.19 100.92,80 133.82,137.19 "/>
<polygon class="st1" points="90.65,124.17 100.99,105.98 111.46,124.17 "/>
</g>
</svg> </svg>
); );
} }
return (
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 202.69 177.29" >
<clipPath id="firstColour">
<rect x="0" y="0" width="100" height="200" />
</clipPath>
<clipPath id="secondColour">
<rect x="100" y="0" width="100" height="200" />
</clipPath>
<polygon clip-path="url(#firstColour)" class={colours[0]} points="1.77,176.25 100.7,2.08 200.9,176.25 "/>
<polygon clip-path="url(#firstColour)" class={colours[0]} points="23.99,163.23 100.78,28.05 178.54,163.23 "/>
<polygon clip-path="url(#firstColour)" class={colours[0]} points="46.21,150.21 100.85,54.03 156.18,150.21 "/>
<polygon clip-path="url(#firstColour)" class={colours[0]} points="68.43,137.19 100.92,80 133.82,137.19 "/>
<polygon clip-path="url(#firstColour)" class={colours[0]} points="90.65,124.17 100.99,105.98 111.46,124.17 "/>
<polygon clip-path="url(#secondColour)" class={colours[1]} points="1.77,176.25 100.7,2.08 200.9,176.25 "/>
<polygon clip-path="url(#secondColour)" class={colours[1]} points="23.99,163.23 100.78,28.05 178.54,163.23 "/>
<polygon clip-path="url(#secondColour)" class={colours[1]} points="46.21,150.21 100.85,54.03 156.18,150.21 "/>
<polygon clip-path="url(#secondColour)" class={colours[1]} points="68.43,137.19 100.92,80 133.82,137.19 "/>
<polygon clip-path="url(#secondColour)" class={colours[1]} points="90.65,124.17 100.99,105.98 111.46,124.17 "/>
</svg>
);
};

View File

@ -300,15 +300,15 @@ function createSocket(events) {
position: 'bottomCenter', position: 'bottomCenter',
}); });
sendPing();
sendItemInfo();
if (account) { if (account) {
events.setAccount(account); events.setAccount(account);
sendAccountInstances(); sendAccountInstances();
sendAccountConstructs(); sendAccountConstructs();
setTimeout(sendItemInfo, 2000);
} }
sendPing();
return true; return true;
}); });

View File

@ -130,178 +130,43 @@ function gameConstructImg(name, id, combatTextEl, selectSkillTarget) {
const NULL_UUID = '00000000-0000-0000-0000-000000000000'; const NULL_UUID = '00000000-0000-0000-0000-000000000000';
const STATS = { const STATS = {
redPower: { RedPower: {
stat: 'red_power', stat: 'red_power',
colour: 'red', colour: 'red',
svg: shapes.circle, svg: shapes.circle,
}, },
greenPower: { GreenPower: {
stat: 'green_power', stat: 'green_power',
colour: 'green', colour: 'green',
svg: shapes.circle, svg: shapes.circle,
}, },
bluePower: { BluePower: {
stat: 'blue_power', stat: 'blue_power',
colour: 'blue', colour: 'blue',
svg: shapes.circle, svg: shapes.circle,
}, },
speed: { Speed: {
stat: 'speed', stat: 'speed',
colour: 'white', colour: 'white',
svg: shapes.triangle, svg: shapes.triangle,
}, },
redLife: { RedLife: {
stat: 'red_life', stat: 'red_life',
colour: 'red', colour: 'red',
svg: shapes.square, svg: shapes.square,
}, },
greenLife: { GreenLife: {
stat: 'green_life', stat: 'green_life',
colour: 'green', colour: 'green',
svg: shapes.square, svg: shapes.square,
}, },
blueLife: { BlueLife: {
stat: 'blue_life', stat: 'blue_life',
colour: 'blue', colour: 'blue',
svg: shapes.square, svg: shapes.square,
}, },
}; };
const SPECS = {
Life: {
colour: 'white',
caption: 'Life',
svg: shapes.square
},
GreenLifeI: {
colour: 'green',
caption: 'Life',
thresholds: [5, 10, 20],
svg: shapes.square,
},
RedLifeI: {
colour: 'red',
caption: 'Life',
thresholds: [2, 5, 10],
svg: shapes.square,
},
BlueLifeI: {
colour: 'blue',
caption: 'Life',
thresholds: [2, 5, 10],
svg: shapes.square,
},
GRLI: {
colour: 'yellow',
caption: 'Life',
thresholds: [2, 5, 10],
svg: shapes.square
},
GBLI: {
colour: 'cyan',
caption: 'Life',
thresholds: [2, 5, 10],
svg: shapes.square
},
RBLI: {
colour: 'purple',
caption: 'Life',
thresholds: [2, 5, 10],
svg: shapes.square
},
Power: {
colour: 'white',
caption: 'Power',
thresholds: [],
svg: shapes.circle
},
RedPowerI: {
colour: 'red',
caption: 'PowerI',
thresholds: [5, 10, 20],
svg: shapes.circle
},
BluePowerI: {
colour: 'blue',
caption: 'PowerI',
thresholds: [5, 10, 20],
svg: shapes.circle
},
GreenPowerI: {
colour: 'green',
caption: 'PowerI',
thresholds: [5, 10, 20],
svg: shapes.circle,
},
GRDI: {
colour: 'yellow',
caption: 'PowerI',
thresholds: [2, 5, 10],
svg: shapes.circle
},
GBDI: {
colour: 'cyan',
caption: 'PowerI',
thresholds: [2, 5, 10],
svg: shapes.circle,
},
RBDI: {
colour: 'purple',
caption: 'PowerI',
thresholds: [2, 5, 10],
svg: shapes.circle,
},
Speed: {
colour: 'white',
caption: 'Speed',
svg: shapes.triangle,
},
RedSpeedI: {
colour: 'red',
caption: 'Speed',
thresholds: [5, 10, 20],
svg: shapes.triangle,
},
BlueSpeedI: {
colour: 'blue',
caption: 'Speed',
thresholds: [2, 5, 10],
svg: shapes.triangle,
},
GreenSpeedI: {
colour: 'green',
caption: 'Speed',
thresholds: [2, 5, 10],
svg: shapes.triangle,
},
GRSpeedI: {
colour: 'yellow',
caption: 'Speed',
thresholds: [2, 5, 10],
svg: shapes.triangle,
},
GBSpeedI: {
colour: 'cyan',
caption: 'Speed',
thresholds: [2, 5, 10],
svg: shapes.triangle,
},
RBSpeedI: {
colour: 'purple',
caption: 'Speed',
thresholds: [2, 5, 10],
svg: shapes.triangle,
},
};
const COLOUR_ICONS = {
red: { colour: 'red', caption: 'red', svg: shapes.square },
blue: { colour: 'blue', caption: 'blue', svg: shapes.square },
green: { colour: 'green', caption: 'green', svg: shapes.square },
};
function resoConstructHealth(resolution, currentGame) { function resoConstructHealth(resolution, currentGame) {
if (!resolution) return false; if (!resolution) return false;
@ -599,6 +464,4 @@ module.exports = {
resoConstructHealth, resoConstructHealth,
NULL_UUID, NULL_UUID,
STATS, STATS,
SPECS,
COLOUR_ICONS,
}; };

View File

@ -876,10 +876,10 @@ mod tests {
.named(&"redboi".to_string()); .named(&"redboi".to_string());
construct.learn_mut(Skill::StrikeI); construct.learn_mut(Skill::StrikeI);
construct.spec_add(Spec::GreenLifeI).unwrap(); construct.spec_add(Spec::LifeGGI).unwrap();
construct.spec_add(Spec::RedPowerI).unwrap(); construct.spec_add(Spec::PowerRRI).unwrap();
construct.spec_add(Spec::RedPowerI).unwrap(); construct.spec_add(Spec::PowerRRI).unwrap();
construct.spec_add(Spec::BlueLifeI).unwrap(); construct.spec_add(Spec::LifeBBI).unwrap();
assert_eq!(construct.colours.red, 6); assert_eq!(construct.colours.red, 6);
assert_eq!(construct.colours.green, 2); assert_eq!(construct.colours.green, 2);
@ -893,9 +893,9 @@ mod tests {
let mut construct = Construct::new() let mut construct = Construct::new()
.named(&"player player".to_string()); .named(&"player player".to_string());
construct.spec_add(Spec::RedPowerI).unwrap(); construct.spec_add(Spec::PowerRRI).unwrap();
construct.spec_add(Spec::GreenPowerI).unwrap(); construct.spec_add(Spec::PowerGGI).unwrap();
construct.spec_add(Spec::BluePowerI).unwrap(); construct.spec_add(Spec::PowerBBI).unwrap();
let player_colours = Colours { let player_colours = Colours {
red: 5, red: 5,

View File

@ -1,5 +1,5 @@
use skill::{Skill, Colour}; use skill::{Skill, Colour};
use spec::{Spec}; use spec::{Spec, SpecValues};
use construct::{Colours}; use construct::{Colours};
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)] #[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
@ -23,28 +23,28 @@ pub enum Item {
Speed, Speed,
// Lifes Upgrades // Lifes Upgrades
GreenLifeI, LifeGGI,
RedLifeI, LifeRRI,
BlueLifeI, LifeBBI,
GRLI, LifeRGI,
GBLI, LifeGBI,
RBLI, LifeRBI,
// Power Upgrades // Power Upgrades
RedPowerI, PowerRRI,
BluePowerI, PowerBBI,
GreenPowerI, PowerGGI,
GRDI, PowerRGI,
GBDI, PowerGBI,
RBDI, PowerRBI,
// Speed Upgrades // Speed Upgrades
RedSpeedI, SpeedRRI,
BlueSpeedI, SpeedBBI,
GreenSpeedI, SpeedGGI,
GRSpeedI, SpeedRGI,
GBSpeedI, SpeedGBI,
RBSpeedI, SpeedRBI,
AmplifyI, AmplifyI,
AmplifyII, AmplifyII,
@ -347,28 +347,28 @@ impl Item {
pub fn into_spec(&self) -> Option<Spec> { pub fn into_spec(&self) -> Option<Spec> {
match *self { match *self {
Item::Speed => Some(Spec::Speed), Item::Speed => Some(Spec::Speed),
Item::RedSpeedI => Some(Spec::RedSpeedI), Item::SpeedRRI => Some(Spec::SpeedRRI),
Item::BlueSpeedI => Some(Spec::BlueSpeedI), Item::SpeedBBI => Some(Spec::SpeedBBI),
Item::GreenSpeedI => Some(Spec::GreenSpeedI), Item::SpeedGGI => Some(Spec::SpeedGGI),
Item::GRSpeedI => Some(Spec::GRSpeedI), Item::SpeedRGI => Some(Spec::SpeedRGI),
Item::GBSpeedI => Some(Spec::GBSpeedI), Item::SpeedGBI => Some(Spec::SpeedGBI),
Item::RBSpeedI => Some(Spec::RBSpeedI), Item::SpeedRBI => Some(Spec::SpeedRBI),
Item::Power => Some(Spec::Power), Item::Power => Some(Spec::Power),
Item::RedPowerI => Some(Spec::RedPowerI), Item::PowerRRI => Some(Spec::PowerRRI),
Item::BluePowerI => Some(Spec::BluePowerI), Item::PowerBBI => Some(Spec::PowerBBI),
Item::GreenPowerI => Some(Spec::GreenPowerI), Item::PowerGGI => Some(Spec::PowerGGI),
Item::GRDI => Some(Spec::GRDI), Item::PowerRGI => Some(Spec::PowerRGI),
Item::GBDI => Some(Spec::GBDI), Item::PowerGBI => Some(Spec::PowerGBI),
Item::RBDI => Some(Spec::RBDI), Item::PowerRBI => Some(Spec::PowerRBI),
Item::Life => Some(Spec::Life), Item::Life => Some(Spec::Life),
Item::GRLI => Some(Spec::GRLI), Item::LifeRGI => Some(Spec::LifeRGI),
Item::GBLI => Some(Spec::GBLI), Item::LifeGBI => Some(Spec::LifeGBI),
Item::RBLI => Some(Spec::RBLI), Item::LifeRBI => Some(Spec::LifeRBI),
Item::GreenLifeI => Some(Spec::GreenLifeI), Item::LifeGGI => Some(Spec::LifeGGI),
Item::RedLifeI => Some(Spec::RedLifeI), Item::LifeRRI => Some(Spec::LifeRRI),
Item::BlueLifeI => Some(Spec::BlueLifeI), Item::LifeBBI => Some(Spec::LifeBBI),
_ => None, _ => None,
} }
@ -412,31 +412,31 @@ impl Item {
SPEED determines the order in which skills resolve."), SPEED determines the order in which skills resolve."),
// Lifes Upgrades // Lifes Upgrades
Item::GreenLifeI => format!("Increases CONSTRUCT GreenLife. Item::LifeGGI => format!("Increases CONSTRUCT GreenLife.
When your CONSTRUCT reaches 0 GreenLife it becomes KO and cannot cast SKILLS."), When your CONSTRUCT reaches 0 GreenLife it becomes KO and cannot cast SKILLS."),
Item::RedLifeI => format!("Increases CONSTRUCT RedLife. Item::LifeRRI => format!("Increases CONSTRUCT RedLife.
RedDamage dealt to your construct reduces RedLife before GreenLife."), RedDamage dealt to your construct reduces RedLife before GreenLife."),
Item::BlueLifeI => format!("Increases CONSTRUCT BlueLife. Item::LifeBBI => format!("Increases CONSTRUCT BlueLife.
BlueDamage dealt to your construct reduces BlueLife before GreenLife."), BlueDamage dealt to your construct reduces BlueLife before GreenLife."),
Item::GRLI => format!("Increases CONSTRUCT GreenLife + RedLife"), Item::LifeRGI => format!("Increases CONSTRUCT GreenLife + RedLife"),
Item::GBLI => format!("Increases CONSTRUCT GreenLife + BlueLife"), Item::LifeGBI => format!("Increases CONSTRUCT GreenLife + BlueLife"),
Item::RBLI => format!("Increases CONSTRUCT RedLife + BlueLife"), Item::LifeRBI => format!("Increases CONSTRUCT RedLife + BlueLife"),
// Power Upgrades // Power Upgrades
Item::RedPowerI => format!("Increases CONSTRUCT RedPower."), Item::PowerRRI => format!("Increases CONSTRUCT RedPower."),
Item::BluePowerI => format!("Increases CONSTRUCT BluePower."), Item::PowerBBI => format!("Increases CONSTRUCT BluePower."),
Item::GreenPowerI => format!("Increases CONSTRUCT GreenPower."), Item::PowerGGI => format!("Increases CONSTRUCT GreenPower."),
Item::GRDI => format!("Increases CONSTRUCT GreenPower + RedPower."), Item::PowerRGI => format!("Increases CONSTRUCT GreenPower + RedPower."),
Item::GBDI => format!("Increases CONSTRUCT GreenPower + BluePower."), Item::PowerGBI => format!("Increases CONSTRUCT GreenPower + BluePower."),
Item::RBDI => format!("Increases CONSTRUCT RedPower + BluePower."), Item::PowerRBI => format!("Increases CONSTRUCT RedPower + BluePower."),
// Speed Upgrades // Speed Upgrades
Item::RedSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), Item::SpeedRRI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::BlueSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), Item::SpeedBBI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::GreenSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), Item::SpeedGGI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::GRSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), Item::SpeedRGI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::GBSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), Item::SpeedGBI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::RBSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), Item::SpeedRBI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
// Skills <- need to move effect mulltipliers into skills // Skills <- need to move effect mulltipliers into skills
Item::AmplifyI | Item::AmplifyI |
@ -637,7 +637,7 @@ impl Item {
"Stun the target for {:?}T and applies Vulnerable increasing RedDamage taken by {:?}% for {:?}T", "Stun the target for {:?}T and applies Vulnerable increasing RedDamage taken by {:?}% for {:?}T",
self.into_skill().unwrap().effect().first().unwrap().get_duration(), self.into_skill().unwrap().effect().first().unwrap().get_duration(),
self.into_skill().unwrap().effect().first().unwrap().get_multiplier() - 100, self.into_skill().unwrap().effect().last().unwrap().get_multiplier() - 100,
self.into_skill().unwrap().effect().last().unwrap().get_duration()), self.into_skill().unwrap().effect().last().unwrap().get_duration()),
Item::TriageI | Item::TriageI |
@ -749,26 +749,26 @@ impl Item {
Item::ChaosII => vec![Item::ChaosI, Item::ChaosI, Item::ChaosI], Item::ChaosII => vec![Item::ChaosI, Item::ChaosI, Item::ChaosI],
Item::ChaosIII => vec![Item::ChaosII, Item::ChaosII, Item::ChaosII], Item::ChaosIII => vec![Item::ChaosII, Item::ChaosII, Item::ChaosII],
Item::RedPowerI => vec![Item::Power, Item::Red, Item::Red], Item::PowerRRI => vec![Item::Power, Item::Red, Item::Red],
Item::GreenPowerI => vec![Item::Power, Item::Green, Item::Green], Item::PowerGGI => vec![Item::Power, Item::Green, Item::Green],
Item::BluePowerI => vec![Item::Power, Item::Blue, Item::Blue], Item::PowerBBI => vec![Item::Power, Item::Blue, Item::Blue],
Item::GRDI => vec![Item::Power, Item::Red, Item::Green], Item::PowerRGI => vec![Item::Power, Item::Red, Item::Green],
Item::GBDI => vec![Item::Power, Item::Green, Item::Blue], Item::PowerGBI => vec![Item::Power, Item::Green, Item::Blue],
Item::RBDI => vec![Item::Power, Item::Red, Item::Blue], Item::PowerRBI => vec![Item::Power, Item::Red, Item::Blue],
Item::RedLifeI => vec![Item::Life, Item::Red, Item::Red], Item::LifeRRI => vec![Item::Life, Item::Red, Item::Red],
Item::GreenLifeI => vec![Item::Life, Item::Green, Item::Green], Item::LifeGGI => vec![Item::Life, Item::Green, Item::Green],
Item::BlueLifeI => vec![Item::Life, Item::Blue, Item::Blue], Item::LifeBBI => vec![Item::Life, Item::Blue, Item::Blue],
Item::GRLI => vec![Item::Life, Item::Red, Item::Green], Item::LifeRGI => vec![Item::Life, Item::Red, Item::Green],
Item::GBLI => vec![Item::Life, Item::Green, Item::Blue], Item::LifeGBI => vec![Item::Life, Item::Green, Item::Blue],
Item::RBLI => vec![Item::Life, Item::Red, Item::Blue], Item::LifeRBI => vec![Item::Life, Item::Red, Item::Blue],
Item::RedSpeedI => vec![Item::Speed, Item::Red, Item::Red], Item::SpeedRRI => vec![Item::Speed, Item::Red, Item::Red],
Item::GreenSpeedI => vec![Item::Speed, Item::Green, Item::Green], Item::SpeedGGI => vec![Item::Speed, Item::Green, Item::Green],
Item::BlueSpeedI => vec![Item::Speed, Item::Blue, Item::Blue], Item::SpeedBBI => vec![Item::Speed, Item::Blue, Item::Blue],
Item::GRSpeedI => vec![Item::Speed, Item::Red, Item::Green], Item::SpeedRGI => vec![Item::Speed, Item::Red, Item::Green],
Item::GBSpeedI => vec![Item::Speed, Item::Green, Item::Blue], Item::SpeedGBI => vec![Item::Speed, Item::Green, Item::Blue],
Item::RBSpeedI => vec![Item::Speed, Item::Red, Item::Blue], Item::SpeedRBI => vec![Item::Speed, Item::Red, Item::Blue],
_ => vec![*self], _ => vec![*self],
} }
@ -891,28 +891,28 @@ impl From<Spec> for Item {
fn from(spec: Spec) -> Item { fn from(spec: Spec) -> Item {
match spec { match spec {
Spec::Speed => Item::Speed, Spec::Speed => Item::Speed,
Spec::RedSpeedI => Item::RedSpeedI, Spec::SpeedRRI => Item::SpeedRRI,
Spec::BlueSpeedI => Item::BlueSpeedI, Spec::SpeedBBI => Item::SpeedBBI,
Spec::GreenSpeedI => Item::GreenSpeedI, Spec::SpeedGGI => Item::SpeedGGI,
Spec::GRSpeedI => Item::GRSpeedI, Spec::SpeedRGI => Item::SpeedRGI,
Spec::GBSpeedI => Item::GBSpeedI, Spec::SpeedGBI => Item::SpeedGBI,
Spec::RBSpeedI => Item::RBSpeedI, Spec::SpeedRBI => Item::SpeedRBI,
Spec::Power => Item::Power, Spec::Power => Item::Power,
Spec::RedPowerI => Item::RedPowerI, Spec::PowerRRI => Item::PowerRRI,
Spec::BluePowerI => Item::BluePowerI, Spec::PowerBBI => Item::PowerBBI,
Spec::GreenPowerI => Item::GreenPowerI, Spec::PowerGGI => Item::PowerGGI,
Spec::GRDI => Item::GRDI, Spec::PowerRGI => Item::PowerRGI,
Spec::GBDI => Item::GBDI, Spec::PowerGBI => Item::PowerGBI,
Spec::RBDI => Item::RBDI, Spec::PowerRBI => Item::PowerRBI,
Spec::Life => Item::Life, Spec::Life => Item::Life,
Spec::GRLI => Item::GRLI, Spec::LifeRGI => Item::LifeRGI,
Spec::GBLI => Item::GBLI, Spec::LifeGBI => Item::LifeGBI,
Spec::RBLI => Item::RBLI, Spec::LifeRBI => Item::LifeRBI,
Spec::GreenLifeI => Item::GreenLifeI, Spec::LifeGGI => Item::LifeGGI,
Spec::RedLifeI => Item::RedLifeI, Spec::LifeRRI => Item::LifeRRI,
Spec::BlueLifeI => Item::BlueLifeI, Spec::LifeBBI => Item::LifeBBI,
// _ => panic!("{:?} not implemented as a item", spec), // _ => panic!("{:?} not implemented as a item", spec),
} }
} }
@ -1038,26 +1038,26 @@ pub fn get_combos() -> Vec<Combo> {
Combo { components: Item::ChaosII.combo(), item: Item::ChaosII }, Combo { components: Item::ChaosII.combo(), item: Item::ChaosII },
Combo { components: Item::ChaosIII.combo(), item: Item::ChaosIII }, Combo { components: Item::ChaosIII.combo(), item: Item::ChaosIII },
Combo { components: Item::RedPowerI.combo(), item: Item::RedPowerI }, Combo { components: Item::PowerRRI.combo(), item: Item::PowerRRI },
Combo { components: Item::GreenPowerI.combo(), item: Item::GreenPowerI }, Combo { components: Item::PowerGGI.combo(), item: Item::PowerGGI },
Combo { components: Item::BluePowerI.combo(), item: Item::BluePowerI }, Combo { components: Item::PowerBBI.combo(), item: Item::PowerBBI },
Combo { components: Item::GRDI.combo(), item: Item::GRDI }, Combo { components: Item::PowerRGI.combo(), item: Item::PowerRGI },
Combo { components: Item::GBDI.combo(), item: Item::GBDI }, Combo { components: Item::PowerGBI.combo(), item: Item::PowerGBI },
Combo { components: Item::RBDI.combo(), item: Item::RBDI }, Combo { components: Item::PowerRBI.combo(), item: Item::PowerRBI },
Combo { components: Item::RedLifeI.combo(), item: Item::RedLifeI }, Combo { components: Item::LifeRRI.combo(), item: Item::LifeRRI },
Combo { components: Item::GreenLifeI.combo(), item: Item::GreenLifeI }, Combo { components: Item::LifeGGI.combo(), item: Item::LifeGGI },
Combo { components: Item::BlueLifeI.combo(), item: Item::BlueLifeI }, Combo { components: Item::LifeBBI.combo(), item: Item::LifeBBI },
Combo { components: Item::GRLI.combo(), item: Item::GRLI }, Combo { components: Item::LifeRGI.combo(), item: Item::LifeRGI },
Combo { components: Item::GBLI.combo(), item: Item::GBLI }, Combo { components: Item::LifeGBI.combo(), item: Item::LifeGBI },
Combo { components: Item::RBLI.combo(), item: Item::RBLI }, Combo { components: Item::LifeRBI.combo(), item: Item::LifeRBI },
Combo { components: Item::RedSpeedI.combo(), item: Item::RedSpeedI }, Combo { components: Item::SpeedRRI.combo(), item: Item::SpeedRRI },
Combo { components: Item::GreenSpeedI.combo(), item: Item::GreenSpeedI }, Combo { components: Item::SpeedGGI.combo(), item: Item::SpeedGGI },
Combo { components: Item::BlueSpeedI.combo(), item: Item::BlueSpeedI }, Combo { components: Item::SpeedBBI.combo(), item: Item::SpeedBBI },
Combo { components: Item::GRSpeedI.combo(), item: Item::GRSpeedI }, Combo { components: Item::SpeedRGI.combo(), item: Item::SpeedRGI },
Combo { components: Item::GBSpeedI.combo(), item: Item::GBSpeedI }, Combo { components: Item::SpeedGBI.combo(), item: Item::SpeedGBI },
Combo { components: Item::RBSpeedI.combo(), item: Item::RBSpeedI }, Combo { components: Item::SpeedRBI.combo(), item: Item::SpeedRBI },
]; ];
@ -1071,6 +1071,7 @@ pub struct ItemInfo {
pub item: Item, pub item: Item,
pub spec: bool, pub spec: bool,
pub skill: bool, pub skill: bool,
pub values: Option<SpecValues>,
pub description: String, pub description: String,
} }
@ -1101,6 +1102,10 @@ pub fn item_info() -> ItemInfoCtr {
spec: v.into_spec().is_some(), spec: v.into_spec().is_some(),
skill: v.into_skill().is_some(), skill: v.into_skill().is_some(),
description: v.into_description(), description: v.into_description(),
values: match v.into_spec() {
Some(s) => Some(s.values()),
None => None
},
}) })
.collect::<Vec<ItemInfo>>(); .collect::<Vec<ItemInfo>>();
@ -1139,4 +1144,10 @@ mod tests {
]); ]);
} }
#[test]
fn item_info_test() {
let info = item_info();
println!("{:#?}", info);
}
} }

View File

@ -1,61 +1,262 @@
use construct::{Stat, Colours}; use construct::{Stat, Colours};
use util::{IntPct}; use util::{IntPct};
#[derive(Debug,Clone,Serialize,Deserialize)]
pub struct SpecBonus {
pub req: Colours,
pub bonus: u64,
}
impl SpecBonus {
pub fn get_bonus(&self, c: &Colours) -> u64 {
if c.red >= self.req.red && c.blue >= self.req.blue && c.green >= self.req.green {
return self.bonus;
}
return 0;
}
}
#[derive(Debug,Clone,Serialize,Deserialize)]
pub struct SpecValues {
pub base: u64,
pub bonuses: Vec<SpecBonus>,
}
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)] #[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
pub enum Spec { pub enum Spec {
Speed, Speed,
RedSpeedI, SpeedRRI,
BlueSpeedI, SpeedBBI,
GreenSpeedI, SpeedGGI,
GRSpeedI, SpeedRGI,
GBSpeedI, SpeedGBI,
RBSpeedI, SpeedRBI,
// Pure redLife has to come first as it applies the base amount // Pure redLife has to come first as it applies the base amount
// that is multiplied // that is multiplied
Life, Life,
GreenLifeI, LifeGGI,
RedLifeI, LifeRRI,
BlueLifeI, LifeBBI,
GRLI, LifeRGI,
GBLI, LifeGBI,
RBLI, LifeRBI,
Power, Power,
RedPowerI, PowerRRI,
GreenPowerI, PowerGGI,
BluePowerI, PowerBBI,
GRDI, PowerRGI,
GBDI, PowerGBI,
RBDI, PowerRBI,
} }
impl Spec { impl Spec {
pub fn affects(&self) -> Vec<Stat> { pub fn affects(&self) -> Vec<Stat> {
match *self { match *self {
Spec::Power => vec![Stat::BluePower, Stat::RedPower, Stat::GreenPower], Spec::Power => vec![Stat::BluePower, Stat::RedPower, Stat::GreenPower],
Spec::RedPowerI => vec![Stat::RedPower], Spec::PowerRRI => vec![Stat::RedPower],
Spec::GreenPowerI => vec![Stat::GreenPower], Spec::PowerGGI => vec![Stat::GreenPower],
Spec::BluePowerI => vec![Stat::BluePower], Spec::PowerBBI => vec![Stat::BluePower],
Spec::GRDI => vec![Stat::GreenPower, Stat::RedPower], Spec::PowerRGI => vec![Stat::GreenPower, Stat::RedPower],
Spec::GBDI => vec![Stat::GreenPower, Stat::BluePower], Spec::PowerGBI => vec![Stat::GreenPower, Stat::BluePower],
Spec::RBDI => vec![Stat::RedPower, Stat::BluePower], Spec::PowerRBI => vec![Stat::RedPower, Stat::BluePower],
Spec::Speed => vec![Stat::Speed], Spec::Speed => vec![Stat::Speed],
Spec::RedSpeedI => vec![Stat::Speed], Spec::SpeedRRI => vec![Stat::Speed],
Spec::BlueSpeedI => vec![Stat::Speed], Spec::SpeedBBI => vec![Stat::Speed],
Spec::GreenSpeedI => vec![Stat::Speed], Spec::SpeedGGI => vec![Stat::Speed],
Spec::GRSpeedI => vec![Stat::Speed], Spec::SpeedRGI => vec![Stat::Speed],
Spec::GBSpeedI => vec![Stat::Speed], Spec::SpeedGBI => vec![Stat::Speed],
Spec::RBSpeedI => vec![Stat::Speed], Spec::SpeedRBI => vec![Stat::Speed],
Spec::Life => vec![Stat::GreenLife], Spec::Life => vec![Stat::GreenLife],
Spec::RedLifeI => vec![Stat::RedLife], Spec::LifeRRI => vec![Stat::RedLife],
Spec::BlueLifeI => vec![Stat::BlueLife], Spec::LifeBBI => vec![Stat::BlueLife],
Spec::GreenLifeI => vec![Stat::GreenLife], Spec::LifeGGI => vec![Stat::GreenLife],
Spec::GRLI => vec![Stat::GreenLife, Stat::RedLife], Spec::LifeRGI => vec![Stat::GreenLife, Stat::RedLife],
Spec::GBLI => vec![Stat::GreenLife, Stat::BlueLife], Spec::LifeGBI => vec![Stat::GreenLife, Stat::BlueLife],
Spec::RBLI => vec![Stat::BlueLife, Stat::RedLife], Spec::LifeRBI => vec![Stat::BlueLife, Stat::RedLife],
}
}
pub fn values(&self) -> SpecValues {
match *self {
Spec::Power => SpecValues {
base: 5,
bonuses: vec![]
},
Spec::PowerRRI => SpecValues {
base: 10,
bonuses: vec![
SpecBonus { req: Colours { red: 5, green: 0, blue: 0 }, bonus: 10 },
SpecBonus { req: Colours { red: 10, green: 0, blue: 0 }, bonus: 20 },
SpecBonus { req: Colours { red: 20, green: 0, blue: 0 }, bonus: 40 }
],
},
Spec::PowerGGI => SpecValues {
base: 10,
bonuses: vec![
SpecBonus { req: Colours { red: 0, green: 5, blue: 0 }, bonus: 10 },
SpecBonus { req: Colours { red: 0, green: 10, blue: 0 }, bonus: 20 },
SpecBonus { req: Colours { red: 0, green: 20, blue: 0 }, bonus: 40 }
],
},
Spec::PowerBBI => SpecValues {
base: 10,
bonuses: vec![
SpecBonus { req: Colours { red: 0, green: 0, blue: 5 }, bonus: 10 },
SpecBonus { req: Colours { red: 0, green: 0, blue: 10 }, bonus: 20 },
SpecBonus { req: Colours { red: 0, green: 0, blue: 20 }, bonus: 40 }
],
},
Spec::PowerRGI => SpecValues {
base: 5,
bonuses: vec![
SpecBonus { req: Colours { red: 2, green: 2, blue: 0 }, bonus: 10 },
SpecBonus { req: Colours { red: 5, green: 5, blue: 0 }, bonus: 15 },
SpecBonus { req: Colours { red: 10, green: 10, blue: 0 }, bonus: 30 }
],
},
Spec::PowerGBI => SpecValues {
base: 5,
bonuses: vec![
SpecBonus { req: Colours { red: 0, green: 2, blue: 2 }, bonus: 10 },
SpecBonus { req: Colours { red: 0, green: 5, blue: 5 }, bonus: 15 },
SpecBonus { req: Colours { red: 0, green: 10, blue: 10 }, bonus: 30 }
],
},
Spec::PowerRBI => SpecValues {
base: 5,
bonuses: vec![
SpecBonus { req: Colours { red: 2, green: 0, blue: 2 }, bonus: 10 },
SpecBonus { req: Colours { red: 5, green: 0, blue: 5 }, bonus: 15 },
SpecBonus { req: Colours { red: 10, green: 0, blue: 10 }, bonus: 30 }
],
},
Spec::Speed => SpecValues {
base: 5,
bonuses: vec![]
},
Spec::SpeedRRI => SpecValues {
base: 10,
bonuses: vec![
SpecBonus { req: Colours { red: 5, green: 0, blue: 0 }, bonus: 10 },
SpecBonus { req: Colours { red: 10, green: 0, blue: 0 }, bonus: 20 },
SpecBonus { req: Colours { red: 20, green: 0, blue: 0 }, bonus: 40 }
],
},
Spec::SpeedGGI => SpecValues {
base: 10,
bonuses: vec![
SpecBonus { req: Colours { red: 0, green: 5, blue: 0 }, bonus: 10 },
SpecBonus { req: Colours { red: 0, green: 10, blue: 0 }, bonus: 20 },
SpecBonus { req: Colours { red: 0, green: 20, blue: 0 }, bonus: 40 }
],
},
Spec::SpeedBBI => SpecValues {
base: 10,
bonuses: vec![
SpecBonus { req: Colours { red: 0, green: 0, blue: 5 }, bonus: 10 },
SpecBonus { req: Colours { red: 0, green: 0, blue: 10 }, bonus: 20 },
SpecBonus { req: Colours { red: 0, green: 0, blue: 20 }, bonus: 40 }
],
},
Spec::SpeedRGI => SpecValues {
base: 5,
bonuses: vec![
SpecBonus { req: Colours { red: 2, green: 2, blue: 0 }, bonus: 10 },
SpecBonus { req: Colours { red: 5, green: 5, blue: 0 }, bonus: 15 },
SpecBonus { req: Colours { red: 10, green: 10, blue: 0 }, bonus: 30 }
],
},
Spec::SpeedGBI => SpecValues {
base: 5,
bonuses: vec![
SpecBonus { req: Colours { red: 0, green: 2, blue: 2 }, bonus: 10 },
SpecBonus { req: Colours { red: 0, green: 5, blue: 5 }, bonus: 15 },
SpecBonus { req: Colours { red: 0, green: 10, blue: 10 }, bonus: 30 }
],
},
Spec::SpeedRBI => SpecValues {
base: 5,
bonuses: vec![
SpecBonus { req: Colours { red: 2, green: 0, blue: 2 }, bonus: 10 },
SpecBonus { req: Colours { red: 5, green: 0, blue: 5 }, bonus: 15 },
SpecBonus { req: Colours { red: 10, green: 0, blue: 10 }, bonus: 30 }
],
},
Spec::Life => SpecValues {
base: 5,
bonuses: vec![]},
Spec::LifeRRI => SpecValues {
base: 10,
bonuses: vec![
SpecBonus { req: Colours { red: 5, green: 0, blue: 0 }, bonus: 10 },
SpecBonus { req: Colours { red: 10, green: 0, blue: 0 }, bonus: 20 },
SpecBonus { req: Colours { red: 20, green: 0, blue: 0 }, bonus: 40 }
],
},
Spec::LifeGGI => SpecValues {
base: 10,
bonuses: vec![
SpecBonus { req: Colours { red: 0, green: 5, blue: 0 }, bonus: 10 },
SpecBonus { req: Colours { red: 0, green: 10, blue: 0 }, bonus: 20 },
SpecBonus { req: Colours { red: 0, green: 20, blue: 0 }, bonus: 40 }
],
},
Spec::LifeBBI => SpecValues {
base: 10,
bonuses: vec![
SpecBonus { req: Colours { red: 0, green: 0, blue: 5 }, bonus: 10 },
SpecBonus { req: Colours { red: 0, green: 0, blue: 10 }, bonus: 20 },
SpecBonus { req: Colours { red: 0, green: 0, blue: 20 }, bonus: 40 }
],
},
Spec::LifeRGI => SpecValues {
base: 5,
bonuses: vec![
SpecBonus { req: Colours { red: 2, green: 2, blue: 0 }, bonus: 10 },
SpecBonus { req: Colours { red: 5, green: 5, blue: 0 }, bonus: 15 },
SpecBonus { req: Colours { red: 10, green: 10, blue: 0 }, bonus: 30 }
],
},
Spec::LifeGBI => SpecValues {
base: 5,
bonuses: vec![
SpecBonus { req: Colours { red: 0, green: 2, blue: 2 }, bonus: 10 },
SpecBonus { req: Colours { red: 0, green: 5, blue: 5 }, bonus: 15 },
SpecBonus { req: Colours { red: 0, green: 10, blue: 10 }, bonus: 30 }
],
},
Spec::LifeRBI => SpecValues {
base: 5,
bonuses: vec![
SpecBonus { req: Colours { red: 2, green: 0, blue: 2 }, bonus: 10 },
SpecBonus { req: Colours { red: 5, green: 0, blue: 5 }, bonus: 15 },
SpecBonus { req: Colours { red: 10, green: 0, blue: 10 }, bonus: 30 }
],
},
} }
} }
@ -63,136 +264,35 @@ impl Spec {
let construct_colour_total: u64 = (construct_colours.red + construct_colours.green + construct_colours.blue) as u64; let construct_colour_total: u64 = (construct_colours.red + construct_colours.green + construct_colours.blue) as u64;
match *self { match *self {
// Upgrades to Power Spec // Upgrades to Power Spec
Spec::Power => modified + base.pct(5), Spec::Power |
Spec::RedPowerI => modified + { Spec::PowerRRI |
let mut pct = 10; Spec::PowerGGI |
if player_colours.red >= 5 { pct += 10 }; Spec::PowerBBI |
if player_colours.red >= 10 { pct += 20 }; Spec::PowerRGI |
if player_colours.red >= 20 { pct += 40 }; Spec::PowerGBI |
base.pct(pct) Spec::PowerRBI |
Spec::Speed |
Spec::SpeedRRI |
Spec::SpeedGGI |
Spec::SpeedBBI |
Spec::SpeedRGI |
Spec::SpeedGBI |
Spec::SpeedRBI => modified + {
let spec_values = self.values();
base.pct(spec_values.bonuses.iter()
.fold(spec_values.base, |acc, s| acc + s.get_bonus(player_colours)))
}, },
Spec::GreenPowerI => modified + {
let mut pct = 10; Spec::Life |
if player_colours.green >= 5 { pct += 10 }; Spec::LifeRRI |
if player_colours.green >= 10 { pct += 20 }; Spec::LifeGGI |
if player_colours.green >= 20 { pct += 40 }; Spec::LifeBBI |
base.pct(pct) Spec::LifeRGI |
}, Spec::LifeGBI |
Spec::BluePowerI => modified + { Spec::LifeRBI => modified + {
let mut pct = 10; let spec_values = self.values();
if player_colours.blue >= 5 { pct += 10 }; construct_colour_total * (spec_values.bonuses.iter()
if player_colours.blue >= 10 { pct += 20 }; .fold(spec_values.base, |acc, s| acc + s.get_bonus(player_colours)))
if player_colours.blue >= 20 { pct += 40 };
base.pct(pct)
},
Spec::GRDI => modified + {
let mut pct = 5;
if player_colours.green >= 2 && player_colours.red >= 2 { pct += 10 };
if player_colours.green >= 5 && player_colours.red >= 5 { pct += 15 };
if player_colours.green >= 10 && player_colours.red >= 10 { pct += 30 };
base.pct(pct)
},
Spec::GBDI => modified + {
let mut pct = 5;
if player_colours.green >= 2 && player_colours.blue >= 2 { pct += 10 };
if player_colours.green >= 5 && player_colours.blue >= 5 { pct += 15 };
if player_colours.green >= 10 && player_colours.blue >= 10 { pct += 30 };
base.pct(pct)
},
Spec::RBDI => modified + {
let mut pct = 5;
if player_colours.blue >= 2 && player_colours.red >= 2 { pct += 10 };
if player_colours.blue >= 5 && player_colours.red >= 5 { pct += 15 };
if player_colours.blue >= 10 && player_colours.red >= 10 { pct += 30 };
base.pct(pct)
},
// Upgrades to speed Spec
Spec::Speed => modified + base.pct(5),
Spec::RedSpeedI => modified + {
let mut pct = 5;
if player_colours.red >= 5 { pct += 5 };
if player_colours.red >= 10 { pct += 10 };
if player_colours.red >= 20 { pct += 20 };
base.pct(pct)
},
Spec::GreenSpeedI => modified + {
let mut pct = 5;
if player_colours.green >= 5 { pct += 5 };
if player_colours.green >= 10 { pct += 10 };
if player_colours.green >= 20 { pct += 20 };
base.pct(pct)
},
Spec::BlueSpeedI => modified + {
let mut pct = 5;
if player_colours.blue >= 5 { pct += 5 };
if player_colours.blue >= 10 { pct += 10 };
if player_colours.blue >= 20 { pct += 20 };
base.pct(pct)
},
Spec::GRSpeedI => modified + {
let mut pct = 5;
if player_colours.green >= 2 && player_colours.red >= 2 { pct += 5 };
if player_colours.green >= 5 && player_colours.red >= 5 { pct += 10 };
if player_colours.green >= 10 && player_colours.red >= 10 { pct += 20 };
base.pct(pct)
},
Spec::GBSpeedI => modified + {
let mut pct = 5;
if player_colours.green >= 2 && player_colours.blue >= 2 { pct += 5 };
if player_colours.green >= 5 && player_colours.blue >= 5 { pct += 10 };
if player_colours.green >= 10 && player_colours.blue >= 10 { pct += 20 };
base.pct(pct)
},
Spec::RBSpeedI => modified + {
let mut pct = 5;
if player_colours.blue >= 2 && player_colours.red >= 2 { pct += 5 };
if player_colours.blue >= 5 && player_colours.red >= 5 { pct += 10 };
if player_colours.blue >= 10 && player_colours.red >= 10 { pct += 20 };
base.pct(pct)
},
// Upgrades to HP Spec
Spec::Life => modified + base.pct(5),
Spec::GreenLifeI => modified + {
let mut mult: u64 = 25;
if player_colours.green >= 5 { mult += 15 };
if player_colours.green >= 10 { mult += 30 };
if player_colours.green >= 20 { mult += 45 };
mult * construct_colour_total
},
Spec::RedLifeI => modified + {
let mut mult: u64 = 25;
if player_colours.red >= 5 { mult += 15 };
if player_colours.red >= 10 { mult += 30 };
if player_colours.red >= 20 { mult += 45 };
mult * construct_colour_total
},
Spec::BlueLifeI => modified + {
let mut mult: u64 = 25;
if player_colours.blue >= 5 { mult += 15 };
if player_colours.blue >= 10 { mult += 30 };
if player_colours.blue >= 20 { mult += 45 };
mult * construct_colour_total
},
Spec::GRLI => modified + {
let mut mult: u64 = 15;
if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 };
if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 };
if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 };
mult * construct_colour_total
},
Spec::GBLI => modified + {
let mut mult: u64 = 15;
if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 };
if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 };
if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 };
mult * construct_colour_total
},
Spec::RBLI => modified + {
let mut mult: u64 = 15;
if player_colours.blue >= 2 && player_colours.red >= 2 { mult += 10 };
if player_colours.blue >= 5 && player_colours.red >= 5 { mult += 20 };
if player_colours.blue >= 10 && player_colours.red >= 10 { mult += 40 };
mult * construct_colour_total
}, },
} }
} }