+ sendLastate: function(target) {
+ if (
+ (this.game.moves.length > 0 && this.vr.turn != this.game.mycolor) ||
+ this.game.score != "*" ||
+ this.drawOffer == "sent" ||
+ this.rematchOffer == "sent"
+ ) {
+ // Send our "last state" informations to opponent
+ const L = this.game.moves.length;
+ const myIdx = ["w", "b"].indexOf(this.game.mycolor);
+ const myLastate = {
+ lastMove: L > 0 ? this.game.moves[L - 1] : undefined,
+ clock: this.game.clocks[myIdx],
+ // Since we played a move (or abort or resign),
+ // only drawOffer=="sent" is possible
+ drawSent: this.drawOffer == "sent",
+ rematchSent: this.rematchOffer == "sent",
+ score: this.game.score,
+ score: this.game.scoreMsg,
+ movesCount: L,
+ initime: this.game.initime[1 - myIdx] //relevant only if I played
+ };
+ this.send("lastate", { data: myLastate, target: target });
+ } else {
+ this.send("lastate", { data: {nothing: true}, target: target });
+ }
+ },