+ }
+ case "askgame":
+ // Send current (live) game
+ const myGame =
+ {
+ // Minimal game informations:
+ id: this.game.id,
+ players: this.game.players.map(p => p.name),
+ vid: this.game.vid,
+ timeControl: this.game.timeControl,
+ };
+ this.st.conn.send(JSON.stringify({code:"game",
+ game:myGame, target:data.from}));
+ break;
+ case "newmove":
+ // NOTE: this call to play() will trigger processMove()
+ this.$refs["basegame"].play(data.move,
+ "receive", this.game.vname!="Dark" ? "animate" : null);
+ break;
+ case "lastate": //got opponent infos about last move
+ {
+ const L = this.game.moves.length;
+ if (data.movesCount > L)
+ {
+ // Just got last move from him
+ this.$refs["basegame"].play(data.lastMove,
+ "receive", this.game.vname!="Dark" ? "animate" : null);
+ if (data.score != "*" && this.game.score == "*")
+ {
+ // Opponent resigned or aborted game, or accepted draw offer
+ // (this is not a stalemate or checkmate)
+ this.$refs["basegame"].endGame(data.score, "Opponent action");
+ }
+ this.game.clocks = data.clocks; //TODO: check this?
+ this.drawOffer = data.drawOffer; //does opponent offer draw?
+ }
+ break;
+ }