- cancelDrawOffer: this.drawOffer=="",
- });
- this.send("newmove", {data: sendMove});
- // (Add)Time indication: useful in case of lastate infos requested
- move.addTime = addTime;
- }
- else
- addTime = move.addTime; //supposed transmitted
- // Update current game object:
- this.game.moves.push(move);
- this.game.fen = move.fen;
- this.$set(this.game.clocks, colorIdx, this.game.clocks[colorIdx] + addTime);
- // move.initime is set only when I receive a "lastate" move from opponent
- this.game.initime[nextIdx] = move.initime || Date.now();
- // If repetition detected, consider that a draw offer was received:
- const fenObj = V.ParseFen(move.fen);
- let repIdx = fenObj.position + "_" + fenObj.turn;
- if (!!fenObj.flags)
- repIdx += "_" + fenObj.flags;
- this.repeat[repIdx] = (!!this.repeat[repIdx]
- ? this.repeat[repIdx]+1
- : 1);
- if (this.repeat[repIdx] >= 3)
- this.drawOffer = "threerep";
- else if (this.drawOffer == "threerep")
- this.drawOffer = "";
- // Since corr games are stored at only one location, update should be
- // done only by one player for each move:
- if (!!this.game.mycolor &&
- (this.game.type == "live" || move.color == this.game.mycolor))
- {
- let drawCode = "";
- switch (this.drawOffer)
- {
- case "threerep":
- drawCode = "t";
- break;
- case "sent":
- drawCode = this.game.mycolor;
- break;
- case "received":
- drawCode = this.vr.turn;
- break;
- }
- if (this.game.type == "corr")
- {
- GameStorage.update(this.gameRef.id,
- {
- fen: move.fen,
- move:
- {
- squares: filtered_move,
- played: Date.now(),
- idx: this.game.moves.length - 1,
- },
- drawOffer: drawCode || "n", //"n" for "None" to force reset (otherwise it's ignored)
- });
+ cancelDrawOffer: this.drawOffer == "",
+ // Players' SID required for /mygames page
+ // TODO: precompute and add this field to game object?
+ players: this.game.players.map(p => p.sid)
+ };
+ this.send("newmove", { data: sendMove });