clean up abandon and reset tutorial if in progress
This commit is contained in:
parent
bb94e43ca1
commit
29c4bfe891
@ -8,6 +8,7 @@ const addState = connect(
|
|||||||
const {
|
const {
|
||||||
ws,
|
ws,
|
||||||
game,
|
game,
|
||||||
|
animating,
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
function sendAbandon() {
|
function sendAbandon() {
|
||||||
@ -16,30 +17,31 @@ const addState = connect(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
game,
|
game,
|
||||||
|
|
||||||
sendAbandon,
|
sendAbandon,
|
||||||
|
animating,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
function receiveDispatch(dispatch) {
|
function receiveDispatch(dispatch) {
|
||||||
function leave() {
|
function leave() {
|
||||||
dispatch(actions.setNav('play'));
|
dispatch(actions.setNav('play'));
|
||||||
dispatch(actions.setGame(null));
|
dispatch(actions.setGame(null));
|
||||||
dispatch(actions.setInstance(null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { leave };
|
return { leave };
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
function GameCtrlTopBtns(args) {
|
function GameCtrlTopBtns(args) {
|
||||||
const {
|
const {
|
||||||
game,
|
game,
|
||||||
|
|
||||||
leave,
|
leave,
|
||||||
sendAbandon,
|
sendAbandon,
|
||||||
|
animating,
|
||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
const finished = game && game.phase === 'Finished';
|
const finished = game && game.phase === 'Finish';
|
||||||
const { abandonState } = this.state;
|
const { abandonState } = this.state;
|
||||||
|
|
||||||
const abandonStateTrue = e => {
|
const abandonStateTrue = e => {
|
||||||
@ -52,7 +54,7 @@ function GameCtrlTopBtns(args) {
|
|||||||
const abandonText = abandonState ? 'Confirm' : 'Abandon';
|
const abandonText = abandonState ? 'Confirm' : 'Abandon';
|
||||||
const abandonAction = abandonState ? sendAbandon : abandonStateTrue;
|
const abandonAction = abandonState ? sendAbandon : abandonStateTrue;
|
||||||
|
|
||||||
const abandonBtn = <button class={abandonClasses} disabled={finished} onClick={abandonAction}>{abandonText}</button>;
|
const abandonBtn = <button class={abandonClasses} disabled={finished || animating} onClick={abandonAction}>{abandonText}</button>;
|
||||||
const leaveBtn = <button class='abandon confirming' onClick={leave}>Leave</button>;
|
const leaveBtn = <button class='abandon confirming' onClick={leave}>Leave</button>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -8,6 +8,7 @@ const addState = connect(
|
|||||||
const {
|
const {
|
||||||
ws,
|
ws,
|
||||||
instance,
|
instance,
|
||||||
|
tutorial,
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
function sendAbandon() {
|
function sendAbandon() {
|
||||||
@ -21,10 +22,11 @@ const addState = connect(
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
function receiveDispatch(dispatch) {
|
function receiveDispatch(dispatch) {
|
||||||
function leave() {
|
function leave(tutorial) {
|
||||||
dispatch(actions.setNav('play'));
|
dispatch(actions.setNav('play'));
|
||||||
dispatch(actions.setGame(null));
|
dispatch(actions.setGame(null));
|
||||||
dispatch(actions.setInstance(null));
|
dispatch(actions.setInstance(null));
|
||||||
|
if (tutorial && tutorial < 7) dispatch(actions.setTutorial(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return { leave };
|
return { leave };
|
||||||
@ -37,6 +39,7 @@ function InstanceTopBtns(args) {
|
|||||||
|
|
||||||
leave,
|
leave,
|
||||||
sendAbandon,
|
sendAbandon,
|
||||||
|
tutorial,
|
||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
const finished = instance && instance.phase === 'Finished';
|
const finished = instance && instance.phase === 'Finished';
|
||||||
@ -53,7 +56,7 @@ function InstanceTopBtns(args) {
|
|||||||
const abandonAction = abandonState ? sendAbandon : abandonStateTrue;
|
const abandonAction = abandonState ? sendAbandon : abandonStateTrue;
|
||||||
|
|
||||||
const abandonBtn = <button class={abandonClasses} disabled={finished} onClick={abandonAction}>{abandonText}</button>;
|
const abandonBtn = <button class={abandonClasses} disabled={finished} onClick={abandonAction}>{abandonText}</button>;
|
||||||
const leaveBtn = <button class='abandon confirming' onClick={leave}>Leave</button>;
|
const leaveBtn = <button class='abandon confirming' onClick={() => leave(tutorial)}>Leave</button>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="instance-ctrl-btns">
|
<div class="instance-ctrl-btns">
|
||||||
|
|||||||
@ -164,7 +164,7 @@ function Vbox(args) {
|
|||||||
|
|
||||||
function availableBtn(v, group, index) {
|
function availableBtn(v, group, index) {
|
||||||
if (!v) return <button disabled class='empty' > </button>;
|
if (!v) return <button disabled class='empty' > </button>;
|
||||||
const selected = vboxSelected[0] === group && vboxSelected[1] === index;
|
const selected = vboxSelected[0] === group && vboxSelected[1] === index;
|
||||||
|
|
||||||
// state not yet set in double click handler
|
// state not yet set in double click handler
|
||||||
function onDblClick(e) {
|
function onDblClick(e) {
|
||||||
|
|||||||
@ -210,7 +210,6 @@ function registerEvents(store) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (v.phase === 'Finished') {
|
if (v.phase === 'Finished') {
|
||||||
setGame(null);
|
|
||||||
ws.sendAccountInstances();
|
ws.sendAccountInstances();
|
||||||
}
|
}
|
||||||
if (v.time_control === 'Practice' && v.rounds.length === 1 && tutorial) {
|
if (v.time_control === 'Practice' && v.rounds.length === 1 && tutorial) {
|
||||||
|
|||||||
@ -78,7 +78,6 @@ function tutorialVbox(player, store, tutorial) {
|
|||||||
vbox.free[2] = [];
|
vbox.free[2] = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(stage);
|
|
||||||
store.dispatch(actions.setTutorial(stage));
|
store.dispatch(actions.setTutorial(stage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user