remove combiner, vboxSelected fields "shopSelect & stashSelect"
This commit is contained in:
parent
e35c688cff
commit
af99883ced
@ -16,7 +16,6 @@ export const setInstanceChat = value => ({ type: 'SET_INSTANCE_CHAT', value });
|
||||
|
||||
export const setActiveItem = value => ({ type: 'SET_ACTIVE_VAR', value });
|
||||
export const setActiveSkill = (constructId, skill) => ({ type: 'SET_ACTIVE_SKILL', value: constructId ? { constructId, skill } : null });
|
||||
export const setCombiner = value => ({ type: 'SET_COMBINER', value: Array.from(value) });
|
||||
export const setConstructEditId = value => ({ type: 'SET_CONSTRUCT_EDIT_ID', value });
|
||||
export const setConstructs = value => ({ type: 'SET_CONSTRUCTS', value });
|
||||
export const setConstructRename = value => ({ type: 'SET_CONSTRUCT_RENAME', value });
|
||||
|
||||
@ -33,7 +33,6 @@ const addState = connect(
|
||||
function accountPage() {
|
||||
dispatch(actions.setGame(null));
|
||||
dispatch(actions.setInstance(null));
|
||||
dispatch(actions.setCombiner([]));
|
||||
dispatch(actions.setReclaiming(false));
|
||||
dispatch(actions.setActiveSkill(null));
|
||||
dispatch(actions.setInfo(null));
|
||||
|
||||
@ -32,7 +32,6 @@ const addState = connect(
|
||||
function setNav(place) {
|
||||
dispatch(actions.setGame(null));
|
||||
dispatch(actions.setInstance(null));
|
||||
dispatch(actions.setCombiner([]));
|
||||
dispatch(actions.setReclaiming(false));
|
||||
dispatch(actions.setActiveSkill(null));
|
||||
dispatch(actions.setInfo(null));
|
||||
|
||||
@ -7,7 +7,6 @@ const addState = connect(
|
||||
function receiveState(state) {
|
||||
const {
|
||||
ws,
|
||||
combiner,
|
||||
info,
|
||||
itemInfo,
|
||||
instance,
|
||||
@ -18,7 +17,6 @@ const addState = connect(
|
||||
|
||||
return {
|
||||
ws,
|
||||
combiner,
|
||||
info,
|
||||
itemInfo,
|
||||
instance,
|
||||
|
||||
@ -27,11 +27,10 @@ const addState = connect(
|
||||
|
||||
|
||||
function clearItems() {
|
||||
dispatch(actions.setCombiner([]));
|
||||
dispatch(actions.setReclaiming(false));
|
||||
dispatch(actions.setItemUnequip([]));
|
||||
dispatch(actions.setVboxHighlight([]));
|
||||
dispatch(actions.setVboxSelected({ vbox: [], combiner: [] }));
|
||||
dispatch(actions.setVboxSelected({ shopSelect: [], stashSelect: [] }));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ const addState = connect(
|
||||
} = state;
|
||||
|
||||
function sendVboxAcceptEquip(constructId) {
|
||||
return ws.sendVboxAcceptEquip(instance.id, vboxSelected.vbox[0][0], vboxSelected.vbox[0][1], constructId);
|
||||
return ws.sendVboxAcceptEquip(instance.id, vboxSelected.shopSelect[0][0], vboxSelected.shopSelect[0][1], constructId);
|
||||
}
|
||||
|
||||
function sendVboxApply(constructId, i) {
|
||||
@ -60,8 +60,7 @@ const addState = connect(
|
||||
}
|
||||
|
||||
function setItemUnequip(v) {
|
||||
dispatch(actions.setVboxSelected({ vbox: [], combiner: [] }));
|
||||
dispatch(actions.setCombiner([]));
|
||||
dispatch(actions.setVboxSelected({ shopSelect: [], stashSelect: [] }));
|
||||
return dispatch(actions.setItemUnequip(v));
|
||||
}
|
||||
|
||||
@ -92,8 +91,8 @@ function Construct(props) {
|
||||
|
||||
const { vbox } = player;
|
||||
|
||||
const itemEquip = vboxSelected.vbox.length === 0 && vboxSelected.combiner.length === 1
|
||||
? vboxSelected.combiner[0]
|
||||
const itemEquip = vboxSelected.shopSelect.length === 0 && vboxSelected.stashSelect.length === 1
|
||||
? vboxSelected.stashSelect[0]
|
||||
: -1;
|
||||
|
||||
const duplicateSkill = construct.skills.length !== 0 && construct.skills.every(sk => {
|
||||
@ -107,7 +106,7 @@ function Construct(props) {
|
||||
e.preventDefault();
|
||||
if (duplicateSkill || tutorialDisableEquip) return true;
|
||||
if (itemEquip !== -1) return sendVboxApply(construct.id, itemEquip);
|
||||
if (vboxSelected.vbox.length === 1) return sendVboxAcceptEquip(construct.id);
|
||||
if (vboxSelected.shopSelect.length === 1) return sendVboxAcceptEquip(construct.id);
|
||||
if (itemUnequip.length && itemUnequip[0] !== construct.id) return sendVboxUnequipApply(construct.id);
|
||||
setItemUnequip([]);
|
||||
return true;
|
||||
@ -115,7 +114,7 @@ function Construct(props) {
|
||||
function hoverInfo(e, info) {
|
||||
e.stopPropagation();
|
||||
if (!info) return false;
|
||||
if (vboxSelected.vbox.length || itemEquip > -1) return false;
|
||||
if (vboxSelected.shopSelect.length || vboxSelected.stashSelect.length) return false;
|
||||
return setInfo(info);
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@ const addState = connect(
|
||||
function setNav(place) {
|
||||
dispatch(actions.setGame(null));
|
||||
dispatch(actions.setInstance(null));
|
||||
dispatch(actions.setCombiner([]));
|
||||
dispatch(actions.setReclaiming(false));
|
||||
dispatch(actions.setActiveSkill(null));
|
||||
dispatch(actions.setInfo(null));
|
||||
|
||||
@ -15,7 +15,6 @@ const addState = connect(
|
||||
ws,
|
||||
instance,
|
||||
player,
|
||||
combiner,
|
||||
reclaiming,
|
||||
vboxSelected,
|
||||
itemInfo,
|
||||
@ -33,7 +32,7 @@ const addState = connect(
|
||||
}
|
||||
|
||||
function sendVboxCombine() {
|
||||
return ws.sendVboxCombine(instance.id, vboxSelected.combiner, vboxSelected.vbox);
|
||||
return ws.sendVboxCombine(instance.id, vboxSelected.stashSelect, vboxSelected.shopSelect);
|
||||
}
|
||||
|
||||
function sendVboxReclaim(i) {
|
||||
@ -45,7 +44,6 @@ const addState = connect(
|
||||
}
|
||||
|
||||
return {
|
||||
combiner,
|
||||
instance,
|
||||
player,
|
||||
reclaiming,
|
||||
@ -62,15 +60,9 @@ const addState = connect(
|
||||
},
|
||||
|
||||
function receiveDispatch(dispatch) {
|
||||
function setCombiner(c) {
|
||||
dispatch(actions.setItemUnequip([]));
|
||||
return dispatch(actions.setCombiner(c));
|
||||
}
|
||||
|
||||
function setReclaiming(v) {
|
||||
dispatch(actions.setItemUnequip([]));
|
||||
dispatch(actions.setCombiner([]));
|
||||
dispatch(actions.setVboxSelected({ vbox: [], combiner: [] }));
|
||||
dispatch(actions.setVboxSelected({ shopSelect: [], stashSelect: [] }));
|
||||
return dispatch(actions.setReclaiming(v));
|
||||
}
|
||||
|
||||
@ -85,7 +77,6 @@ const addState = connect(
|
||||
}
|
||||
|
||||
return {
|
||||
setCombiner,
|
||||
setReclaiming,
|
||||
setInfo,
|
||||
setVboxSelected,
|
||||
@ -97,7 +88,6 @@ const addState = connect(
|
||||
class Vbox extends preact.Component {
|
||||
shouldComponentUpdate(newProps) {
|
||||
// Single variable props
|
||||
if (newProps.combiner !== this.props.combiner) return true;
|
||||
if (newProps.itemUnequip !== this.props.itemUnequip) return true;
|
||||
if (newProps.reclaiming !== this.props.reclaiming) return true;
|
||||
if (newProps.tutorial !== this.props.tutorial) return true;
|
||||
@ -132,11 +122,12 @@ class Vbox extends preact.Component {
|
||||
|
||||
if (!player) return false;
|
||||
const { vbox } = player;
|
||||
const { combiner } = vboxSelected;
|
||||
const vboxSelecting = vboxSelected.vbox.length;
|
||||
const { shopSelect, stashSelect } = vboxSelected;
|
||||
console.log(vboxSelected);
|
||||
const vboxSelecting = shopSelect.length;
|
||||
|
||||
function combinerChange(newCombiner) {
|
||||
return setVboxSelected({ vbox: vboxSelected.vbox, combiner: newCombiner });
|
||||
function combinerChange(newStashSelect) {
|
||||
return setVboxSelected({ shopSelect, stashSelect: newStashSelect });
|
||||
}
|
||||
|
||||
//
|
||||
@ -145,9 +136,9 @@ class Vbox extends preact.Component {
|
||||
function vboxHover(e, v) {
|
||||
if (v) {
|
||||
e.stopPropagation();
|
||||
if (vboxSelected.vbox[0]) return true; // There is a base skill or spec selected in the vbox
|
||||
if (combiner.length !== 0) {
|
||||
const base = combiner.find(c => !['Red', 'Blue', 'Green'].includes(vbox.bound[c]));
|
||||
if (shopSelect[0]) return true; // There is a base skill or spec selected in the vbox
|
||||
if (stashSelect.length !== 0) {
|
||||
const base = stashSelect.find(c => !['Red', 'Blue', 'Green'].includes(vbox.bound[c]));
|
||||
if (base || base === 0) return true;
|
||||
}
|
||||
setInfo(v);
|
||||
@ -156,28 +147,28 @@ class Vbox extends preact.Component {
|
||||
}
|
||||
|
||||
function clearVboxSelected() {
|
||||
setVboxSelected({ vbox: [], combiner });
|
||||
setVboxSelected({ shopSelect: [], stashSelect: [] });
|
||||
}
|
||||
|
||||
function vboxBuySelected() {
|
||||
if (!vboxSelecting) return false;
|
||||
document.activeElement.blur();
|
||||
clearVboxSelected();
|
||||
sendVboxAccept(vboxSelected.vbox[0][0], vboxSelected.vbox[0][1]);
|
||||
sendVboxAccept(shopSelect[0][0], shopSelect[0][1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
function availableBtn(v, group, index) {
|
||||
if (!v) return <button disabled class='empty' key={(group * 10) + index} > </button>;
|
||||
const selected = vboxSelected.vbox.length && vboxSelected.vbox.some(vs => vs[0] === group && vs[1] === index);
|
||||
const selected = shopSelect.length && shopSelect.some(vs => vs[0] === group && vs[1] === index);
|
||||
// state not yet set in double click handler
|
||||
/*function onDblClick(e) {
|
||||
clearVboxSelected();
|
||||
sendVboxAccept(group, index);
|
||||
e.stopPropagation();
|
||||
}*/
|
||||
|
||||
const combinerItems = combiner.map(j => vbox.bound[j]);
|
||||
console.log(stashSelect);
|
||||
console.log(vboxSelected);
|
||||
const combinerItems = stashSelect.map(j => vbox.bound[j]);
|
||||
const combinerCount = countBy(combinerItems, co => co);
|
||||
|
||||
const comboHighlight = combinerItems.length > 0 && itemInfo.combos.some(combo => {
|
||||
@ -195,15 +186,15 @@ class Vbox extends preact.Component {
|
||||
function onClick(e) {
|
||||
e.stopPropagation();
|
||||
setInfo(vbox.free[group][index]);
|
||||
if (vboxSelected.vbox.length && vboxSelected.vbox.some(vs => vs[0] === group && vs[1] === index)) {
|
||||
return setVboxSelected({ vbox: vboxSelected.vbox.filter(vs => !(vs[0] === group && vs[1] === index)), combiner });
|
||||
if (shopSelect.length && shopSelect.some(vs => vs[0] === group && vs[1] === index)) {
|
||||
return setVboxSelected({ shopSelect: shopSelect.filter(vs => !(vs[0] === group && vs[1] === index)), stashSelect });
|
||||
}
|
||||
|
||||
if (!vboxSelected.vbox.length && !combiner.length) return setVboxSelected({ vbox: [[group, index]], combiner });
|
||||
if (!shopSelect.length && !stashSelect.length) return setVboxSelected({ shopSelect: [[group, index]], stashSelect });
|
||||
if (comboHighlight !== 'combo-border') {
|
||||
return setVboxSelected({ vbox: [[group, index]], combiner: [] });
|
||||
return setVboxSelected({ shopSelect: [[group, index]], stashSelect: [] });
|
||||
}
|
||||
return setVboxSelected({ vbox: [...vboxSelected.vbox, [group, index]], combiner });
|
||||
return setVboxSelected({ shopSelect: [...shopSelect, [group, index]], stashSelect });
|
||||
}
|
||||
|
||||
|
||||
@ -280,7 +271,7 @@ class Vbox extends preact.Component {
|
||||
return <button key={i} onClick={emptyInvClick} disabled={!inventoryHighlight} class={inventoryHighlight ? 'receiving' : 'empty'} > </button>;
|
||||
}
|
||||
|
||||
const combinerItems = combiner.map(j => vbox.bound[j]);
|
||||
const combinerItems = stashSelect.map(j => vbox.bound[j]);
|
||||
const combinerCount = countBy(combinerItems, co => co);
|
||||
|
||||
const comboItem = itemInfo.combos.find(combo => {
|
||||
@ -299,16 +290,16 @@ class Vbox extends preact.Component {
|
||||
function onClick(type) {
|
||||
if (reclaiming) return sendVboxReclaim(i);
|
||||
|
||||
const combinerContainsIndex = combiner.indexOf(i) > -1;
|
||||
const combinerContainsIndex = stashSelect.indexOf(i) > -1;
|
||||
// 4 things selected
|
||||
if (combiner.length > 2 && !combinerContainsIndex) {
|
||||
if (stashSelect.length > 2 && !combinerContainsIndex) {
|
||||
setInfo(vbox.bound[i]);
|
||||
return combinerChange([i]);
|
||||
}
|
||||
// removing
|
||||
if (combinerContainsIndex) {
|
||||
if (type === 'click') {
|
||||
return combinerChange(without(combiner, i));
|
||||
return combinerChange(without(stashSelect, i));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -318,12 +309,12 @@ class Vbox extends preact.Component {
|
||||
return combinerChange([i]);
|
||||
}
|
||||
|
||||
combiner.push(i);
|
||||
if (combiner.length === 3) setInfo(comboItem.item);
|
||||
return combinerChange(combiner);
|
||||
stashSelect.push(i);
|
||||
if (stashSelect.length === 3) setInfo(comboItem.item);
|
||||
return combinerChange(stashSelect);
|
||||
}
|
||||
|
||||
const highlighted = combiner.indexOf(i) > -1;
|
||||
const highlighted = stashSelect.indexOf(i) > -1;
|
||||
const border = buttons[removeTier(v)] ? buttons[removeTier(v)]() : '';
|
||||
const classes = `${highlighted ? 'highlight' : border} ${comboHighlight}`;
|
||||
|
||||
@ -351,9 +342,9 @@ class Vbox extends preact.Component {
|
||||
function combinerBtn() {
|
||||
let text = '';
|
||||
let comboItem = '';
|
||||
if (combiner.length < 3) {
|
||||
if (stashSelect.length < 3) {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (combiner.length > i) {
|
||||
if (stashSelect.length > i) {
|
||||
text += '■ ';
|
||||
} else {
|
||||
text += '▫ ';
|
||||
@ -361,7 +352,7 @@ class Vbox extends preact.Component {
|
||||
}
|
||||
} else {
|
||||
// Since theres 3 items in combiner and you can't have invalid combos we can preview it
|
||||
const combinerItems = combiner.map(j => vbox.bound[j]);
|
||||
const combinerItems = stashSelect.map(j => vbox.bound[j]);
|
||||
const combinerCount = countBy(combinerItems, co => co);
|
||||
const comboItemObj = itemInfo.combos.find(combo => combinerItems.every(c => {
|
||||
if (!combo.components.includes(c)) return false;
|
||||
@ -429,9 +420,9 @@ class Vbox extends preact.Component {
|
||||
function hoverInfo(e, newInfo) {
|
||||
e.stopPropagation();
|
||||
|
||||
if (vboxSelected.vbox[0]) return true;
|
||||
if (combiner.length !== 0) {
|
||||
const base = combiner.find(c => !['Red', 'Blue', 'Green'].includes(vbox.bound[c]));
|
||||
if (shopSelect[0]) return true;
|
||||
if (stashSelect.length !== 0) {
|
||||
const base = stashSelect.find(c => !['Red', 'Blue', 'Green'].includes(vbox.bound[c]));
|
||||
if (base || base === 0) return true;
|
||||
}
|
||||
return setInfo(newInfo);
|
||||
|
||||
@ -157,11 +157,6 @@ function registerEvents(store) {
|
||||
store.dispatch(actions.setShop(v));
|
||||
}
|
||||
|
||||
function clearCombiner() {
|
||||
store.dispatch(actions.setInfo([]));
|
||||
store.dispatch(actions.setCombiner([]));
|
||||
}
|
||||
|
||||
function clearConstructRename() {
|
||||
store.dispatch(actions.setConstructRename(null));
|
||||
}
|
||||
@ -184,13 +179,12 @@ function registerEvents(store) {
|
||||
}
|
||||
|
||||
function clearInstance() {
|
||||
store.dispatch(actions.setCombiner([]));
|
||||
store.dispatch(actions.setReclaiming(false));
|
||||
store.dispatch(actions.setActiveSkill(null));
|
||||
store.dispatch(actions.setInfo(null));
|
||||
store.dispatch(actions.setItemUnequip([]));
|
||||
store.dispatch(actions.setVboxHighlight([]));
|
||||
store.dispatch(actions.setVboxSelected({ vbox: [], combiner: [] }));
|
||||
store.dispatch(actions.setVboxSelected({ shopSelect: [], stashSelect: [] }));
|
||||
}
|
||||
|
||||
function setAccountInstances(v) {
|
||||
@ -344,7 +338,6 @@ function registerEvents(store) {
|
||||
window.addEventListener('hashchange', urlHashChange, false);
|
||||
|
||||
return {
|
||||
clearCombiner,
|
||||
clearConstructRename,
|
||||
clearInfo,
|
||||
clearInstance,
|
||||
|
||||
@ -6,13 +6,12 @@ function setupKeys(store) {
|
||||
key.unbind('esc');
|
||||
|
||||
key('esc', () => document.activeElement.blur());
|
||||
key('esc', () => store.dispatch(actions.setCombiner([])));
|
||||
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.setItemUnequip([])));
|
||||
key('esc', () => store.dispatch(actions.setVboxHighlight([])));
|
||||
key('esc', () => store.dispatch(actions.setVboxSelected({ vbox: [], combiner: [] })));
|
||||
key('esc', () => store.dispatch(actions.setVboxSelected({ shopSelect: [], stashSelect: [] })));
|
||||
key('esc', () => store.dispatch(actions.setMtxActive(null)));
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,6 @@ module.exports = {
|
||||
chatShow: createReducer(null, 'SET_CHAT_SHOW'),
|
||||
chatWheel: createReducer([], 'SET_CHAT_WHEEL'),
|
||||
|
||||
combiner: createReducer([], 'SET_COMBINER'),
|
||||
constructs: createReducer([], 'SET_CONSTRUCTS'),
|
||||
constructEditId: createReducer(null, 'SET_CONSTRUCT_EDIT_ID'),
|
||||
constructRename: createReducer(null, 'SET_CONSTRUCT_RENAME'),
|
||||
@ -58,7 +57,7 @@ module.exports = {
|
||||
tutorial: createReducer(1, 'SET_TUTORIAL'),
|
||||
tutorialGame: createReducer(1, 'SET_TUTORIAL_GAME'),
|
||||
|
||||
vboxSelected: createReducer({ vbox: [], combiner: [] }, 'SET_VBOX_SELECTED'),
|
||||
vboxSelected: createReducer({ shopSelect: [], stashSelect: [] }, 'SET_VBOX_SELECTED'),
|
||||
|
||||
ws: createReducer(null, 'SET_WS'),
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user