This commit is contained in:
ntr 2019-05-08 18:54:50 +10:00
parent 9abbc26308
commit 70f3796d14
4 changed files with 31 additions and 27 deletions

View File

@ -10,14 +10,12 @@ const InfoCryp = require('./info.cryp');
function Info(args) { function Info(args) {
const { const {
activeCryp, activeCryp,
setActiveCryp,
info, info,
combiner,
sendUnequip, sendUnequip,
instance, instance,
player, player,
setInfo,
vboxInfo, vboxInfo,
setVboxHidden,
vboxHidden, vboxHidden,
} = args; } = args;
@ -160,6 +158,27 @@ function Info(args) {
function Combos() { function Combos() {
if (!info[0]) return false; if (!info[0]) return false;
if (activeCryp) return false; if (activeCryp) return false;
if (!player) return false;
if (combiner[0] !== null) {
const filteredCombos = vboxInfo.combos
.filter(combo => combiner.every(u => u === null || combo.units.includes(player.vbox.bound[u])));
return (
<table>
<tbody>
{filteredCombos.map((c, i) =>
<tr key={i} >
<td className="highlight" >{convertVar(c.var)}</td>
{c.units.map(u => <td>{convertVar(u)}</td>)}
</tr>
)}
</tbody>
</table>
);
}
return ( return (
<table> <table>
<tbody> <tbody>
@ -183,8 +202,8 @@ function Info(args) {
return ( return (
<div className={classes} > <div className={classes} >
<InfoCryp /> <InfoCryp />
<Combos />
<CrypVar /> <CrypVar />
<Combos />
<ScoreBoard /> <ScoreBoard />
</div> </div>
); );

View File

@ -7,6 +7,7 @@ const addState = connect(
function receiveState(state) { function receiveState(state) {
const { const {
activeCryp, activeCryp,
combiner,
info, info,
ws, ws,
instance, instance,
@ -22,6 +23,7 @@ const addState = connect(
return { return {
activeCryp, activeCryp,
info, info,
combiner,
sendUnequip, sendUnequip,
instance, instance,
player, player,
@ -29,27 +31,6 @@ const addState = connect(
vboxHidden, vboxHidden,
}; };
}, },
function receiveDispatch(dispatch) {
function setInfo(item, value) {
dispatch(actions.setInfo([item, value]));
}
function setActiveCryp(value) {
dispatch(actions.setActiveCryp(value));
}
function setVboxHidden(value) {
dispatch(actions.setVboxHidden(value));
}
return {
setInfo,
setVboxHidden,
setActiveCryp,
};
}
); );
module.exports = addState(Info); module.exports = addState(Info);

View File

@ -106,14 +106,17 @@ function Vbox(args) {
// INVENTORY // INVENTORY
// //
function boundClick(e, i, highlight) { function boundClick(e, i, highlight) {
if (reclaiming && vbox.bound[i]) sendVboxReclaim(i); const value = vbox.bound[i];
if (reclaiming && value) sendVboxReclaim(i);
else if (highlight && activeCryp) { else if (highlight && activeCryp) {
sendVboxApply(i); sendVboxApply(i);
showTeam(); showTeam();
} else if (vbox.bound[i]) { } else if (value) {
const insert = combiner.findIndex(j => j === null); const insert = combiner.findIndex(j => j === null);
if (insert === -1) return setCombiner([i, null, null]); if (insert === -1) return setCombiner([i, null, null]);
combiner[insert] = i; combiner[insert] = i;
setInfo('item', value);
setActiveCryp(null);
return setCombiner(combiner); return setCombiner(combiner);
} }
return false; return false;

View File

@ -96,6 +96,7 @@ function registerEvents(store) {
} }
function clearCombiner() { function clearCombiner() {
store.dispatch(actions.setInfo(null));
store.dispatch(actions.setCombiner([null, null, null])); store.dispatch(actions.setCombiner([null, null, null]));
} }