rm free and bound

This commit is contained in:
ntr 2019-11-28 15:48:31 +10:00
parent 33ad4db8f5
commit 4920821ec2
7 changed files with 48 additions and 48 deletions

View File

@ -98,7 +98,7 @@ function Construct(props) {
const duplicateSkill = construct.skills.length !== 0 && construct.skills.every(sk => { const duplicateSkill = construct.skills.length !== 0 && construct.skills.every(sk => {
if (!itemEquip && itemEquip !== 0) return false; if (!itemEquip && itemEquip !== 0) return false;
if (!sk) return false; if (!sk) return false;
return sk.skill === vbox.bound[itemEquip]; return sk.skill === vbox.stash[itemEquip];
}); });
const tutorialDisableEquip = tutorialShouldDisableEquip(tutorial, iter, instance, construct); const tutorialDisableEquip = tutorialShouldDisableEquip(tutorial, iter, instance, construct);
function onClick(e) { function onClick(e) {
@ -136,7 +136,7 @@ function Construct(props) {
return true; return true;
} }
const equipping = skillList.includes(vbox.bound[itemEquip]) && !skill const equipping = skillList.includes(vbox.stash[itemEquip]) && !skill
&& !tutorialDisableEquip && !duplicateSkill && i === construct.skills.length; && !tutorialDisableEquip && !duplicateSkill && i === construct.skills.length;
const border = () => { const border = () => {
if (!skill) return ''; if (!skill) return '';
@ -169,7 +169,7 @@ function Construct(props) {
const s = construct.specs[i]; const s = construct.specs[i];
if (!s) { if (!s) {
const equipping = specList.includes(vbox.bound[itemEquip]) && i === construct.specs.length; const equipping = specList.includes(vbox.stash[itemEquip]) && i === construct.specs.length;
const classes = `${equipping ? 'equipping' : 'gray'} empty`; const classes = `${equipping ? 'equipping' : 'gray'} empty`;
return ( return (
<button key={i} class={classes} disabled={!equipping} > <button key={i} class={classes} disabled={!equipping} >

View File

@ -48,7 +48,7 @@ class Combiner extends preact.Component {
class='combiner vbox-btn' class='combiner vbox-btn'
onClick={e => e.stopPropagation()} onClick={e => e.stopPropagation()}
onMouseDown={vboxBuySelected}> onMouseDown={vboxBuySelected}>
{`Buy ${vbox.free[item[0]][item[1]]} ${item[0] + 1}b`} {`Buy ${vbox.store[item[0]][item[1]]} ${item[0] + 1}b`}
</button> </button>
); );
} }

View File

@ -161,7 +161,7 @@ class Vbox extends preact.Component {
function stashHdr() { function stashHdr() {
const refund = storeSelect.length === 0 && stashSelect.length === 1 const refund = storeSelect.length === 0 && stashSelect.length === 1
? itemInfo.items.find(i => i.item === vbox.bound[stashSelect[0]]).cost ? itemInfo.items.find(i => i.item === vbox.stash[stashSelect[0]]).cost
: 0; : 0;
const tutorialDisabled = tutorial && tutorial < 8 const tutorialDisabled = tutorial && tutorial < 8
&& instance.time_control === 'Practice' && instance.rounds.length === 1; && instance.time_control === 'Practice' && instance.rounds.length === 1;

View File

@ -81,7 +81,7 @@ class stashElement extends preact.Component {
} }
if (notValidCombo) { if (notValidCombo) {
setInfo(vbox.bound[i]); setInfo(vbox.stash[i]);
return setVboxSelected({ storeSelect: [], stashSelect: [i] }); return setVboxSelected({ storeSelect: [], stashSelect: [i] });
} }
@ -123,7 +123,7 @@ class stashElement extends preact.Component {
onDragOver={ev => ev.preventDefault()} onDragOver={ev => ev.preventDefault()}
onDrop={stashClick} onDrop={stashClick}
> >
{range(0, 6).map(i => stashBtn(vbox.bound[i], i))} {range(0, 6).map(i => stashBtn(vbox.stash[i], i.toString()))}
</div> </div>
); );
} }

View File

@ -32,7 +32,7 @@ class storeElement extends preact.Component {
const { storeSelect, stashSelect } = vboxSelected; const { storeSelect, stashSelect } = vboxSelected;
function availableBtn(v, group, index) { function availableBtn(v, group, index) {
if (!v) return <button disabled class='empty' key={(group * 10) + index} >&nbsp;</button>; if (!v) return <button disabled class='empty' key={group + index} >&nbsp;</button>;
const selected = storeSelect.length && storeSelect.some(vs => vs[0] === group && vs[1] === index); const selected = storeSelect.length && storeSelect.some(vs => vs[0] === group && vs[1] === index);
const notValidCombo = vboxHighlight && !vboxHighlight.includes(v); const notValidCombo = vboxHighlight && !vboxHighlight.includes(v);
@ -63,7 +63,7 @@ class storeElement extends preact.Component {
const disabled = vbox.bits <= group; const disabled = vbox.bits <= group;
return ( return (
<label <label
key={group * 10 + index} key={group + index}
onDragEnd={clearVboxSelected}> onDragEnd={clearVboxSelected}>
<button <button
class={classes} class={classes}
@ -81,11 +81,11 @@ class storeElement extends preact.Component {
<div class='store' <div class='store'
onClick={e => e.stopPropagation()}> onClick={e => e.stopPropagation()}>
<div class="vbox-colours"> <div class="vbox-colours">
{range(0, 6).map(i => availableBtn(vbox.free[0][i], 0, i))} {range(0, 6).map(i => availableBtn(vbox.store['Colours'][i], 'Colours', i.toString()))}
</div> </div>
<div class="vbox-items"> <div class="vbox-items">
{range(0, 3).map(i => availableBtn(vbox.free[1][i], 1, i))} {range(0, 3).map(i => availableBtn(vbox.store['Skills'][i], 'Skills', i.toString()))}
{range(0, 3).map(i => availableBtn(vbox.free[2][i], 2, i))} {range(0, 3).map(i => availableBtn(vbox.store['Specs'][i], 'Specs', i.toString()))}
</div> </div>
</div> </div>
); );

View File

@ -23,8 +23,8 @@ function setVboxState(dispatch, vboxSelected, state) {
if (!(storeSelect.length === 0 && stashSelect.length === 0)) { if (!(storeSelect.length === 0 && stashSelect.length === 0)) {
vboxHighlight = []; vboxHighlight = [];
const stashItems = stashSelect.map(j => vbox.bound[j]); const stashItems = stashSelect.map(j => vbox.stash[j]);
const shopItems = storeSelect.map(j => vbox.free[j[0]][j[1]]); const shopItems = storeSelect.map(j => vbox.store[j[0]][j[1]]);
const selectedItems = stashItems.concat(shopItems); const selectedItems = stashItems.concat(shopItems);
const itemCount = countBy(selectedItems, co => co); const itemCount = countBy(selectedItems, co => co);
@ -55,12 +55,12 @@ function setVboxState(dispatch, vboxSelected, state) {
const vboxInfo = () => { const vboxInfo = () => {
if (vboxCombiner) return vboxCombiner; if (vboxCombiner) return vboxCombiner;
if (itemUnequip.length) return itemUnequip[1]; if (itemUnequip.length) return itemUnequip[1];
const stashBase = stashSelect.find(i => !(['Red', 'Blue', 'Green'].includes(vbox.bound[i]))); const stashBase = stashSelect.find(i => !(['Red', 'Blue', 'Green'].includes(vbox.stash[i])));
if (stashBase > -1) return vbox.bound[stashBase]; if (stashBase > -1) return vbox.stash[stashBase];
const storeBase = storeSelect.find(j => !(['Red', 'Blue', 'Green'].includes(vbox.free[j[0]][j[1]]))); const storeBase = storeSelect.find(j => !(['Red', 'Blue', 'Green'].includes(vbox.store[j[0]][j[1]])));
if (storeBase) return vbox.free[storeBase[0]][storeBase[1]]; if (storeBase) return vbox.store[storeBase[0]][storeBase[1]];
if (stashSelect.length > 0) return vbox.bound[stashSelect[0]]; if (stashSelect.length > 0) return vbox.stash[stashSelect[0]];
if (storeSelect.length > 0) return vbox.free[storeSelect[0][0]][storeSelect[0][1]]; if (storeSelect.length > 0) return vbox.store[storeSelect[0][0]][storeSelect[0][1]];
return false; return false;
}; };

View File

@ -24,21 +24,21 @@ function tutorialVbox(player, store, tutorial) {
if (vbox.bits < 29) { if (vbox.bits < 29) {
stage += 1; stage += 1;
} else { } else {
vbox.free[0] = vbox.free[0].slice(0, 2); vbox.store[0] = vbox.store[0].slice(0, 2);
vbox.free[1] = []; vbox.store[1] = [];
vbox.free[2] = []; vbox.store[2] = [];
vbox.bound.fill(null, 0, 3); vbox.stash.fill(null, 0, 3);
} }
} }
if (stage === 2) { if (stage === 2) {
if (!(vbox.bound.slice(0, 3).every(i => i === 'Attack') && vbox.bound.length >= 3)) { if (!(vbox.stash.slice(0, 3).every(i => i === 'Attack') && vbox.stash.length >= 3)) {
stage += 1; stage += 1;
} else { } else {
vbox.free[0] = vbox.free[0].slice(0, 2); vbox.store[0] = vbox.store[0].slice(0, 2);
vbox.free[1] = []; vbox.store[1] = [];
vbox.free[2] = []; vbox.store[2] = [];
vbox.bound.fill(null, 1, 3); vbox.stash.fill(null, 1, 3);
} }
} }
@ -46,21 +46,21 @@ function tutorialVbox(player, store, tutorial) {
if (player.constructs[0].skills.length !== 0) { if (player.constructs[0].skills.length !== 0) {
stage += 1; stage += 1;
} else { } else {
vbox.free[0] = vbox.free[0].slice(0, 2); vbox.store[0] = vbox.store[0].slice(0, 2);
vbox.free[1] = []; vbox.store[1] = [];
vbox.free[2] = []; vbox.store[2] = [];
vbox.bound.fill(null, 0, 2); vbox.stash.fill(null, 0, 2);
} }
} }
if (stage === 4) { if (stage === 4) {
if (!vbox.free[2][0] || vbox.bits < 24) { if (!vbox.store[2][0] || vbox.bits < 24) {
stage += 1; stage += 1;
} else { } else {
vbox.free[0] = []; vbox.store[0] = [];
vbox.free[1] = []; vbox.store[1] = [];
vbox.free[2] = vbox.free[2].slice(0, 1); vbox.store[2] = vbox.store[2].slice(0, 1);
vbox.bound.fill(null, 0, 2); vbox.stash.fill(null, 0, 2);
} }
} }
@ -68,10 +68,10 @@ function tutorialVbox(player, store, tutorial) {
if (player.constructs[0].specs.length !== 0) { if (player.constructs[0].specs.length !== 0) {
stage += 1; stage += 1;
} else { } else {
vbox.free[0] = []; vbox.store[0] = [];
vbox.free[1] = []; vbox.store[1] = [];
vbox.free[2] = vbox.free[2].slice(0, 1); vbox.store[2] = vbox.store[2].slice(0, 1);
vbox.bound.fill(null, 0, 2); vbox.stash.fill(null, 0, 2);
} }
} }
@ -79,9 +79,9 @@ function tutorialVbox(player, store, tutorial) {
if (player.constructs.every(c => c.skills.length !== 0)) { if (player.constructs.every(c => c.skills.length !== 0)) {
stage += 1; stage += 1;
} else { } else {
vbox.free[0] = []; vbox.store[0] = [];
vbox.free[1] = []; vbox.store[1] = [];
vbox.free[2] = []; vbox.store[2] = [];
} }
} }
@ -89,9 +89,9 @@ function tutorialVbox(player, store, tutorial) {
if (vbox.bits < 25) { if (vbox.bits < 25) {
stage += 1; stage += 1;
} else { } else {
vbox.free[0] = []; vbox.store[0] = [];
vbox.free[1] = []; vbox.store[1] = [];
vbox.free[2] = []; vbox.store[2] = [];
} }
} }
store.dispatch(actions.setTutorial(stage)); store.dispatch(actions.setTutorial(stage));