From: Benjamin Auder Date: Wed, 4 Mar 2020 22:51:36 +0000 (+0100) Subject: Add debug trace to understand why corr move 1 isn't recorded X-Git-Url: https://git.auder.net/doc/html/assets/scripts/pieces/cb.svg?a=commitdiff_plain;h=e4b6e2850770c0511ddd17d29adf6a903b4792b1;p=vchess.git Add debug trace to understand why corr move 1 isn't recorded --- diff --git a/client/src/utils/gameStorage.js b/client/src/utils/gameStorage.js index 27564966..dfbd6394 100644 --- a/client/src/utils/gameStorage.js +++ b/client/src/utils/gameStorage.js @@ -62,7 +62,6 @@ export const GameStorage = { 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: { diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 137e5a9f..8f49c5d7 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -710,10 +710,6 @@ export default { 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) @@ -731,10 +727,6 @@ console.log(moveCol + " " + this.game.type); break; } if (this.game.type == "corr") { - - -console.log("DO UPDATE"); - GameStorage.update(this.gameRef.id, { fen: this.game.fen, move: { diff --git a/server/models/Game.js b/server/models/Game.js index d72f51a1..cfaddfef 100644 --- a/server/models/Game.js +++ b/server/models/Game.js @@ -252,10 +252,14 @@ const GameModel = "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); }