Merge branch 'develop' of ssh://git.mnml.gg:40022/~/mnml into develop

This commit is contained in:
Mashy
2019-11-28 17:49:10 +10:00
17 changed files with 462 additions and 340 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ export const setTeamSelect = value => ({ type: 'SET_TEAM_SELECT', value: Array.f
export const setTutorial = value => ({ type: 'SET_TUTORIAL', value });
export const setTutorialGame = value => ({ type: 'SET_TUTORIAL_GAME', value });
export const setVboxSelected = value => ({ type: 'SET_VBOX_SELECTED', value });
export const setVboxSelected = value => ({ type: 'SET_VBOX_SELECTED', value: Object.create(value) });
export const setVboxCombiner = value => ({ type: 'SET_VBOX_COMBINER', value });
export const setVboxHighlight = value => ({ type: 'SET_VBOX_HIGHLIGHT', value });
export const setVboxInfo = value => ({ type: 'SET_VBOX_INFO', value });
+10 -10
View File
@@ -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,
+9 -2
View File
@@ -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>
);
}
+16 -16
View File
@@ -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
+2 -2
View File
@@ -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>
);
}
+5 -5
View File
@@ -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} >&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 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>
);
+16 -11
View File
@@ -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 };
+4 -4
View File
@@ -45,10 +45,10 @@ module.exports = {
item: 'READY',
description: 'Ready for the game to begin. When all players are ready the first VBOX PHASE begins.',
},
reclaim: {
item: 'RECLAIM',
description: <p>Reclaim items refunding the listed cost of the item.<br />
Click to enable and then click the item to reclaim.</p>,
Refund: {
item: 'Refund',
description: <p>Refund items refunding the listed cost of the item.<br />
Click to enable and then click the item to Refund.</p>,
},
refill: {
item: 'REFILL',
+1
View File
@@ -10,6 +10,7 @@ function setupKeys(store) {
key('esc', () => store.dispatch(actions.setInfo(null)));
key('esc', () => store.dispatch(actions.setItemUnequip([])));
key('esc', () => store.dispatch(actions.setVboxSelected({ storeSelect: [], stashSelect: [] })));
key('esc', () => store.dispatch(actions.setVboxHighlight(null)));
key('esc', () => store.dispatch(actions.setMtxActive(null)));
}
+16 -21
View File
@@ -2,6 +2,7 @@ const toast = require('izitoast');
const cbor = require('borc');
const throttle = require('lodash/throttle');
const groupBy = require('lodash/groupBy');
const SOCKET_URL =
`${window.location.protocol === 'https:' ? 'wss://' : 'ws://'}${window.location.host}/api/ws`;
@@ -77,13 +78,13 @@ function createSocket(events) {
send(['InstanceChat', { instance_id: instanceId, index }]);
}
function sendVboxAccept(instanceId, group, index) {
send(['VboxAccept', { instance_id: instanceId, group, index }]);
function sendVboxBuy(instanceId, group, index) {
send(['VboxBuy', { instance_id: instanceId, group, index }]);
events.clearInstance();
}
function sendVboxAcceptEquip(instanceId, group, index, constructId) {
send(['VboxAcceptEquip', { instance_id: instanceId, group, index, construct_id: constructId }]);
function sendVboxBuyEquip(instanceId, group, index, constructId) {
send(['VboxBuy', { instance_id: instanceId, group, index, construct_id: constructId }]);
events.clearInstance();
}
@@ -102,18 +103,20 @@ function createSocket(events) {
events.clearInstance();
}
function sendVboxDiscard(instanceId) {
send(['VboxDiscard', { instance_id: instanceId }]);
function sendVboxRefill(instanceId) {
send(['VboxRefill', { instance_id: instanceId }]);
events.clearInstance();
}
function sendVboxCombine(instanceId, invIndicies, vboxIndicies) {
send(['VboxCombine', { instance_id: instanceId, inv_indices: invIndicies, vbox_indices: vboxIndicies }]);
const formatted = {};
vboxIndicies.forEach(p => formatted[p[0]] ? formatted[p[0]].push(p[1]) : formatted[p[0]] = [p[1]]);
send(['VboxCombine', { instance_id: instanceId, inv_indices: invIndicies, vbox_indices: formatted }]);
events.clearInstance();
}
function sendVboxReclaim(instanceId, index) {
send(['VboxReclaim', { instance_id: instanceId, index }]);
function sendVboxRefund(instanceId, index) {
send(['VboxRefund', { instance_id: instanceId, index }]);
events.clearInstance();
}
@@ -204,12 +207,6 @@ function createSocket(events) {
send(['SubscriptionState', {}]);
}
function clearTutorial(instanceId) {
events.clearTutorial();
events.clearInstance();
sendInstanceState(instanceId);
}
// -------------
// Incoming
// -------------
@@ -416,12 +413,12 @@ function createSocket(events) {
sendInstanceChat,
sendInstanceLeave,
sendVboxAccept,
sendVboxAcceptEquip,
sendVboxBuy,
sendVboxBuyEquip,
sendVboxApply,
sendVboxReclaim,
sendVboxRefund,
sendVboxCombine,
sendVboxDiscard,
sendVboxRefill,
sendVboxUnequip,
sendVboxUnequipApply,
@@ -436,8 +433,6 @@ function createSocket(events) {
sendMtxBuy,
sendMtxConstructSpawn,
clearTutorial,
connect,
};
}
+29 -29
View File
@@ -24,21 +24,21 @@ function tutorialVbox(player, store, tutorial) {
if (vbox.bits < 29) {
stage += 1;
} else {
vbox.free[0] = vbox.free[0].slice(0, 2);
vbox.free[1] = [];
vbox.free[2] = [];
vbox.bound.fill(null, 0, 3);
vbox.store[0] = vbox.store[0].slice(0, 2);
vbox.store[1] = [];
vbox.store[2] = [];
vbox.stash.fill(null, 0, 3);
}
}
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;
} else {
vbox.free[0] = vbox.free[0].slice(0, 2);
vbox.free[1] = [];
vbox.free[2] = [];
vbox.bound.fill(null, 1, 3);
vbox.store[0] = vbox.store[0].slice(0, 2);
vbox.store[1] = [];
vbox.store[2] = [];
vbox.stash.fill(null, 1, 3);
}
}
@@ -46,21 +46,21 @@ function tutorialVbox(player, store, tutorial) {
if (player.constructs[0].skills.length !== 0) {
stage += 1;
} else {
vbox.free[0] = vbox.free[0].slice(0, 2);
vbox.free[1] = [];
vbox.free[2] = [];
vbox.bound.fill(null, 0, 2);
vbox.store[0] = vbox.store[0].slice(0, 2);
vbox.store[1] = [];
vbox.store[2] = [];
vbox.stash.fill(null, 0, 2);
}
}
if (stage === 4) {
if (!vbox.free[2][0] || vbox.bits < 24) {
if (!vbox.store[2][0] || vbox.bits < 24) {
stage += 1;
} else {
vbox.free[0] = [];
vbox.free[1] = [];
vbox.free[2] = vbox.free[2].slice(0, 1);
vbox.bound.fill(null, 0, 2);
vbox.store[0] = [];
vbox.store[1] = [];
vbox.store[2] = vbox.store[2].slice(0, 1);
vbox.stash.fill(null, 0, 2);
}
}
@@ -68,10 +68,10 @@ function tutorialVbox(player, store, tutorial) {
if (player.constructs[0].specs.length !== 0) {
stage += 1;
} else {
vbox.free[0] = [];
vbox.free[1] = [];
vbox.free[2] = vbox.free[2].slice(0, 1);
vbox.bound.fill(null, 0, 2);
vbox.store[0] = [];
vbox.store[1] = [];
vbox.store[2] = vbox.store[2].slice(0, 1);
vbox.stash.fill(null, 0, 2);
}
}
@@ -79,9 +79,9 @@ function tutorialVbox(player, store, tutorial) {
if (player.constructs.every(c => c.skills.length !== 0)) {
stage += 1;
} else {
vbox.free[0] = [];
vbox.free[1] = [];
vbox.free[2] = [];
vbox.store[0] = [];
vbox.store[1] = [];
vbox.store[2] = [];
}
}
@@ -89,9 +89,9 @@ function tutorialVbox(player, store, tutorial) {
if (vbox.bits < 25) {
stage += 1;
} else {
vbox.free[0] = [];
vbox.free[1] = [];
vbox.free[2] = [];
vbox.store[0] = [];
vbox.store[1] = [];
vbox.store[2] = [];
}
}
store.dispatch(actions.setTutorial(stage));
@@ -204,7 +204,7 @@ function tutorialStage(tutorial, clearTutorial, instance) {
<p>Press <b>READY</b> to progress to the <b>GAME PHASE</b> <br />
or continue creating new items to strengthen your constructs further</p>
<p>You can unequip skills and specs back into the inventory by double clicking. <br />
Reclaim can be used to refund the cost of items in your inventory. </p>
Refund can be used to refund the cost of items in your inventory. </p>
</div>
);
}
+1 -1
View File
@@ -197,7 +197,7 @@ function postData(url = '/', data = {}) {
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
credentials: 'include', // include, same-origin, *omit
headers: {
Accept: 'application/json',
Buy: 'application/json',
'content-type': 'application/json',
},
redirect: 'error', // manual, *follow, error