- 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: ""});
+ // Send our "last state" informations to opponent
+ const L = this.game.moves.length;
+ const myIdx = ["w","b"].indexOf(this.game.mycolor);
+ const myLastate = {
+ // NOTE: lastMove (when defined) includes addTime
+ lastMove: (L>0 ? this.game.moves[L-1] : undefined),
+ // Since we played a move (or abort or resign),
+ // only drawOffer=="sent" is possible
+ drawSent: this.drawOffer == "sent",
+ score: this.game.score,
+ movesCount: L,
+ initime: this.game.initime[1-myIdx], //relevant only if I played
+ };
+ this.send("lastate", {data:myLastate, target:data.from});