preview combiner

This commit is contained in:
Mashy 2019-10-18 09:30:01 +10:00
parent b71cc8fc0f
commit 85497bfbf2

View File

@ -20,6 +20,7 @@ const addState = connect(
itemInfo, itemInfo,
itemUnequip, itemUnequip,
navInstance, navInstance,
info,
} = state; } = state;
function sendVboxDiscard() { function sendVboxDiscard() {
@ -56,6 +57,7 @@ const addState = connect(
itemUnequip, itemUnequip,
sendItemUnequip, sendItemUnequip,
navInstance, navInstance,
info,
}; };
}, },
@ -115,6 +117,7 @@ function Vbox(args) {
sendItemUnequip, sendItemUnequip,
setReclaiming, setReclaiming,
info,
} = args; } = args;
if (!player) return false; if (!player) return false;
@ -138,7 +141,7 @@ function Vbox(args) {
// //
function vboxHover(e, v) { function vboxHover(e, v) {
if (v) { if (v) {
setInfo(v); if (info !== v) setInfo(v);
e.stopPropagation(); e.stopPropagation();
} }
return true; return true;
@ -329,7 +332,7 @@ function Vbox(args) {
function combinerBtn() { function combinerBtn() {
let text = ''; let text = '';
let comboItem = 'refine';
if (combiner.length < 3) { if (combiner.length < 3) {
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
if (combiner.length > i) { if (combiner.length > i) {
@ -339,14 +342,17 @@ function Vbox(args) {
} }
} }
} else { } else {
text = 'combine'; // Since theres 3 items in combiner and you can't have valid combos we can preview it
const combinerItems = combiner.map(j => vbox.bound[j]);
comboItem = itemInfo.combos.find(combo => combinerItems.every(c => combo.components.includes(c))).item;
text = `Combine - ${comboItem}`;
} }
return ( return (
<button <button
class='vbox-btn' class='vbox-btn'
disabled={combiner.length !== 3} disabled={combiner.length !== 3}
onMouseOver={e => hoverInfo(e, 'refine')} onMouseOver={e => hoverInfo(e, comboItem)}
onClick={e => e.stopPropagation()} onClick={e => e.stopPropagation()}
onMouseDown={() => sendVboxCombine()}> onMouseDown={() => sendVboxCombine()}>
{text} {text}
@ -390,9 +396,10 @@ function Vbox(args) {
// //
// EVERYTHING // EVERYTHING
// //
function hoverInfo(e, info) { function hoverInfo(e, newInfo) {
e.stopPropagation(); e.stopPropagation();
return setInfo(info); if (info === newInfo) return true;
return setInfo(newInfo);
} }
const classes = `vbox ${navInstance === 0 ? 'visible' : ''}`; const classes = `vbox ${navInstance === 0 ? 'visible' : ''}`;