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 setActiveConstruct = value => ({ type: 'SET_ACTIVE_CONSTRUCT', value });
|
||||
|
||||
export const setAnimating = value => ({ type: 'SET_ANIMATING', value });
|
||||
export const setAnimCb = value => ({ type: 'SET_ANIM_CB', value });
|
||||
|
||||
@ -36,7 +36,6 @@ const addState = connect(
|
||||
dispatch(actions.setCombiner([]));
|
||||
dispatch(actions.setReclaiming(false));
|
||||
dispatch(actions.setActiveSkill(null));
|
||||
dispatch(actions.setActiveConstruct(null));
|
||||
dispatch(actions.setInfo(null));
|
||||
dispatch(actions.setItemEquip(null));
|
||||
dispatch(actions.setItemUnequip([]));
|
||||
|
||||
@ -14,7 +14,6 @@ const addState = connect(
|
||||
account,
|
||||
animating,
|
||||
activeSkill,
|
||||
activeConstruct,
|
||||
} = state;
|
||||
|
||||
function selectSkillTarget(targetConstructId) {
|
||||
@ -34,7 +33,6 @@ const addState = connect(
|
||||
account,
|
||||
animating,
|
||||
activeSkill,
|
||||
activeConstruct,
|
||||
selectSkillTarget,
|
||||
};
|
||||
},
|
||||
@ -44,11 +42,7 @@ const addState = connect(
|
||||
dispatch(actions.setActiveSkill(constructId, skill));
|
||||
}
|
||||
|
||||
function setActiveConstruct(construct) {
|
||||
dispatch(actions.setActiveConstruct(construct));
|
||||
}
|
||||
|
||||
return { setActiveSkill, setActiveConstruct };
|
||||
return { setActiveSkill };
|
||||
}
|
||||
|
||||
);
|
||||
@ -59,7 +53,6 @@ function Game(props) {
|
||||
account,
|
||||
animating,
|
||||
setActiveSkill,
|
||||
setActiveConstruct,
|
||||
} = props;
|
||||
|
||||
if (!game) return <div>...</div>;
|
||||
@ -91,7 +84,6 @@ function Game(props) {
|
||||
|
||||
function gameClick(e) {
|
||||
e.stopPropagation();
|
||||
setActiveConstruct(null);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -35,7 +35,6 @@ const addState = connect(
|
||||
dispatch(actions.setCombiner([]));
|
||||
dispatch(actions.setReclaiming(false));
|
||||
dispatch(actions.setActiveSkill(null));
|
||||
dispatch(actions.setActiveConstruct(null));
|
||||
dispatch(actions.setInfo(null));
|
||||
dispatch(actions.setItemEquip(null));
|
||||
dispatch(actions.setItemUnequip([]));
|
||||
|
||||
@ -66,10 +66,6 @@ const addState = connect(
|
||||
dispatch(actions.setInfo(item));
|
||||
}
|
||||
|
||||
function setActiveConstruct(value) {
|
||||
dispatch(actions.setActiveConstruct(value));
|
||||
}
|
||||
|
||||
function setItemEquip(v) {
|
||||
return dispatch(actions.setItemEquip(v));
|
||||
}
|
||||
@ -78,7 +74,7 @@ const addState = connect(
|
||||
return dispatch(actions.setItemUnequip(v));
|
||||
}
|
||||
|
||||
return { quit, setInfo, setActiveConstruct, setItemUnequip, setItemEquip };
|
||||
return { quit, setInfo, setItemUnequip, setItemEquip };
|
||||
}
|
||||
|
||||
);
|
||||
@ -101,7 +97,6 @@ function Construct(props) {
|
||||
sendVboxAcceptEquip,
|
||||
sendVboxUnequipApply,
|
||||
sendUnequip,
|
||||
setActiveConstruct,
|
||||
setItemUnequip,
|
||||
setItemEquip,
|
||||
setInfo,
|
||||
@ -144,7 +139,6 @@ function Construct(props) {
|
||||
function skillClick(e) {
|
||||
if (!skill) return false;
|
||||
setItemUnequip([construct.id, skill.skill]);
|
||||
setActiveConstruct(construct);
|
||||
e.stopPropagation();
|
||||
return true;
|
||||
}
|
||||
@ -152,7 +146,6 @@ function Construct(props) {
|
||||
function skillDblClick(e) {
|
||||
if (!skill) return false;
|
||||
sendUnequip(construct.id, skill.skill);
|
||||
setActiveConstruct(null);
|
||||
setItemUnequip([]);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
@ -203,12 +196,10 @@ function Construct(props) {
|
||||
function specClick(e) {
|
||||
e.stopPropagation();
|
||||
setItemUnequip([construct.id, s]);
|
||||
setActiveConstruct(construct);
|
||||
}
|
||||
|
||||
function specDblClick(e) {
|
||||
sendUnequip(construct.id, s);
|
||||
setActiveConstruct(null);
|
||||
setItemUnequip([]);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
@ -291,7 +282,6 @@ class InstanceConstructs extends preact.Component {
|
||||
itemInfo,
|
||||
// Function calls
|
||||
setInfo,
|
||||
setActiveConstruct,
|
||||
sendVboxApply,
|
||||
sendVboxAcceptEquip,
|
||||
sendVboxUnequipApply,
|
||||
@ -321,7 +311,6 @@ class InstanceConstructs extends preact.Component {
|
||||
sendVboxAcceptEquip,
|
||||
sendVboxUnequipApply,
|
||||
setInfo,
|
||||
setActiveConstruct,
|
||||
itemInfo,
|
||||
setVboxHighlight,
|
||||
sendUnequip,
|
||||
@ -331,7 +320,7 @@ class InstanceConstructs extends preact.Component {
|
||||
});
|
||||
|
||||
return (
|
||||
<div class='construct-list' onClick={() => setActiveConstruct(null)}>
|
||||
<div class='construct-list'>
|
||||
{constructs}
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -55,15 +55,6 @@ function InstanceCtrlBtns(args) {
|
||||
|
||||
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 (
|
||||
<div class="instance-ctrl-btns">
|
||||
<button disabled={!account.subscribed} onClick={() => setChatShow(!chatShow)}>Chat</button>
|
||||
|
||||
@ -36,7 +36,6 @@ const addState = connect(
|
||||
dispatch(actions.setCombiner([]));
|
||||
dispatch(actions.setReclaiming(false));
|
||||
dispatch(actions.setActiveSkill(null));
|
||||
dispatch(actions.setActiveConstruct(null));
|
||||
dispatch(actions.setInfo(null));
|
||||
dispatch(actions.setItemEquip(null));
|
||||
dispatch(actions.setItemUnequip([]));
|
||||
|
||||
@ -177,7 +177,6 @@ function registerEvents(store) {
|
||||
|
||||
function clearInfo() {
|
||||
store.dispatch(actions.setInfo(null));
|
||||
store.dispatch(actions.setActiveConstruct(null));
|
||||
console.log('event clear item');
|
||||
}
|
||||
|
||||
@ -185,7 +184,6 @@ function registerEvents(store) {
|
||||
store.dispatch(actions.setCombiner([]));
|
||||
store.dispatch(actions.setReclaiming(false));
|
||||
store.dispatch(actions.setActiveSkill(null));
|
||||
store.dispatch(actions.setActiveConstruct(null));
|
||||
store.dispatch(actions.setInfo(null));
|
||||
store.dispatch(actions.setItemEquip(null));
|
||||
store.dispatch(actions.setItemUnequip([]));
|
||||
@ -208,6 +206,7 @@ function registerEvents(store) {
|
||||
return store.dispatch(actions.setInvite(code));
|
||||
}
|
||||
|
||||
let autoReady = null;
|
||||
function setInstance(v) {
|
||||
const { account, instance, ws, tutorial } = store.getState();
|
||||
if (v) {
|
||||
@ -216,15 +215,23 @@ function registerEvents(store) {
|
||||
store.dispatch(actions.setPlayer(player));
|
||||
|
||||
if (!instance || v.id !== instance.id) {
|
||||
store.dispatch(actions.setNav('vbox'));
|
||||
const first = player.constructs[0];
|
||||
store.dispatch(actions.setActiveConstruct(first));
|
||||
clearTimeout(autoReady);
|
||||
}
|
||||
|
||||
if (v.phase === 'Finished') {
|
||||
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
|
||||
if (localStorage.getItem('tutorial-complete') || window.innerWidth <= 1100) {
|
||||
store.dispatch(actions.setTutorial(null));
|
||||
|
||||
@ -10,7 +10,6 @@ function createReducer(defaultState, actionType) {
|
||||
/* eslint-disable key-spacing */
|
||||
module.exports = {
|
||||
account: createReducer(null, 'SET_ACCOUNT'),
|
||||
activeConstruct: createReducer(null, 'SET_ACTIVE_CONSTRUCT'),
|
||||
activeItem: createReducer(null, 'SET_ACTIVE_VAR'),
|
||||
activeSkill: createReducer(null, 'SET_ACTIVE_SKILL'),
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user