+ case "lastate": //got opponent infos about last move (we might have resigned)
+ if (this.mode!="human" || this.oppid!=data.oppid)
+ {
+ // OK, we resigned
+ this.conn.send(JSON.stringify({
+ code:"lastate",
+ oppid:this.oppId,
+ lastMove:undefined,
+ movesCount:-1,
+ }));
+ }
+ else if (data.movesCount < 0)
+ {
+ // OK, he resigned
+ this.endGame(this.mycolor=="w"?"1-0":"0-1");
+ }
+ else if (data.movesCount < this.vr.moves.length)
+ {
+ // We must tell last move to opponent
+ const L = this.vr.moves.length;
+ this.conn.send(JSON.stringify({
+ code:"lastate",
+ oppid:this.oppId,
+ lastMove:this.vr.moves[L-1],
+ movesCount:L,
+ }));
+ }
+ else if (data.movesCount > this.vr.moves.length) //just got last move from him
+ this.play(data.lastMove, "animate");