Add debug trace to understand why corr move 1 isn't recorded
authorBenjamin Auder <benjamin.auder@somewhere>
Wed, 4 Mar 2020 22:51:36 +0000 (23:51 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Wed, 4 Mar 2020 22:51:36 +0000 (23:51 +0100)
client/src/utils/gameStorage.js
client/src/views/Game.vue
server/models/Game.js

index 2756496..dfbd639 100644 (file)
@@ -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: {
index 137e5a9..8f49c5d 100644 (file)
@@ -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: {
index d72f51a..cfaddfe 100644 (file)
@@ -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);
           }