+ 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)
+ });
+ }
+ else //live
+ {
+ GameStorage.update(this.gameRef.id,
+ {
+ fen: move.fen,
+ move: filtered_move,
+ clocks: this.game.clocks,
+ initime: this.game.initime,
+ drawOffer: drawCode,
+ });
+ }
+ }
+ },
+ resetChatColor: function() {
+ // TODO: this is called twice, once on opening an once on closing
+ document.getElementById("chatBtn").style.backgroundColor = "#e2e2e2";
+ },
+ processChat: function(chat) {
+ this.send("newchat", {data:chat});
+ // NOTE: anonymous chats in corr games are not stored on server (TODO?)
+ if (this.game.type == "corr" && this.st.user.id > 0)
+ GameStorage.update(this.gameRef.id, {chat: chat});
+ },
+ gameOver: function(score, scoreMsg) {
+ this.game.score = score;
+ this.game.scoreMsg = this.st.tr[(!!scoreMsg
+ ? scoreMsg
+ : getScoreMessage(score))];
+ const myIdx = this.game.players.findIndex(p => {
+ return p.sid == this.st.user.sid || p.uid == this.st.user.id;