don't redirect simul host while replaying a game

This commit is contained in:
Thibault Duplessis 2019-08-27 00:02:25 +02:00
parent d2492268c1
commit a3115d26f9

View file

@ -1,6 +1,7 @@
import * as game from 'game';
import throttle from 'common/throttle';
import notify from 'common/notification';
import { isPlayerTurn } from 'game';
import * as xhr from './xhr';
import * as sound from './sound';
import RoundController from './ctrl';
@ -15,7 +16,7 @@ export interface RoundSocket extends Untyped {
outoftime(): void;
berserk(): void;
sendLoading(typ: string, data?: any): void
receive(typ: string, data: any): boolean;
receive(typ: string, data: any): boolean;
}
interface Incoming {
@ -83,8 +84,8 @@ export function make(send: SocketSend, ctrl: RoundController): RoundSocket {
},
rematchOffer(by: Color) {
d.player.offeringRematch = by === d.player.color;
const fromOp = d.opponent.offeringRematch = by === d.opponent.color;
if (fromOp) notify(ctrl.noarg('yourOpponentWantsToPlayANewGameWithYou'));
if (d.opponent.offeringRematch = by === d.opponent.color)
notify(ctrl.noarg('yourOpponentWantsToPlayANewGameWithYou'));
ctrl.redraw();
},
rematchTaken(nextId: string) {
@ -119,7 +120,7 @@ export function make(send: SocketSend, ctrl: RoundController): RoundSocket {
ctrl.opts.userId == d.simul.hostId &&
gameId !== d.game.id &&
ctrl.moveOn.get() &&
ctrl.chessground.state.turnColor !== ctrl.chessground.state.movable.color) {
!isPlayerTurn(ctrl.data)) {
ctrl.setRedirecting();
sound.move();
li.hasToReload = true;