fix game navigation and added skip

This commit is contained in:
ntr 2019-05-19 18:38:25 +10:00
parent d72118b157
commit fedc52b558
7 changed files with 40 additions and 15 deletions

View File

@ -7,6 +7,9 @@ export const setCryps = value => ({ type: SET_CRYPS, value });
export const SET_VBOX_INFO = 'SET_VBOX_INFO'; export const SET_VBOX_INFO = 'SET_VBOX_INFO';
export const setVboxInfo = value => ({ type: SET_VBOX_INFO, value }); export const setVboxInfo = value => ({ type: SET_VBOX_INFO, value });
export const SET_SKIP = 'SET_SKIP';
export const setSkip = value => ({ type: SET_SKIP, value });
export const SET_VBOX_HIGHLIGHT = 'SET_VBOX_HIGHLIGHT'; export const SET_VBOX_HIGHLIGHT = 'SET_VBOX_HIGHLIGHT';
export const setVboxHighlight = value => ({ type: SET_VBOX_HIGHLIGHT, value }); export const setVboxHighlight = value => ({ type: SET_VBOX_HIGHLIGHT, value });

View File

@ -15,6 +15,7 @@ function GamePanel(props) {
sendGameReady, sendGameReady,
showLog, showLog,
toggleLog, toggleLog,
skip,
quit, quit,
} = props; } = props;
@ -41,17 +42,29 @@ function GamePanel(props) {
// ); // );
// } // }
function backClick() { function actionClick() {
if (game.phase === 'Finish') sendInstanceState(game.instance); if (game.phase === 'Finish') {
return quit(); sendInstanceState(game.instance);
quit();
}
if (resolution) {
return skip();
}
return sendGameReady();
} }
let actionText = 'Ready';
if (game.phase === 'Finish') actionText = 'Done';
if (resolution) actionText = 'Skip';
const header = ( const header = (
<div className="top"> <div className="top">
<button <button
className="instance-btn instance-ui-btn right" className="instance-btn instance-ui-btn right"
onClick={() => sendGameReady()}> onClick={() => actionClick()}>
Ready {actionText}
</button> </button>
</div> </div>
); );

View File

@ -69,8 +69,11 @@ const addState = connect(
dispatch(actions.setShowLog(v)); dispatch(actions.setShowLog(v));
} }
function skip() {
dispatch(actions.setSkip(true));
}
return { setActiveSkill, setActiveCryp, quit, toggleLog }; return { setActiveSkill, setActiveCryp, quit, toggleLog, skip };
} }
); );

View File

@ -31,15 +31,6 @@ function Main(props) {
); );
} }
if (nav === 'team') return <Team />;
if (nav === 'list') return <List />;
if (instance) {
return (
<InstanceContainer />
);
}
if (game) { if (game) {
console.log('game time'); console.log('game time');
return ( return (
@ -47,6 +38,14 @@ function Main(props) {
); );
} }
if (instance) {
return (
<InstanceContainer />
);
}
if (nav === 'team') return <Team />;
if (nav === 'list') return <List />;
return ( return (
<Team /> <Team />

View File

@ -37,6 +37,8 @@ const addState = connect(
} }
function navTo(place) { function navTo(place) {
dispatch(actions.setGame(null));
dispatch(actions.setInstance(null));
return dispatch(actions.setNav(place)); return dispatch(actions.setNav(place));
} }

View File

@ -66,6 +66,8 @@ function registerEvents(store) {
// Create sub events for combat animations // Create sub events for combat animations
const sequence = getCombatSequence(r.event); const sequence = getCombatSequence(r.event);
return eachSeries(sequence, (stage, sCb) => { return eachSeries(sequence, (stage, sCb) => {
const { skip } = store.getState();
if (skip) return sCb();
const stagedR = Object.create(r); const stagedR = Object.create(r);
stagedR.stage = stage; stagedR.stage = stage;
store.dispatch(actions.setResolution(stagedR)); store.dispatch(actions.setResolution(stagedR));
@ -78,6 +80,8 @@ function registerEvents(store) {
}, err => { }, err => {
if (err) return console.error(err); if (err) return console.error(err);
store.dispatch(actions.setResolution(null)); store.dispatch(actions.setResolution(null));
// stop skipping resolutions
store.dispatch(actions.setSkip(false));
// update the game // update the game
store.dispatch(actions.setGame(game)); store.dispatch(actions.setGame(game));
// get the latest state and restart polling // get the latest state and restart polling

View File

@ -23,6 +23,7 @@ module.exports = {
info: createReducer([null, null], actions.SET_INFO), info: createReducer([null, null], actions.SET_INFO),
instance: createReducer(null, actions.SET_INSTANCE), instance: createReducer(null, actions.SET_INSTANCE),
instances: createReducer([], actions.SET_INSTANCES), instances: createReducer([], actions.SET_INSTANCES),
skip: createReducer(false, actions.SET_SKIP),
nav: createReducer(null, actions.SET_NAV), nav: createReducer(null, actions.SET_NAV),
ping: createReducer(null, actions.SET_PING), ping: createReducer(null, actions.SET_PING),
player: createReducer(null, actions.SET_PLAYER), player: createReducer(null, actions.SET_PLAYER),