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
*CLIENT*
* fix mobile menu
* make fullscreen
* disappear on touch
*SERVER*

View File

@ -289,14 +289,8 @@
margin: 0 1em;
}
.equip-icon {
height: 2em;
stroke-width: 5px;
fill: none;
}
.construct-list .stat-icon {
width: 100%;
.icons figure {
flex: 1;
}
.construct-list .stats .damage-label {
@ -420,19 +414,29 @@ button.equipping {
.thresholds {
display: flex;
flex-flow: row-wrap;
/*align-items: center;*/
flex-flow: column;
text-align: center;
}
.thresholds svg {
stroke-width: 5px;
}
.thresholds hr {
margin: 1em 0;
}
.colour-reqs {
display: flex;
flex-flow: row;
justify-content: space-around;
}
.spec-goals {
}
.spec-goals figure svg {
.thresholds figure svg {
height: 2em;
}
.spec-goals .unmet {
.thresholds .unmet {
opacity: 0.5;
}

View File

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

View File

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

View File

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

View File

@ -2,10 +2,10 @@ const preact = require('preact');
const range = require('lodash/range');
const { INFO } = require('./../constants');
const { SPECS } = require('./../utils');
const { COLOUR_ICONS, convertItem } = require('../utils');
const { convertItem } = require('../utils');
const shapes = require('./shapes');
function Info(args) {
function InfoComponent(args) {
const {
info,
itemInfo,
@ -24,16 +24,6 @@ function Info(args) {
const isSkill = fullInfo.skill;
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) {
return (
<div className="info-skill">
@ -44,16 +34,30 @@ function Info(args) {
}
if (isSpec) {
const breaks = SPECS[info].thresholds;
const colourReqs = SPECS[info].colours || [];
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 thresholdEl = colourReqs.map((c, i) => {
const numIcons = Math.max(...breaks);
const dots = range(0, numIcons).map(j => {
const colourReqs = fullInfo.values.bonuses || [];
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 caption = breaks.includes(j + 1)
? '+ x'
: '';
const reqClass = unmet
? 'unmet'
@ -61,25 +65,43 @@ function Info(args) {
return (
<figure key={j} alt={c.colour} className={reqClass} >
{COLOUR_ICONS[c].svg(`stat-icon ${COLOUR_ICONS[c].colour}`)}
<figcaption>{caption}</figcaption>
{shapes.square([c])}
</figure>
);
});
return (
<div key={i} className="spec-goals">
<div key={c}>
{dots}
</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 (
<div className="info-spec">
<h2>{info}</h2>
<div>{fullInfo.description}</div>
<div className="thresholds">
{thresholdEl}
{thresholds}
</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 shapes = require('./shapes');
const { SPECS, STATS, instanceConstruct } = require('../utils');
const { STATS, instanceConstruct } = require('../utils');
const actions = require('../actions');
const addState = connect(
@ -146,12 +146,14 @@ function Construct(props) {
const equip = specList.includes(vbox.bound[itemEquip]) ? 'equip-spec' : 'gray';
return (
<figure key={i} className={equip} >
{shapes.diamond(`stat-icon ${equip}`)}
{shapes.diamond(equip)}
<figcaption>&nbsp;</figcaption>
</figure>
);
}
const specInfo = itemInfo.items.find(i => i.item === s);
function specClick(e) {
e.stopPropagation();
setItemUnequip(s);
@ -174,35 +176,23 @@ function Construct(props) {
onClick={specClick}
onDblClick={specDblClick}
onMouseOver={e => hoverInfo(e, s)} >
{SPECS[s].svg(`stat-icon ${SPECS[s].colour}`)}
<figcaption>{SPECS[s].caption}</figcaption>
{shapes[s]()}
<figcaption>{s}</figcaption>
</figure>
);
});
const stats = Object.values(STATS).map(s => (
<figure key={s.stat} alt={s.stat} className={s.stat}>
{s.svg(`stat-icon ${s.colour} stat`)}
<figcaption>{construct[s.stat].value}</figcaption>
</figure>
));
const stats = Object.keys(STATS).map(s => {
const stat = STATS[s];
return <figure key={stat.stat} alt={stat.stat} className={stat.stat}>
{shapes[s]()}
<figcaption>{construct[stat.stat].value}</figcaption>
</figure>;
});
const activeId = activeConstruct ? activeConstruct.id : false;
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 (
<div key={construct.id} className={constructClass} onClick={onClick} >
{instanceConstruct(construct.name, construct.id)}

View File

@ -4,7 +4,7 @@ const range = require('lodash/range');
const actions = require('../actions');
const shapes = require('./shapes');
const { convertItem, SPECS } = require('./../utils');
const { convertItem } = require('./../utils');
const addState = connect(
function receiveState(state) {
@ -64,9 +64,11 @@ function Equipment(props) {
const isSkill = fullInfo && fullInfo.skill;
const isSpec = fullInfo && fullInfo.spec;
console.log('isSkill', isSkill, fullInfo);
function skillClick(e, i) {
if (itemUnequip && activeConstruct) return false;
const value = vbox.bound[i];
// const value = vbox.bound[i];
setItemEquip(i);
return false;
}
@ -87,37 +89,38 @@ function Equipment(props) {
const skillClass = isSkill ? 'skills highlight' : 'skills';
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 item = convertItem(vbox.bound[i]);
if (skillList.includes(item)) {
const skillInfo = itemInfo.items.find(i => i.item === item);
if (skillInfo && skillInfo.skill) {
return (
<button key={i} onClick={e => skillClick(e, i)} onMouseOver={e => hoverInfo(e, item)}>
{item}
</button>
);
} return false;
}
return false;
});
const specs = range(0, 9).map(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 (
<figure key={i} onClick={e => skillClick(e, i)} onMouseOver={e => hoverInfo(e, item)} >
{SPECS[item].svg(`stat-icon ${SPECS[item].colour}`)}
<figcaption>{SPECS[item].caption}</figcaption>
{shapes[item]()}
<figcaption>{item}</figcaption>
</figure>
);
} return false;
}
return false;
});
if (skills.every(s => !s)) skills.push(<button disabled={true}>&nbsp;</button>);
if (specs.every(s => !s)) {
specs.push(
<figure>
{shapes.diamond('stat-icon gray')}
{shapes.diamond('gray')}
<figcaption>&nbsp;</figcaption>
</figure>
);

View File

@ -18,4 +18,43 @@ module.exports = {
triangle,
saw,
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');
module.exports = function triangle(classes) {
module.exports = function circle(colours) {
if (colours.length === 1) {
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" style="enable-background:new 0 0 198.13 199.94;" className={classes} >
<g>
<ellipse class="st2" cx="99.07" cy="99.97" rx="97.6" ry="98.5"/>
<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
S141.34,177.35,99.07,177.35z"/>
<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
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"
/>
</g>
<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" >
<ellipse class={colours[0]} cx="99.07" cy="99.97" rx="97.6" ry="98.5"/>
<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"/>
<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={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 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"/>
</svg>
);
}
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" >
<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>
);
};

View File

@ -1,14 +1,40 @@
const preact = require('preact');
module.exports = function triangle(classes) {
module.exports = function square(colours) {
if (colours.length === 1) {
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" style="enable-background:new 0 0 199.33 199.99;" className={classes} >
<rect x="1.47" y="1.47" class="st0" 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="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="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="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"/>
viewBox="0 0 199.33 199.99" >
<rect x="1.47" y="1.47" class={colours[0]} width="196.39" height="197.05"/>
<rect x="21.63" y="22.22" class={colours[0]} width="156.07" height="155.55"/>
<rect x="42.12" y="42.64" class={colours[0]} width="115.09" height="114.71"/>
<rect x="62.61" y="63.06" class={colours[0]} width="74.11" height="73.86"/>
<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>
);
}

View File

@ -1,16 +1,38 @@
const preact = require('preact');
module.exports = function triangle(classes) {
module.exports = function triangle(colours) {
if (colours.length === 1) {
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" style="enable-background:new 0 0 202.69 177.29;" className={classes}>
<g>
<polygon class="st1" points="1.77,176.25 100.7,2.08 200.9,176.25 "/>
<polygon class="st1" points="23.99,163.23 100.78,28.05 178.54,163.23 "/>
<polygon class="st1" points="46.21,150.21 100.85,54.03 156.18,150.21 "/>
<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 version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 202.69 177.29" >
<polygon class={colours[0]} points="1.77,176.25 100.7,2.08 200.9,176.25 "/>
<polygon class={colours[0]} points="23.99,163.23 100.78,28.05 178.54,163.23 "/>
<polygon class={colours[0]} points="46.21,150.21 100.85,54.03 156.18,150.21 "/>
<polygon class={colours[0]} points="68.43,137.19 100.92,80 133.82,137.19 "/>
<polygon class={colours[0]} points="90.65,124.17 100.99,105.98 111.46,124.17 "/>
</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',
});
sendPing();
sendItemInfo();
if (account) {
events.setAccount(account);
sendAccountInstances();
sendAccountConstructs();
setTimeout(sendItemInfo, 2000);
}
sendPing();
return true;
});

View File

@ -130,178 +130,43 @@ function gameConstructImg(name, id, combatTextEl, selectSkillTarget) {
const NULL_UUID = '00000000-0000-0000-0000-000000000000';
const STATS = {
redPower: {
RedPower: {
stat: 'red_power',
colour: 'red',
svg: shapes.circle,
},
greenPower: {
GreenPower: {
stat: 'green_power',
colour: 'green',
svg: shapes.circle,
},
bluePower: {
BluePower: {
stat: 'blue_power',
colour: 'blue',
svg: shapes.circle,
},
speed: {
Speed: {
stat: 'speed',
colour: 'white',
svg: shapes.triangle,
},
redLife: {
RedLife: {
stat: 'red_life',
colour: 'red',
svg: shapes.square,
},
greenLife: {
GreenLife: {
stat: 'green_life',
colour: 'green',
svg: shapes.square,
},
blueLife: {
BlueLife: {
stat: 'blue_life',
colour: 'blue',
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) {
if (!resolution) return false;
@ -599,6 +464,4 @@ module.exports = {
resoConstructHealth,
NULL_UUID,
STATS,
SPECS,
COLOUR_ICONS,
};

View File

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

View File

@ -1,5 +1,5 @@
use skill::{Skill, Colour};
use spec::{Spec};
use spec::{Spec, SpecValues};
use construct::{Colours};
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
@ -23,28 +23,28 @@ pub enum Item {
Speed,
// Lifes Upgrades
GreenLifeI,
RedLifeI,
BlueLifeI,
GRLI,
GBLI,
RBLI,
LifeGGI,
LifeRRI,
LifeBBI,
LifeRGI,
LifeGBI,
LifeRBI,
// Power Upgrades
RedPowerI,
BluePowerI,
GreenPowerI,
GRDI,
GBDI,
RBDI,
PowerRRI,
PowerBBI,
PowerGGI,
PowerRGI,
PowerGBI,
PowerRBI,
// Speed Upgrades
RedSpeedI,
BlueSpeedI,
GreenSpeedI,
GRSpeedI,
GBSpeedI,
RBSpeedI,
SpeedRRI,
SpeedBBI,
SpeedGGI,
SpeedRGI,
SpeedGBI,
SpeedRBI,
AmplifyI,
AmplifyII,
@ -347,28 +347,28 @@ impl Item {
pub fn into_spec(&self) -> Option<Spec> {
match *self {
Item::Speed => Some(Spec::Speed),
Item::RedSpeedI => Some(Spec::RedSpeedI),
Item::BlueSpeedI => Some(Spec::BlueSpeedI),
Item::GreenSpeedI => Some(Spec::GreenSpeedI),
Item::GRSpeedI => Some(Spec::GRSpeedI),
Item::GBSpeedI => Some(Spec::GBSpeedI),
Item::RBSpeedI => Some(Spec::RBSpeedI),
Item::SpeedRRI => Some(Spec::SpeedRRI),
Item::SpeedBBI => Some(Spec::SpeedBBI),
Item::SpeedGGI => Some(Spec::SpeedGGI),
Item::SpeedRGI => Some(Spec::SpeedRGI),
Item::SpeedGBI => Some(Spec::SpeedGBI),
Item::SpeedRBI => Some(Spec::SpeedRBI),
Item::Power => Some(Spec::Power),
Item::RedPowerI => Some(Spec::RedPowerI),
Item::BluePowerI => Some(Spec::BluePowerI),
Item::GreenPowerI => Some(Spec::GreenPowerI),
Item::GRDI => Some(Spec::GRDI),
Item::GBDI => Some(Spec::GBDI),
Item::RBDI => Some(Spec::RBDI),
Item::PowerRRI => Some(Spec::PowerRRI),
Item::PowerBBI => Some(Spec::PowerBBI),
Item::PowerGGI => Some(Spec::PowerGGI),
Item::PowerRGI => Some(Spec::PowerRGI),
Item::PowerGBI => Some(Spec::PowerGBI),
Item::PowerRBI => Some(Spec::PowerRBI),
Item::Life => Some(Spec::Life),
Item::GRLI => Some(Spec::GRLI),
Item::GBLI => Some(Spec::GBLI),
Item::RBLI => Some(Spec::RBLI),
Item::GreenLifeI => Some(Spec::GreenLifeI),
Item::RedLifeI => Some(Spec::RedLifeI),
Item::BlueLifeI => Some(Spec::BlueLifeI),
Item::LifeRGI => Some(Spec::LifeRGI),
Item::LifeGBI => Some(Spec::LifeGBI),
Item::LifeRBI => Some(Spec::LifeRBI),
Item::LifeGGI => Some(Spec::LifeGGI),
Item::LifeRRI => Some(Spec::LifeRRI),
Item::LifeBBI => Some(Spec::LifeBBI),
_ => None,
}
@ -412,31 +412,31 @@ impl Item {
SPEED determines the order in which skills resolve."),
// 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."),
Item::RedLifeI => format!("Increases CONSTRUCT RedLife.
Item::LifeRRI => format!("Increases CONSTRUCT RedLife.
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."),
Item::GRLI => format!("Increases CONSTRUCT GreenLife + RedLife"),
Item::GBLI => format!("Increases CONSTRUCT GreenLife + BlueLife"),
Item::RBLI => format!("Increases CONSTRUCT RedLife + BlueLife"),
Item::LifeRGI => format!("Increases CONSTRUCT GreenLife + RedLife"),
Item::LifeGBI => format!("Increases CONSTRUCT GreenLife + BlueLife"),
Item::LifeRBI => format!("Increases CONSTRUCT RedLife + BlueLife"),
// Power Upgrades
Item::RedPowerI => format!("Increases CONSTRUCT RedPower."),
Item::BluePowerI => format!("Increases CONSTRUCT BluePower."),
Item::GreenPowerI => format!("Increases CONSTRUCT GreenPower."),
Item::GRDI => format!("Increases CONSTRUCT GreenPower + RedPower."),
Item::GBDI => format!("Increases CONSTRUCT GreenPower + BluePower."),
Item::RBDI => format!("Increases CONSTRUCT RedPower + BluePower."),
Item::PowerRRI => format!("Increases CONSTRUCT RedPower."),
Item::PowerBBI => format!("Increases CONSTRUCT BluePower."),
Item::PowerGGI => format!("Increases CONSTRUCT GreenPower."),
Item::PowerRGI => format!("Increases CONSTRUCT GreenPower + RedPower."),
Item::PowerGBI => format!("Increases CONSTRUCT GreenPower + BluePower."),
Item::PowerRBI => format!("Increases CONSTRUCT RedPower + BluePower."),
// Speed Upgrades
Item::RedSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::BlueSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::GreenSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::GRSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::GBSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::RBSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::SpeedRRI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::SpeedBBI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::SpeedGGI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::SpeedRGI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"),
Item::SpeedGBI => 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
Item::AmplifyI |
@ -637,7 +637,7 @@ impl Item {
"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_multiplier() - 100,
self.into_skill().unwrap().effect().last().unwrap().get_multiplier() - 100,
self.into_skill().unwrap().effect().last().unwrap().get_duration()),
Item::TriageI |
@ -749,26 +749,26 @@ impl Item {
Item::ChaosII => vec![Item::ChaosI, Item::ChaosI, Item::ChaosI],
Item::ChaosIII => vec![Item::ChaosII, Item::ChaosII, Item::ChaosII],
Item::RedPowerI => vec![Item::Power, Item::Red, Item::Red],
Item::GreenPowerI => vec![Item::Power, Item::Green, Item::Green],
Item::BluePowerI => vec![Item::Power, Item::Blue, Item::Blue],
Item::GRDI => vec![Item::Power, Item::Red, Item::Green],
Item::GBDI => vec![Item::Power, Item::Green, Item::Blue],
Item::RBDI => vec![Item::Power, Item::Red, Item::Blue],
Item::PowerRRI => vec![Item::Power, Item::Red, Item::Red],
Item::PowerGGI => vec![Item::Power, Item::Green, Item::Green],
Item::PowerBBI => vec![Item::Power, Item::Blue, Item::Blue],
Item::PowerRGI => vec![Item::Power, Item::Red, Item::Green],
Item::PowerGBI => vec![Item::Power, Item::Green, Item::Blue],
Item::PowerRBI => vec![Item::Power, Item::Red, Item::Blue],
Item::RedLifeI => vec![Item::Life, Item::Red, Item::Red],
Item::GreenLifeI => vec![Item::Life, Item::Green, Item::Green],
Item::BlueLifeI => vec![Item::Life, Item::Blue, Item::Blue],
Item::GRLI => vec![Item::Life, Item::Red, Item::Green],
Item::GBLI => vec![Item::Life, Item::Green, Item::Blue],
Item::RBLI => vec![Item::Life, Item::Red, Item::Blue],
Item::LifeRRI => vec![Item::Life, Item::Red, Item::Red],
Item::LifeGGI => vec![Item::Life, Item::Green, Item::Green],
Item::LifeBBI => vec![Item::Life, Item::Blue, Item::Blue],
Item::LifeRGI => vec![Item::Life, Item::Red, Item::Green],
Item::LifeGBI => vec![Item::Life, Item::Green, Item::Blue],
Item::LifeRBI => vec![Item::Life, Item::Red, Item::Blue],
Item::RedSpeedI => vec![Item::Speed, Item::Red, Item::Red],
Item::GreenSpeedI => vec![Item::Speed, Item::Green, Item::Green],
Item::BlueSpeedI => vec![Item::Speed, Item::Blue, Item::Blue],
Item::GRSpeedI => vec![Item::Speed, Item::Red, Item::Green],
Item::GBSpeedI => vec![Item::Speed, Item::Green, Item::Blue],
Item::RBSpeedI => vec![Item::Speed, Item::Red, Item::Blue],
Item::SpeedRRI => vec![Item::Speed, Item::Red, Item::Red],
Item::SpeedGGI => vec![Item::Speed, Item::Green, Item::Green],
Item::SpeedBBI => vec![Item::Speed, Item::Blue, Item::Blue],
Item::SpeedRGI => vec![Item::Speed, Item::Red, Item::Green],
Item::SpeedGBI => vec![Item::Speed, Item::Green, Item::Blue],
Item::SpeedRBI => vec![Item::Speed, Item::Red, Item::Blue],
_ => vec![*self],
}
@ -891,28 +891,28 @@ impl From<Spec> for Item {
fn from(spec: Spec) -> Item {
match spec {
Spec::Speed => Item::Speed,
Spec::RedSpeedI => Item::RedSpeedI,
Spec::BlueSpeedI => Item::BlueSpeedI,
Spec::GreenSpeedI => Item::GreenSpeedI,
Spec::GRSpeedI => Item::GRSpeedI,
Spec::GBSpeedI => Item::GBSpeedI,
Spec::RBSpeedI => Item::RBSpeedI,
Spec::SpeedRRI => Item::SpeedRRI,
Spec::SpeedBBI => Item::SpeedBBI,
Spec::SpeedGGI => Item::SpeedGGI,
Spec::SpeedRGI => Item::SpeedRGI,
Spec::SpeedGBI => Item::SpeedGBI,
Spec::SpeedRBI => Item::SpeedRBI,
Spec::Power => Item::Power,
Spec::RedPowerI => Item::RedPowerI,
Spec::BluePowerI => Item::BluePowerI,
Spec::GreenPowerI => Item::GreenPowerI,
Spec::GRDI => Item::GRDI,
Spec::GBDI => Item::GBDI,
Spec::RBDI => Item::RBDI,
Spec::PowerRRI => Item::PowerRRI,
Spec::PowerBBI => Item::PowerBBI,
Spec::PowerGGI => Item::PowerGGI,
Spec::PowerRGI => Item::PowerRGI,
Spec::PowerGBI => Item::PowerGBI,
Spec::PowerRBI => Item::PowerRBI,
Spec::Life => Item::Life,
Spec::GRLI => Item::GRLI,
Spec::GBLI => Item::GBLI,
Spec::RBLI => Item::RBLI,
Spec::GreenLifeI => Item::GreenLifeI,
Spec::RedLifeI => Item::RedLifeI,
Spec::BlueLifeI => Item::BlueLifeI,
Spec::LifeRGI => Item::LifeRGI,
Spec::LifeGBI => Item::LifeGBI,
Spec::LifeRBI => Item::LifeRBI,
Spec::LifeGGI => Item::LifeGGI,
Spec::LifeRRI => Item::LifeRRI,
Spec::LifeBBI => Item::LifeBBI,
// _ => 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::ChaosIII.combo(), item: Item::ChaosIII },
Combo { components: Item::RedPowerI.combo(), item: Item::RedPowerI },
Combo { components: Item::GreenPowerI.combo(), item: Item::GreenPowerI },
Combo { components: Item::BluePowerI.combo(), item: Item::BluePowerI },
Combo { components: Item::GRDI.combo(), item: Item::GRDI },
Combo { components: Item::GBDI.combo(), item: Item::GBDI },
Combo { components: Item::RBDI.combo(), item: Item::RBDI },
Combo { components: Item::PowerRRI.combo(), item: Item::PowerRRI },
Combo { components: Item::PowerGGI.combo(), item: Item::PowerGGI },
Combo { components: Item::PowerBBI.combo(), item: Item::PowerBBI },
Combo { components: Item::PowerRGI.combo(), item: Item::PowerRGI },
Combo { components: Item::PowerGBI.combo(), item: Item::PowerGBI },
Combo { components: Item::PowerRBI.combo(), item: Item::PowerRBI },
Combo { components: Item::RedLifeI.combo(), item: Item::RedLifeI },
Combo { components: Item::GreenLifeI.combo(), item: Item::GreenLifeI },
Combo { components: Item::BlueLifeI.combo(), item: Item::BlueLifeI },
Combo { components: Item::GRLI.combo(), item: Item::GRLI },
Combo { components: Item::GBLI.combo(), item: Item::GBLI },
Combo { components: Item::RBLI.combo(), item: Item::RBLI },
Combo { components: Item::LifeRRI.combo(), item: Item::LifeRRI },
Combo { components: Item::LifeGGI.combo(), item: Item::LifeGGI },
Combo { components: Item::LifeBBI.combo(), item: Item::LifeBBI },
Combo { components: Item::LifeRGI.combo(), item: Item::LifeRGI },
Combo { components: Item::LifeGBI.combo(), item: Item::LifeGBI },
Combo { components: Item::LifeRBI.combo(), item: Item::LifeRBI },
Combo { components: Item::RedSpeedI.combo(), item: Item::RedSpeedI },
Combo { components: Item::GreenSpeedI.combo(), item: Item::GreenSpeedI },
Combo { components: Item::BlueSpeedI.combo(), item: Item::BlueSpeedI },
Combo { components: Item::GRSpeedI.combo(), item: Item::GRSpeedI },
Combo { components: Item::GBSpeedI.combo(), item: Item::GBSpeedI },
Combo { components: Item::RBSpeedI.combo(), item: Item::RBSpeedI },
Combo { components: Item::SpeedRRI.combo(), item: Item::SpeedRRI },
Combo { components: Item::SpeedGGI.combo(), item: Item::SpeedGGI },
Combo { components: Item::SpeedBBI.combo(), item: Item::SpeedBBI },
Combo { components: Item::SpeedRGI.combo(), item: Item::SpeedRGI },
Combo { components: Item::SpeedGBI.combo(), item: Item::SpeedGBI },
Combo { components: Item::SpeedRBI.combo(), item: Item::SpeedRBI },
];
@ -1071,6 +1071,7 @@ pub struct ItemInfo {
pub item: Item,
pub spec: bool,
pub skill: bool,
pub values: Option<SpecValues>,
pub description: String,
}
@ -1101,6 +1102,10 @@ pub fn item_info() -> ItemInfoCtr {
spec: v.into_spec().is_some(),
skill: v.into_skill().is_some(),
description: v.into_description(),
values: match v.into_spec() {
Some(s) => Some(s.values()),
None => None
},
})
.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 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)]
pub enum Spec {
Speed,
RedSpeedI,
BlueSpeedI,
GreenSpeedI,
GRSpeedI,
GBSpeedI,
RBSpeedI,
SpeedRRI,
SpeedBBI,
SpeedGGI,
SpeedRGI,
SpeedGBI,
SpeedRBI,
// Pure redLife has to come first as it applies the base amount
// that is multiplied
Life,
GreenLifeI,
RedLifeI,
BlueLifeI,
GRLI,
GBLI,
RBLI,
LifeGGI,
LifeRRI,
LifeBBI,
LifeRGI,
LifeGBI,
LifeRBI,
Power,
RedPowerI,
GreenPowerI,
BluePowerI,
GRDI,
GBDI,
RBDI,
PowerRRI,
PowerGGI,
PowerBBI,
PowerRGI,
PowerGBI,
PowerRBI,
}
impl Spec {
pub fn affects(&self) -> Vec<Stat> {
match *self {
Spec::Power => vec![Stat::BluePower, Stat::RedPower, Stat::GreenPower],
Spec::RedPowerI => vec![Stat::RedPower],
Spec::GreenPowerI => vec![Stat::GreenPower],
Spec::BluePowerI => vec![Stat::BluePower],
Spec::GRDI => vec![Stat::GreenPower, Stat::RedPower],
Spec::GBDI => vec![Stat::GreenPower, Stat::BluePower],
Spec::RBDI => vec![Stat::RedPower, Stat::BluePower],
Spec::PowerRRI => vec![Stat::RedPower],
Spec::PowerGGI => vec![Stat::GreenPower],
Spec::PowerBBI => vec![Stat::BluePower],
Spec::PowerRGI => vec![Stat::GreenPower, Stat::RedPower],
Spec::PowerGBI => vec![Stat::GreenPower, Stat::BluePower],
Spec::PowerRBI => vec![Stat::RedPower, Stat::BluePower],
Spec::Speed => vec![Stat::Speed],
Spec::RedSpeedI => vec![Stat::Speed],
Spec::BlueSpeedI => vec![Stat::Speed],
Spec::GreenSpeedI => vec![Stat::Speed],
Spec::GRSpeedI => vec![Stat::Speed],
Spec::GBSpeedI => vec![Stat::Speed],
Spec::RBSpeedI => vec![Stat::Speed],
Spec::SpeedRRI => vec![Stat::Speed],
Spec::SpeedBBI => vec![Stat::Speed],
Spec::SpeedGGI => vec![Stat::Speed],
Spec::SpeedRGI => vec![Stat::Speed],
Spec::SpeedGBI => vec![Stat::Speed],
Spec::SpeedRBI => vec![Stat::Speed],
Spec::Life => vec![Stat::GreenLife],
Spec::RedLifeI => vec![Stat::RedLife],
Spec::BlueLifeI => vec![Stat::BlueLife],
Spec::GreenLifeI => vec![Stat::GreenLife],
Spec::GRLI => vec![Stat::GreenLife, Stat::RedLife],
Spec::GBLI => vec![Stat::GreenLife, Stat::BlueLife],
Spec::RBLI => vec![Stat::BlueLife, Stat::RedLife],
Spec::LifeRRI => vec![Stat::RedLife],
Spec::LifeBBI => vec![Stat::BlueLife],
Spec::LifeGGI => vec![Stat::GreenLife],
Spec::LifeRGI => vec![Stat::GreenLife, Stat::RedLife],
Spec::LifeGBI => vec![Stat::GreenLife, Stat::BlueLife],
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;
match *self {
// Upgrades to Power Spec
Spec::Power => modified + base.pct(5),
Spec::RedPowerI => modified + {
let mut pct = 10;
if player_colours.red >= 5 { pct += 10 };
if player_colours.red >= 10 { pct += 20 };
if player_colours.red >= 20 { pct += 40 };
base.pct(pct)
Spec::Power |
Spec::PowerRRI |
Spec::PowerGGI |
Spec::PowerBBI |
Spec::PowerRGI |
Spec::PowerGBI |
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;
if player_colours.green >= 5 { pct += 10 };
if player_colours.green >= 10 { pct += 20 };
if player_colours.green >= 20 { pct += 40 };
base.pct(pct)
},
Spec::BluePowerI => modified + {
let mut pct = 10;
if player_colours.blue >= 5 { pct += 10 };
if player_colours.blue >= 10 { pct += 20 };
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
Spec::Life |
Spec::LifeRRI |
Spec::LifeGGI |
Spec::LifeBBI |
Spec::LifeRGI |
Spec::LifeGBI |
Spec::LifeRBI => modified + {
let spec_values = self.values();
construct_colour_total * (spec_values.bonuses.iter()
.fold(spec_values.base, |acc, s| acc + s.get_bonus(player_colours)))
},
}
}