diff --git a/client/src/actions.jsx b/client/src/actions.jsx index ebec075d..8de43e4f 100644 --- a/client/src/actions.jsx +++ b/client/src/actions.jsx @@ -30,7 +30,6 @@ export const setEmail = value => ({ type: 'SET_EMAIL', value }); export const setInvite = value => ({ type: 'SET_INVITE', value }); export const setInstance = value => ({ type: 'SET_INSTANCE', value }); export const setInstances = value => ({ type: 'SET_INSTANCES', value }); -export const setItemEquip = value => ({ type: 'SET_ITEM_EQUIP', value }); export const setItemInfo = value => ({ type: 'SET_ITEM_INFO', value }); export const setItemUnequip = value => ({ type: 'SET_ITEM_UNEQUIP', value }); export const setMtxActive = value => ({ type: 'SET_MTX_ACTIVE', value }); diff --git a/client/src/components/account.status.jsx b/client/src/components/account.status.jsx index c25b0855..47c3c9e3 100644 --- a/client/src/components/account.status.jsx +++ b/client/src/components/account.status.jsx @@ -37,7 +37,6 @@ const addState = connect( dispatch(actions.setReclaiming(false)); dispatch(actions.setActiveSkill(null)); dispatch(actions.setInfo(null)); - dispatch(actions.setItemEquip(null)); dispatch(actions.setItemUnequip([])); dispatch(actions.setVboxHighlight([])); return dispatch(actions.setNav('account')); diff --git a/client/src/components/header.jsx b/client/src/components/header.jsx index 76e96fe7..6e85ffa1 100644 --- a/client/src/components/header.jsx +++ b/client/src/components/header.jsx @@ -36,7 +36,6 @@ const addState = connect( dispatch(actions.setReclaiming(false)); dispatch(actions.setActiveSkill(null)); dispatch(actions.setInfo(null)); - dispatch(actions.setItemEquip(null)); dispatch(actions.setItemUnequip([])); dispatch(actions.setVboxHighlight([])); dispatch(actions.setMtxActive(null)); diff --git a/client/src/components/instance.component.jsx b/client/src/components/instance.component.jsx index 23b0148a..da4fb8c3 100644 --- a/client/src/components/instance.component.jsx +++ b/client/src/components/instance.component.jsx @@ -29,10 +29,9 @@ const addState = connect( function clearItems() { dispatch(actions.setCombiner([])); dispatch(actions.setReclaiming(false)); - dispatch(actions.setItemEquip(null)); dispatch(actions.setItemUnequip([])); dispatch(actions.setVboxHighlight([])); - dispatch(actions.setVboxSelected([])); + dispatch(actions.setVboxSelected({ vbox: [], combiner: [] })); return true; } diff --git a/client/src/components/instance.constructs.jsx b/client/src/components/instance.constructs.jsx index 42d95444..61636f03 100644 --- a/client/src/components/instance.constructs.jsx +++ b/client/src/components/instance.constructs.jsx @@ -19,24 +19,19 @@ const addState = connect( player, account, itemInfo, - itemEquip, itemUnequip, vboxSelected, tutorial, } = state; function sendVboxAcceptEquip(constructId) { - return ws.sendVboxAcceptEquip(instance.id, vboxSelected[0][0], vboxSelected[0][1], constructId); + return ws.sendVboxAcceptEquip(instance.id, vboxSelected.vbox[0][0], vboxSelected.vbox[0][1], constructId); } function sendVboxApply(constructId, i) { return ws.sendVboxApply(instance.id, constructId, i); } - function sendUnequip(constructId, item) { - return ws.sendVboxUnequip(instance.id, constructId, item); - } - function sendVboxUnequipApply(targetConstructId) { return ws.sendVboxUnequipApply(instance.id, itemUnequip[0], itemUnequip[1], targetConstructId); } @@ -49,9 +44,7 @@ const addState = connect( sendVboxUnequipApply, sendVboxApply, itemInfo, - itemEquip, itemUnequip, - sendUnequip, vboxSelected, tutorial, }; @@ -66,17 +59,13 @@ const addState = connect( dispatch(actions.setInfo(item)); } - function setItemEquip(v) { - return dispatch(actions.setItemEquip(v)); - } - function setItemUnequip(v) { - dispatch(actions.setVboxSelected([])); + dispatch(actions.setVboxSelected({ vbox: [], combiner: [] })); dispatch(actions.setCombiner([])); return dispatch(actions.setItemUnequip(v)); } - return { quit, setInfo, setItemUnequip, setItemEquip }; + return { quit, setInfo, setItemUnequip }; } ); @@ -86,7 +75,6 @@ function Construct(props) { // Changing state variables construct, iter, - itemEquip, itemUnequip, instance, player, @@ -98,13 +86,16 @@ function Construct(props) { sendVboxApply, sendVboxAcceptEquip, sendVboxUnequipApply, - sendUnequip, setItemUnequip, - setItemEquip, setInfo, } = props; + const { vbox } = player; + const itemEquip = vboxSelected.vbox.length === 0 && vboxSelected.combiner.length === 1 + ? vboxSelected.combiner[0] + : -1; + const duplicateSkill = construct.skills.length !== 0 && construct.skills.every(sk => { if (!itemEquip && itemEquip !== 0) return false; if (!sk) return false; @@ -115,17 +106,16 @@ function Construct(props) { e.stopPropagation(); e.preventDefault(); if (duplicateSkill || tutorialDisableEquip) return true; - if (itemEquip !== null) return sendVboxApply(construct.id, itemEquip); - if (vboxSelected.length === 1) return sendVboxAcceptEquip(construct.id); + if (itemEquip !== -1) return sendVboxApply(construct.id, itemEquip); + if (vboxSelected.vbox.length === 1) return sendVboxAcceptEquip(construct.id); if (itemUnequip.length && itemUnequip[0] !== construct.id) return sendVboxUnequipApply(construct.id); - setItemEquip(null); setItemUnequip([]); return true; } function hoverInfo(e, info) { e.stopPropagation(); if (!info) return false; - if (vboxSelected.length || itemEquip > -1) return false; + if (vboxSelected.vbox.length || itemEquip > -1) return false; return setInfo(info); } @@ -145,15 +135,6 @@ function Construct(props) { return true; } - function skillDblClick(e) { - if (!skill) return false; - sendUnequip(construct.id, skill.skill); - setItemUnequip([]); - e.stopPropagation(); - e.preventDefault(); - return true; - } - const equipping = skillList.includes(vbox.bound[itemEquip]) && !skill && !tutorialDisableEquip && !duplicateSkill && i === construct.skills.length; const border = () => { @@ -176,7 +157,6 @@ function Construct(props) { disabled={!skill && !equipping} class={classes} onClick={skillClick} - onDblClick={skillDblClick} onMouseOver={e => hoverInfo(e, skill && skill.skill)} > {s} @@ -202,13 +182,6 @@ function Construct(props) { setItemUnequip([construct.id, s, i]); } - function specDblClick(e) { - sendUnequip(construct.id, s); - setItemUnequip([]); - e.stopPropagation(); - e.preventDefault(); - return true; - } const highlight = itemUnequip[0] === construct.id && itemUnequip[1] === s && i === itemUnequip[2]; return ( @@ -439,7 +429,7 @@ class Vbox extends preact.Component { function hoverInfo(e, newInfo) { e.stopPropagation(); - if (vboxSelected[0]) return true; + if (vboxSelected.vbox[0]) return true; if (combiner.length !== 0) { const base = combiner.find(c => !['Red', 'Blue', 'Green'].includes(vbox.bound[c])); if (base || base === 0) return true; diff --git a/client/src/events.jsx b/client/src/events.jsx index ab634d98..db002dba 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -188,10 +188,9 @@ function registerEvents(store) { store.dispatch(actions.setReclaiming(false)); store.dispatch(actions.setActiveSkill(null)); store.dispatch(actions.setInfo(null)); - store.dispatch(actions.setItemEquip(null)); store.dispatch(actions.setItemUnequip([])); store.dispatch(actions.setVboxHighlight([])); - store.dispatch(actions.setVboxSelected([])); + store.dispatch(actions.setVboxSelected({ vbox: [], combiner: [] })); } function setAccountInstances(v) { diff --git a/client/src/keyboard.jsx b/client/src/keyboard.jsx index e037be18..3ce1184d 100644 --- a/client/src/keyboard.jsx +++ b/client/src/keyboard.jsx @@ -10,10 +10,9 @@ function setupKeys(store) { key('esc', () => store.dispatch(actions.setReclaiming(false))); key('esc', () => store.dispatch(actions.setActiveSkill(null))); key('esc', () => store.dispatch(actions.setInfo(null))); - key('esc', () => store.dispatch(actions.setItemEquip(null))); key('esc', () => store.dispatch(actions.setItemUnequip([]))); key('esc', () => store.dispatch(actions.setVboxHighlight([]))); - key('esc', () => store.dispatch(actions.setVboxSelected([]))); + key('esc', () => store.dispatch(actions.setVboxSelected({ vbox: [], combiner: [] }))); key('esc', () => store.dispatch(actions.setMtxActive(null))); } diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index c9479f56..3a593124 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -39,7 +39,6 @@ module.exports = { instance: createReducer(null, 'SET_INSTANCE'), instanceChat: createReducer(null, 'SET_INSTANCE_CHAT'), instances: createReducer([], 'SET_INSTANCES'), - itemEquip: createReducer(null, 'SET_ITEM_EQUIP'), itemInfo: createReducer({ combos: [], items: [] }, 'SET_ITEM_INFO'), itemUnequip: createReducer([], 'SET_ITEM_UNEQUIP'), mtxActive: createReducer(null, 'SET_MTX_ACTIVE'), @@ -59,7 +58,7 @@ module.exports = { tutorial: createReducer(1, 'SET_TUTORIAL'), tutorialGame: createReducer(1, 'SET_TUTORIAL_GAME'), - vboxSelected: createReducer([], 'SET_VBOX_SELECTED'), + vboxSelected: createReducer({ vbox: [], combiner: [] }, 'SET_VBOX_SELECTED'), ws: createReducer(null, 'SET_WS'), };