X-Git-Url: https://git.auder.net/js/rpsls.js?a=blobdiff_plain;f=client%2Fsrc%2Futils%2FgameStorage.js;h=b7cf85c18a111ff044d3041053e57d6dddcf3d1d;hb=7e355d68b5962aad106e28a9d669a47f3cbec43a;hp=0b3a7da64e350748f93f0963990b9f550a0a03e1;hpb=f41ce5806b989c06091a403d7e26ff3c457650c9;p=vchess.git diff --git a/client/src/utils/gameStorage.js b/client/src/utils/gameStorage.js index 0b3a7da6..b7cf85c1 100644 --- a/client/src/utils/gameStorage.js +++ b/client/src/utils/gameStorage.js @@ -1,6 +1,6 @@ // Game object: { // // Static informations: -// gameId: string +// id: string // vname: string, // fenStart: string, // players: array of sid+id+name, @@ -39,7 +39,7 @@ function dbOperation(callback) alert("Error while loading database: " + event.target.errorCode); }; // Create objectStore for vchess->games - let objectStore = db.createObjectStore("games", { keyPath: "gameId" }); + let objectStore = db.createObjectStore("games", { keyPath: "id" }); objectStore.createIndex("score", "score"); //to search by game result } } @@ -81,7 +81,9 @@ export const GameStorage = { move: obj.move, //may be undefined... fen: obj.fen, + message: obj.message, score: obj.score, + drawOffer: obj.drawOffer, } } ); @@ -133,7 +135,11 @@ export const GameStorage = if (Number.isInteger(gameId) || !isNaN(parseInt(gameId))) { ajax("/games", "GET", {gid:gameId}, res => { - callback(res.game); + let game = res.game; + game.moves.forEach(m => { + m.squares = JSON.parse(m.squares); + }); + callback(game); }); } else //local game