disconnect timer seconds - closes #5888

user-games-dl-form
Thibault Duplessis 2020-01-08 21:29:11 -06:00
parent 7ab94e6cae
commit 45590bce42
2 changed files with 14 additions and 8 deletions

View File

@ -635,6 +635,18 @@ export default class RoundController {
if (this.opts.onChange) setTimeout(() => this.opts.onChange(this.data), 150);
};
private goneTick;
setGone = (gone: number | boolean) => {
game.setGone(this.data, this.data.opponent.color, gone);
clearTimeout(this.goneTick);
if (Number(gone) > 1)
this.goneTick = setTimeout(() => {
const g = Number(this.opponentGone());
if (g > 1) this.setGone(g - 1);
}, 1000);
this.redraw();
}
opponentGone = (): number | boolean => {
const d = this.data;
return d.opponent.gone !== false &&

View File

@ -124,14 +124,8 @@ export function make(send: SocketSend, ctrl: RoundController): RoundSocket {
berserk(color: Color) {
ctrl.setBerserk(color);
},
gone(isGone) {
game.setGone(d, d.opponent.color, isGone);
ctrl.redraw();
},
goneIn(seconds) {
game.setGone(d, d.opponent.color, seconds);
ctrl.redraw();
},
gone: ctrl.setGone,
goneIn: ctrl.setGone,
checkCount(e) {
d.player.checks = d.player.color == 'white' ? e.white : e.black;
d.opponent.checks = d.opponent.color == 'white' ? e.white : e.black;