Merge branch 'develop' of ssh://git.mnml.gg:40022/~/mnml into develop
This commit is contained in:
@@ -24,8 +24,8 @@ const addState = connect(
|
||||
tutorial,
|
||||
} = state;
|
||||
|
||||
function sendVboxAcceptEquip(constructId) {
|
||||
return ws.sendVboxAcceptEquip(instance.id, vboxSelected.storeSelect[0][0], vboxSelected.storeSelect[0][1], constructId);
|
||||
function sendVboxBuyEquip(constructId) {
|
||||
return ws.sendVboxBuyEquip(instance.id, vboxSelected.storeSelect[0][0], vboxSelected.storeSelect[0][1], constructId);
|
||||
}
|
||||
|
||||
function sendVboxApply(constructId, i) {
|
||||
@@ -40,7 +40,7 @@ const addState = connect(
|
||||
instance,
|
||||
player,
|
||||
account,
|
||||
sendVboxAcceptEquip,
|
||||
sendVboxBuyEquip,
|
||||
sendVboxUnequipApply,
|
||||
sendVboxApply,
|
||||
itemInfo,
|
||||
@@ -83,7 +83,7 @@ function Construct(props) {
|
||||
itemInfo,
|
||||
// Function Calls
|
||||
sendVboxApply,
|
||||
sendVboxAcceptEquip,
|
||||
sendVboxBuyEquip,
|
||||
sendVboxUnequipApply,
|
||||
setItemUnequip,
|
||||
setInfo,
|
||||
@@ -98,7 +98,7 @@ function Construct(props) {
|
||||
const duplicateSkill = construct.skills.length !== 0 && construct.skills.every(sk => {
|
||||
if (!itemEquip && itemEquip !== 0) 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);
|
||||
function onClick(e) {
|
||||
@@ -106,7 +106,7 @@ function Construct(props) {
|
||||
e.preventDefault();
|
||||
if (duplicateSkill || tutorialDisableEquip) return true;
|
||||
if (itemEquip !== -1) return sendVboxApply(construct.id, itemEquip);
|
||||
if (vboxSelected.storeSelect.length === 1) return sendVboxAcceptEquip(construct.id);
|
||||
if (vboxSelected.storeSelect.length === 1) return sendVboxBuyEquip(construct.id);
|
||||
if (itemUnequip.length && itemUnequip[0] !== construct.id) return sendVboxUnequipApply(construct.id);
|
||||
setItemUnequip([]);
|
||||
return true;
|
||||
@@ -136,7 +136,7 @@ function Construct(props) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const equipping = skillList.includes(vbox.bound[itemEquip]) && !skill
|
||||
const equipping = skillList.includes(vbox.stash[itemEquip]) && !skill
|
||||
&& !tutorialDisableEquip && !duplicateSkill && i === construct.skills.length;
|
||||
const border = () => {
|
||||
if (!skill) return '';
|
||||
@@ -169,7 +169,7 @@ function Construct(props) {
|
||||
const s = construct.specs[i];
|
||||
|
||||
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`;
|
||||
return (
|
||||
<button key={i} class={classes} disabled={!equipping} >
|
||||
@@ -261,7 +261,7 @@ class InstanceConstructs extends preact.Component {
|
||||
// Function calls
|
||||
setInfo,
|
||||
sendVboxApply,
|
||||
sendVboxAcceptEquip,
|
||||
sendVboxBuyEquip,
|
||||
sendVboxUnequipApply,
|
||||
setItemUnequip,
|
||||
} = props;
|
||||
@@ -281,7 +281,7 @@ class InstanceConstructs extends preact.Component {
|
||||
setItemUnequip,
|
||||
player,
|
||||
sendVboxApply,
|
||||
sendVboxAcceptEquip,
|
||||
sendVboxBuyEquip,
|
||||
sendVboxUnequipApply,
|
||||
setInfo,
|
||||
itemInfo,
|
||||
|
||||
@@ -26,10 +26,17 @@ class Combiner extends preact.Component {
|
||||
|
||||
const { stashSelect, storeSelect } = vboxSelected;
|
||||
|
||||
function cost([group, i]) {
|
||||
if (group === 'Colours') return 1;
|
||||
if (group === 'Skills') return 2;
|
||||
if (group === 'Specs') return 3;
|
||||
};
|
||||
|
||||
|
||||
if (vboxCombiner) {
|
||||
const combinerComboText = vboxCombiner.replace('Plus', '+');
|
||||
let bits = 0;
|
||||
storeSelect.forEach(item => bits += item[0] + 1);
|
||||
storeSelect.forEach(item => bits += cost(item));
|
||||
return (
|
||||
<button
|
||||
class='combiner vbox-btn'
|
||||
@@ -48,7 +55,7 @@ class Combiner extends preact.Component {
|
||||
class='combiner vbox-btn'
|
||||
onClick={e => e.stopPropagation()}
|
||||
onMouseDown={vboxBuySelected}>
|
||||
{`Buy ${vbox.free[item[0]][item[1]]} ${item[0] + 1}b`}
|
||||
{`Buy ${vbox.store[item[0]][item[1]]} ${cost(item)}b`}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -27,22 +27,22 @@ const addState = connect(
|
||||
return ws.clearTutorial(instance.id);
|
||||
}
|
||||
|
||||
function sendVboxDiscard() {
|
||||
return ws.sendVboxDiscard(instance.id);
|
||||
function sendVboxRefill() {
|
||||
return ws.sendVboxRefill(instance.id);
|
||||
}
|
||||
|
||||
function sendVboxAccept(group, index) {
|
||||
function sendVboxBuy(group, index) {
|
||||
if (!(vboxSelected.storeSelect.length === 1 && vboxSelected.stashSelect.length === 0)) return false;
|
||||
document.activeElement.blur();
|
||||
return ws.sendVboxAccept(instance.id, group, index);
|
||||
return ws.sendVboxBuy(instance.id, group, index);
|
||||
}
|
||||
|
||||
function sendVboxCombine() {
|
||||
return ws.sendVboxCombine(instance.id, vboxSelected.stashSelect, vboxSelected.storeSelect);
|
||||
}
|
||||
|
||||
function sendVboxReclaim(i) {
|
||||
return ws.sendVboxReclaim(instance.id, i);
|
||||
function sendVboxRefund(i) {
|
||||
return ws.sendVboxRefund(instance.id, i);
|
||||
}
|
||||
|
||||
function sendItemUnequip([constructId, item]) {
|
||||
@@ -60,10 +60,10 @@ const addState = connect(
|
||||
|
||||
clearTutorial,
|
||||
sendItemUnequip,
|
||||
sendVboxAccept,
|
||||
sendVboxBuy,
|
||||
sendVboxCombine,
|
||||
sendVboxDiscard,
|
||||
sendVboxReclaim,
|
||||
sendVboxRefill,
|
||||
sendVboxRefund,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -109,10 +109,10 @@ class Vbox extends preact.Component {
|
||||
clearTutorial,
|
||||
dispatchVboxSelect,
|
||||
sendItemUnequip,
|
||||
sendVboxAccept,
|
||||
sendVboxBuy,
|
||||
sendVboxCombine,
|
||||
sendVboxDiscard,
|
||||
sendVboxReclaim,
|
||||
sendVboxRefill,
|
||||
sendVboxRefund,
|
||||
setInfo,
|
||||
} = args;
|
||||
|
||||
@@ -122,7 +122,7 @@ class Vbox extends preact.Component {
|
||||
|
||||
const setVboxSelected = v => dispatchVboxSelect(v, { itemInfo, itemUnequip, vbox });
|
||||
const clearVboxSelected = () => setVboxSelected({ storeSelect: [], stashSelect: [] });
|
||||
const vboxBuySelected = () => sendVboxAccept(storeSelect[0][0], storeSelect[0][1]);
|
||||
const vboxBuySelected = () => sendVboxBuy(storeSelect[0][0], storeSelect[0][1]);
|
||||
|
||||
function vboxHover(e, v) {
|
||||
if (v) {
|
||||
@@ -151,7 +151,7 @@ class Vbox extends preact.Component {
|
||||
&& instance.time_control === 'Practice' && instance.rounds.length === 1)
|
||||
}
|
||||
onClick={e => e.stopPropagation()}
|
||||
onMouseDown={() => sendVboxDiscard()}>
|
||||
onMouseDown={() => sendVboxRefill()}>
|
||||
refill <br />
|
||||
2b
|
||||
</button>
|
||||
@@ -161,7 +161,7 @@ class Vbox extends preact.Component {
|
||||
|
||||
function stashHdr() {
|
||||
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;
|
||||
const tutorialDisabled = tutorial && tutorial < 8
|
||||
&& instance.time_control === 'Practice' && instance.rounds.length === 1;
|
||||
@@ -172,7 +172,7 @@ class Vbox extends preact.Component {
|
||||
onClick={e => e.stopPropagation()}
|
||||
onMouseDown={e => {
|
||||
e.stopPropagation();
|
||||
sendVboxReclaim(vboxSelected.stashSelect[0]);
|
||||
sendVboxRefund(vboxSelected.stashSelect[0]);
|
||||
}}>
|
||||
refund <br />
|
||||
{refund}b
|
||||
|
||||
@@ -81,7 +81,7 @@ class stashElement extends preact.Component {
|
||||
}
|
||||
|
||||
if (notValidCombo) {
|
||||
setInfo(vbox.bound[i]);
|
||||
setInfo(vbox.stash[i]);
|
||||
return setVboxSelected({ storeSelect: [], stashSelect: [i] });
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class stashElement extends preact.Component {
|
||||
onDragOver={ev => ev.preventDefault()}
|
||||
onDrop={stashClick}
|
||||
>
|
||||
{range(0, 6).map(i => stashBtn(vbox.bound[i], i))}
|
||||
{range(0, 6).map(i => stashBtn(vbox.stash[i], i.toString()))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class storeElement extends preact.Component {
|
||||
const { storeSelect, stashSelect } = vboxSelected;
|
||||
|
||||
function availableBtn(v, group, index) {
|
||||
if (!v) return <button disabled class='empty' key={(group * 10) + index} > </button>;
|
||||
if (!v) return <button disabled class='empty' key={group + index} > </button>;
|
||||
const selected = storeSelect.length && storeSelect.some(vs => vs[0] === group && vs[1] === index);
|
||||
|
||||
const notValidCombo = vboxHighlight && !vboxHighlight.includes(v);
|
||||
@@ -63,7 +63,7 @@ class storeElement extends preact.Component {
|
||||
const disabled = vbox.bits <= group;
|
||||
return (
|
||||
<label
|
||||
key={group * 10 + index}
|
||||
key={group + index}
|
||||
onDragEnd={clearVboxSelected}>
|
||||
<button
|
||||
class={classes}
|
||||
@@ -81,11 +81,11 @@ class storeElement extends preact.Component {
|
||||
<div class='store'
|
||||
onClick={e => e.stopPropagation()}>
|
||||
<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 class="vbox-items">
|
||||
{range(0, 3).map(i => availableBtn(vbox.free[1][i], 1, i))}
|
||||
{range(0, 3).map(i => availableBtn(vbox.free[2][i], 2, i))}
|
||||
{range(0, 3).map(i => availableBtn(vbox.store['Skills'][i], 'Skills', i.toString()))}
|
||||
{range(0, 3).map(i => availableBtn(vbox.store['Specs'][i], 'Specs', i.toString()))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -21,10 +21,10 @@ function setVboxState(dispatch, vboxSelected, state) {
|
||||
let vboxCombiner = false;
|
||||
let vboxHighlight = false;
|
||||
|
||||
if (!(storeSelect.length === 0 && stashSelect.length === 0)) {
|
||||
if (storeSelect.length || stashSelect.length) {
|
||||
vboxHighlight = [];
|
||||
const stashItems = stashSelect.map(j => vbox.bound[j]);
|
||||
const shopItems = storeSelect.map(j => vbox.free[j[0]][j[1]]);
|
||||
const stashItems = stashSelect.map(j => vbox.stash[j]);
|
||||
const shopItems = storeSelect.map(j => vbox.store[j[0]][j[1]]);
|
||||
|
||||
const selectedItems = stashItems.concat(shopItems);
|
||||
const itemCount = countBy(selectedItems, co => co);
|
||||
@@ -55,18 +55,18 @@ function setVboxState(dispatch, vboxSelected, state) {
|
||||
const vboxInfo = () => {
|
||||
if (vboxCombiner) return vboxCombiner;
|
||||
if (itemUnequip.length) return itemUnequip[1];
|
||||
const stashBase = stashSelect.find(i => !(['Red', 'Blue', 'Green'].includes(vbox.bound[i])));
|
||||
if (stashBase > -1) return vbox.bound[stashBase];
|
||||
const storeBase = storeSelect.find(j => !(['Red', 'Blue', 'Green'].includes(vbox.free[j[0]][j[1]])));
|
||||
if (storeBase) return vbox.free[storeBase[0]][storeBase[1]];
|
||||
if (stashSelect.length > 0) return vbox.bound[stashSelect[0]];
|
||||
if (storeSelect.length > 0) return vbox.free[storeSelect[0][0]][storeSelect[0][1]];
|
||||
const stashBase = stashSelect.find(i => !(['Red', 'Blue', 'Green'].includes(vbox.stash[i])));
|
||||
if (stashBase > -1) return vbox.stash[stashBase];
|
||||
const storeBase = storeSelect.find(j => !(['Red', 'Blue', 'Green'].includes(vbox.store[j[0]][j[1]])));
|
||||
if (storeBase) return vbox.store[storeBase[0]][storeBase[1]];
|
||||
if (stashSelect.length > 0) return vbox.stash[stashSelect[0]];
|
||||
if (storeSelect.length > 0) return vbox.store[storeSelect[0][0]][storeSelect[0][1]];
|
||||
return false;
|
||||
};
|
||||
|
||||
dispatch(actions.setVboxInfo(vboxInfo()));
|
||||
dispatch(actions.setVboxCombiner(vboxCombiner));
|
||||
dispatch(actions.setVboxHighlight(vboxHighlight));
|
||||
dispatch(actions.setVboxHighlight(vboxHighlight.length ? vboxHighlight : null));
|
||||
}
|
||||
|
||||
function genItemInfo(item, itemInfo, player) {
|
||||
@@ -124,5 +124,10 @@ function genItemInfo(item, itemInfo, player) {
|
||||
);
|
||||
}
|
||||
|
||||
function cost(group) {
|
||||
if (group === 'Colours') return 1;
|
||||
if (group === 'Skills') return 2;
|
||||
if (group === 'Specs') return 3;
|
||||
};
|
||||
|
||||
module.exports = { setVboxState, genItemInfo };
|
||||
module.exports = { setVboxState, genItemInfo, cost };
|
||||
|
||||
Reference in New Issue
Block a user