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 {
|
||||
ws,
|
||||
game,
|
||||
animating,
|
||||
} = state;
|
||||
|
||||
function sendAbandon() {
|
||||
@ -16,30 +17,31 @@ const addState = connect(
|
||||
|
||||
return {
|
||||
game,
|
||||
|
||||
sendAbandon,
|
||||
animating,
|
||||
};
|
||||
},
|
||||
|
||||
function receiveDispatch(dispatch) {
|
||||
function leave() {
|
||||
dispatch(actions.setNav('play'));
|
||||
dispatch(actions.setGame(null));
|
||||
dispatch(actions.setInstance(null));
|
||||
}
|
||||
|
||||
return { leave };
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
function GameCtrlTopBtns(args) {
|
||||
const {
|
||||
game,
|
||||
|
||||
leave,
|
||||
sendAbandon,
|
||||
animating,
|
||||
} = args;
|
||||
|
||||
const finished = game && game.phase === 'Finished';
|
||||
const finished = game && game.phase === 'Finish';
|
||||
const { abandonState } = this.state;
|
||||
|
||||
const abandonStateTrue = e => {
|
||||
@ -52,7 +54,7 @@ function GameCtrlTopBtns(args) {
|
||||
const abandonText = abandonState ? 'Confirm' : 'Abandon';
|
||||
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>;
|
||||
|
||||
return (
|
||||
|
||||
@ -8,6 +8,7 @@ const addState = connect(
|
||||
const {
|
||||
ws,
|
||||
instance,
|
||||
tutorial,
|
||||
} = state;
|
||||
|
||||
function sendAbandon() {
|
||||
@ -21,10 +22,11 @@ const addState = connect(
|
||||
};
|
||||
},
|
||||
function receiveDispatch(dispatch) {
|
||||
function leave() {
|
||||
function leave(tutorial) {
|
||||
dispatch(actions.setNav('play'));
|
||||
dispatch(actions.setGame(null));
|
||||
dispatch(actions.setInstance(null));
|
||||
if (tutorial && tutorial < 7) dispatch(actions.setTutorial(1));
|
||||
}
|
||||
|
||||
return { leave };
|
||||
@ -37,6 +39,7 @@ function InstanceTopBtns(args) {
|
||||
|
||||
leave,
|
||||
sendAbandon,
|
||||
tutorial,
|
||||
} = args;
|
||||
|
||||
const finished = instance && instance.phase === 'Finished';
|
||||
@ -53,7 +56,7 @@ function InstanceTopBtns(args) {
|
||||
const abandonAction = abandonState ? sendAbandon : abandonStateTrue;
|
||||
|
||||
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 (
|
||||
<div class="instance-ctrl-btns">
|
||||
|
||||
@ -164,7 +164,7 @@ function Vbox(args) {
|
||||
|
||||
function availableBtn(v, group, index) {
|
||||
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
|
||||
function onDblClick(e) {
|
||||
|
||||
@ -210,7 +210,6 @@ function registerEvents(store) {
|
||||
}
|
||||
|
||||
if (v.phase === 'Finished') {
|
||||
setGame(null);
|
||||
ws.sendAccountInstances();
|
||||
}
|
||||
if (v.time_control === 'Practice' && v.rounds.length === 1 && tutorial) {
|
||||
|
||||
@ -78,7 +78,6 @@ function tutorialVbox(player, store, tutorial) {
|
||||
vbox.free[2] = [];
|
||||
}
|
||||
}
|
||||
console.log(stage);
|
||||
store.dispatch(actions.setTutorial(stage));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user