- if (move.cancelDrawOffer) {
- // Opponent refuses draw
- this.drawOffer = "";
- // NOTE for corr games: drawOffer reset by player in turn
- if (this.game.type == "live" && !!this.game.mycolor)
- GameStorage.update(this.gameRef.id, { drawOffer: "" });
+ if (move.index > this.game.movesCount && !this.fullGameRequested) {
+ // This can only happen if I'm an observer and missed a move:
+ // just ask fullgame again, this is much simpler.
+ (function askIfPeerConnected() {
+ if (!!this.people[this.gameRef.rid])
+ this.send("askfullgame", { target: this.gameRef.rid });
+ else setTimeout(askIfPeerConnected, 1000);
+ })();
+ this.fullGameRequested = true;
+ } else {
+ if (
+ move.index < this.game.movesCount ||
+ this.gotMoveIdx >= move.index
+ ) {
+ // Opponent re-send but we already have the move:
+ // (maybe he didn't receive our pingback...)
+ // TODO: currently, all opponent game tabs will receive this
+ this.send("gotmove", {index: move.index, target: data.from});
+ } else {
+ const receiveMyMove = (
+ !!this.game.mycolor &&
+ move.index == this.game.movesCount
+ );
+ if (!receiveMyMove && !!this.game.mycolor)
+ // Notify opponent that I got the move:
+ this.send("gotmove", {index: move.index, target: data.from});
+ if (move.cancelDrawOffer) {
+ // Opponent refuses draw
+ this.drawOffer = "";
+ // NOTE for corr games: drawOffer reset by player in turn
+ if (
+ this.game.type == "live" &&
+ !!this.game.mycolor &&
+ !receiveMyMove
+ ) {
+ GameStorage.update(this.gameRef.id, { drawOffer: "" });
+ }
+ }
+ this.$refs["basegame"].play(
+ move.move,
+ "received",
+ null,
+ {
+ addTime: move.addTime,
+ receiveMyMove: receiveMyMove
+ }
+ );
+ }