fix auto ready and remove activeConstruct reducer
This commit is contained in:
parent
db8e198817
commit
1b5050a7bf
@ -1,5 +1,4 @@
|
|||||||
export const setAccount = value => ({ type: 'SET_ACCOUNT', value });
|
export const setAccount = value => ({ type: 'SET_ACCOUNT', value });
|
||||||
export const setActiveConstruct = value => ({ type: 'SET_ACTIVE_CONSTRUCT', value });
|
|
||||||
|
|
||||||
export const setAnimating = value => ({ type: 'SET_ANIMATING', value });
|
export const setAnimating = value => ({ type: 'SET_ANIMATING', value });
|
||||||
export const setAnimCb = value => ({ type: 'SET_ANIM_CB', value });
|
export const setAnimCb = value => ({ type: 'SET_ANIM_CB', value });
|
||||||
|
|||||||
@ -36,7 +36,6 @@ const addState = connect(
|
|||||||
dispatch(actions.setCombiner([]));
|
dispatch(actions.setCombiner([]));
|
||||||
dispatch(actions.setReclaiming(false));
|
dispatch(actions.setReclaiming(false));
|
||||||
dispatch(actions.setActiveSkill(null));
|
dispatch(actions.setActiveSkill(null));
|
||||||
dispatch(actions.setActiveConstruct(null));
|
|
||||||
dispatch(actions.setInfo(null));
|
dispatch(actions.setInfo(null));
|
||||||
dispatch(actions.setItemEquip(null));
|
dispatch(actions.setItemEquip(null));
|
||||||
dispatch(actions.setItemUnequip([]));
|
dispatch(actions.setItemUnequip([]));
|
||||||
|
|||||||
@ -14,7 +14,6 @@ const addState = connect(
|
|||||||
account,
|
account,
|
||||||
animating,
|
animating,
|
||||||
activeSkill,
|
activeSkill,
|
||||||
activeConstruct,
|
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
function selectSkillTarget(targetConstructId) {
|
function selectSkillTarget(targetConstructId) {
|
||||||
@ -34,7 +33,6 @@ const addState = connect(
|
|||||||
account,
|
account,
|
||||||
animating,
|
animating,
|
||||||
activeSkill,
|
activeSkill,
|
||||||
activeConstruct,
|
|
||||||
selectSkillTarget,
|
selectSkillTarget,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -44,11 +42,7 @@ const addState = connect(
|
|||||||
dispatch(actions.setActiveSkill(constructId, skill));
|
dispatch(actions.setActiveSkill(constructId, skill));
|
||||||
}
|
}
|
||||||
|
|
||||||
function setActiveConstruct(construct) {
|
return { setActiveSkill };
|
||||||
dispatch(actions.setActiveConstruct(construct));
|
|
||||||
}
|
|
||||||
|
|
||||||
return { setActiveSkill, setActiveConstruct };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
@ -59,7 +53,6 @@ function Game(props) {
|
|||||||
account,
|
account,
|
||||||
animating,
|
animating,
|
||||||
setActiveSkill,
|
setActiveSkill,
|
||||||
setActiveConstruct,
|
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
if (!game) return <div>...</div>;
|
if (!game) return <div>...</div>;
|
||||||
@ -91,7 +84,6 @@ function Game(props) {
|
|||||||
|
|
||||||
function gameClick(e) {
|
function gameClick(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setActiveConstruct(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -35,7 +35,6 @@ const addState = connect(
|
|||||||
dispatch(actions.setCombiner([]));
|
dispatch(actions.setCombiner([]));
|
||||||
dispatch(actions.setReclaiming(false));
|
dispatch(actions.setReclaiming(false));
|
||||||
dispatch(actions.setActiveSkill(null));
|
dispatch(actions.setActiveSkill(null));
|
||||||
dispatch(actions.setActiveConstruct(null));
|
|
||||||
dispatch(actions.setInfo(null));
|
dispatch(actions.setInfo(null));
|
||||||
dispatch(actions.setItemEquip(null));
|
dispatch(actions.setItemEquip(null));
|
||||||
dispatch(actions.setItemUnequip([]));
|
dispatch(actions.setItemUnequip([]));
|
||||||
|
|||||||
@ -66,10 +66,6 @@ const addState = connect(
|
|||||||
dispatch(actions.setInfo(item));
|
dispatch(actions.setInfo(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
function setActiveConstruct(value) {
|
|
||||||
dispatch(actions.setActiveConstruct(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
function setItemEquip(v) {
|
function setItemEquip(v) {
|
||||||
return dispatch(actions.setItemEquip(v));
|
return dispatch(actions.setItemEquip(v));
|
||||||
}
|
}
|
||||||
@ -78,7 +74,7 @@ const addState = connect(
|
|||||||
return dispatch(actions.setItemUnequip(v));
|
return dispatch(actions.setItemUnequip(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
return { quit, setInfo, setActiveConstruct, setItemUnequip, setItemEquip };
|
return { quit, setInfo, setItemUnequip, setItemEquip };
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
@ -101,7 +97,6 @@ function Construct(props) {
|
|||||||
sendVboxAcceptEquip,
|
sendVboxAcceptEquip,
|
||||||
sendVboxUnequipApply,
|
sendVboxUnequipApply,
|
||||||
sendUnequip,
|
sendUnequip,
|
||||||
setActiveConstruct,
|
|
||||||
setItemUnequip,
|
setItemUnequip,
|
||||||
setItemEquip,
|
setItemEquip,
|
||||||
setInfo,
|
setInfo,
|
||||||
@ -144,7 +139,6 @@ function Construct(props) {
|
|||||||
function skillClick(e) {
|
function skillClick(e) {
|
||||||
if (!skill) return false;
|
if (!skill) return false;
|
||||||
setItemUnequip([construct.id, skill.skill]);
|
setItemUnequip([construct.id, skill.skill]);
|
||||||
setActiveConstruct(construct);
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -152,7 +146,6 @@ function Construct(props) {
|
|||||||
function skillDblClick(e) {
|
function skillDblClick(e) {
|
||||||
if (!skill) return false;
|
if (!skill) return false;
|
||||||
sendUnequip(construct.id, skill.skill);
|
sendUnequip(construct.id, skill.skill);
|
||||||
setActiveConstruct(null);
|
|
||||||
setItemUnequip([]);
|
setItemUnequip([]);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -203,12 +196,10 @@ function Construct(props) {
|
|||||||
function specClick(e) {
|
function specClick(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setItemUnequip([construct.id, s]);
|
setItemUnequip([construct.id, s]);
|
||||||
setActiveConstruct(construct);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function specDblClick(e) {
|
function specDblClick(e) {
|
||||||
sendUnequip(construct.id, s);
|
sendUnequip(construct.id, s);
|
||||||
setActiveConstruct(null);
|
|
||||||
setItemUnequip([]);
|
setItemUnequip([]);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -291,7 +282,6 @@ class InstanceConstructs extends preact.Component {
|
|||||||
itemInfo,
|
itemInfo,
|
||||||
// Function calls
|
// Function calls
|
||||||
setInfo,
|
setInfo,
|
||||||
setActiveConstruct,
|
|
||||||
sendVboxApply,
|
sendVboxApply,
|
||||||
sendVboxAcceptEquip,
|
sendVboxAcceptEquip,
|
||||||
sendVboxUnequipApply,
|
sendVboxUnequipApply,
|
||||||
@ -321,7 +311,6 @@ class InstanceConstructs extends preact.Component {
|
|||||||
sendVboxAcceptEquip,
|
sendVboxAcceptEquip,
|
||||||
sendVboxUnequipApply,
|
sendVboxUnequipApply,
|
||||||
setInfo,
|
setInfo,
|
||||||
setActiveConstruct,
|
|
||||||
itemInfo,
|
itemInfo,
|
||||||
setVboxHighlight,
|
setVboxHighlight,
|
||||||
sendUnequip,
|
sendUnequip,
|
||||||
@ -331,7 +320,7 @@ class InstanceConstructs extends preact.Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class='construct-list' onClick={() => setActiveConstruct(null)}>
|
<div class='construct-list'>
|
||||||
{constructs}
|
{constructs}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -55,15 +55,6 @@ function InstanceCtrlBtns(args) {
|
|||||||
|
|
||||||
const finished = instance && instance.phase === 'Finished';
|
const finished = instance && instance.phase === 'Finished';
|
||||||
|
|
||||||
// cheeky to make sure nubs don't just abandon their first game
|
|
||||||
const beingNub = instance.phase_end
|
|
||||||
&& instance.phase === 'Lobby'
|
|
||||||
&& Date.parse(instance.phase_end) - Date.now() < 2000;
|
|
||||||
|
|
||||||
if (beingNub) {
|
|
||||||
sendReady();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="instance-ctrl-btns">
|
<div class="instance-ctrl-btns">
|
||||||
<button disabled={!account.subscribed} onClick={() => setChatShow(!chatShow)}>Chat</button>
|
<button disabled={!account.subscribed} onClick={() => setChatShow(!chatShow)}>Chat</button>
|
||||||
|
|||||||
@ -36,7 +36,6 @@ const addState = connect(
|
|||||||
dispatch(actions.setCombiner([]));
|
dispatch(actions.setCombiner([]));
|
||||||
dispatch(actions.setReclaiming(false));
|
dispatch(actions.setReclaiming(false));
|
||||||
dispatch(actions.setActiveSkill(null));
|
dispatch(actions.setActiveSkill(null));
|
||||||
dispatch(actions.setActiveConstruct(null));
|
|
||||||
dispatch(actions.setInfo(null));
|
dispatch(actions.setInfo(null));
|
||||||
dispatch(actions.setItemEquip(null));
|
dispatch(actions.setItemEquip(null));
|
||||||
dispatch(actions.setItemUnequip([]));
|
dispatch(actions.setItemUnequip([]));
|
||||||
|
|||||||
@ -177,7 +177,6 @@ function registerEvents(store) {
|
|||||||
|
|
||||||
function clearInfo() {
|
function clearInfo() {
|
||||||
store.dispatch(actions.setInfo(null));
|
store.dispatch(actions.setInfo(null));
|
||||||
store.dispatch(actions.setActiveConstruct(null));
|
|
||||||
console.log('event clear item');
|
console.log('event clear item');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +184,6 @@ function registerEvents(store) {
|
|||||||
store.dispatch(actions.setCombiner([]));
|
store.dispatch(actions.setCombiner([]));
|
||||||
store.dispatch(actions.setReclaiming(false));
|
store.dispatch(actions.setReclaiming(false));
|
||||||
store.dispatch(actions.setActiveSkill(null));
|
store.dispatch(actions.setActiveSkill(null));
|
||||||
store.dispatch(actions.setActiveConstruct(null));
|
|
||||||
store.dispatch(actions.setInfo(null));
|
store.dispatch(actions.setInfo(null));
|
||||||
store.dispatch(actions.setItemEquip(null));
|
store.dispatch(actions.setItemEquip(null));
|
||||||
store.dispatch(actions.setItemUnequip([]));
|
store.dispatch(actions.setItemUnequip([]));
|
||||||
@ -208,6 +206,7 @@ function registerEvents(store) {
|
|||||||
return store.dispatch(actions.setInvite(code));
|
return store.dispatch(actions.setInvite(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let autoReady = null;
|
||||||
function setInstance(v) {
|
function setInstance(v) {
|
||||||
const { account, instance, ws, tutorial } = store.getState();
|
const { account, instance, ws, tutorial } = store.getState();
|
||||||
if (v) {
|
if (v) {
|
||||||
@ -216,15 +215,23 @@ function registerEvents(store) {
|
|||||||
store.dispatch(actions.setPlayer(player));
|
store.dispatch(actions.setPlayer(player));
|
||||||
|
|
||||||
if (!instance || v.id !== instance.id) {
|
if (!instance || v.id !== instance.id) {
|
||||||
store.dispatch(actions.setNav('vbox'));
|
clearTimeout(autoReady);
|
||||||
const first = player.constructs[0];
|
|
||||||
store.dispatch(actions.setActiveConstruct(first));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v.phase === 'Finished') {
|
if (v.phase === 'Finished') {
|
||||||
ws.sendAccountInstances();
|
ws.sendAccountInstances();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (v.phase_end && v.phase === 'Lobby' && !autoReady) {
|
||||||
|
const autoReadyDelay = Date.parse(v.phase_end) - Date.now() - 1000;
|
||||||
|
autoReady = setTimeout(() => {
|
||||||
|
ws.sendInstanceReady(v.id);
|
||||||
|
autoReady = null;
|
||||||
|
}, autoReadyDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v.phase !== 'Lobby') clearTimeout(autoReady);
|
||||||
|
|
||||||
// instance.mobile.less hides info at @media 1000
|
// instance.mobile.less hides info at @media 1000
|
||||||
if (localStorage.getItem('tutorial-complete') || window.innerWidth <= 1100) {
|
if (localStorage.getItem('tutorial-complete') || window.innerWidth <= 1100) {
|
||||||
store.dispatch(actions.setTutorial(null));
|
store.dispatch(actions.setTutorial(null));
|
||||||
|
|||||||
@ -10,7 +10,6 @@ function createReducer(defaultState, actionType) {
|
|||||||
/* eslint-disable key-spacing */
|
/* eslint-disable key-spacing */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
account: createReducer(null, 'SET_ACCOUNT'),
|
account: createReducer(null, 'SET_ACCOUNT'),
|
||||||
activeConstruct: createReducer(null, 'SET_ACTIVE_CONSTRUCT'),
|
|
||||||
activeItem: createReducer(null, 'SET_ACTIVE_VAR'),
|
activeItem: createReducer(null, 'SET_ACTIVE_VAR'),
|
||||||
activeSkill: createReducer(null, 'SET_ACTIVE_SKILL'),
|
activeSkill: createReducer(null, 'SET_ACTIVE_SKILL'),
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user