update: function(gameId, obj) {
if (Number.isInteger(gameId) || !isNaN(parseInt(gameId))) {
// corr: only move, fen and score
-console.log(obj.move);
ajax("/games", "PUT", {
gid: gameId,
newObj: {
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:
-
-
-console.log(moveCol + " " + this.game.type);
-
if (
this.game.mycolor &&
(this.game.type == "live" || moveCol == this.game.mycolor)
break;
}
if (this.game.type == "corr") {
-
-
-console.log("DO UPDATE");
-
GameStorage.update(this.gameRef.id, {
fen: this.game.fen,
move: {
"WHERE gid = " + id;
db.get(query, (err,ret) => {
const m = obj.move;
+
+
+
if (!ret.maxIdx || ret.maxIdx + 1 == m.idx) {
query =
"INSERT INTO Moves (gid, squares, played, idx) VALUES " +
"(" + id + ",?," + m.played + "," + m.idx + ")";
+return cb({errmsg: (!ret.maxIdx || ret.maxIdx + 1 == m.idx) + " " + query});
db.run(query, JSON.stringify(m.squares));
cb(null);
}