X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Futils%2Fstorage.js;h=ecafe20502141f16c52142590c1c0473fc24c866;hp=f5c3b2534be63f44b9e374d783a3ca28583c0274;hb=6ec161b904b068b0f07defce45dba936933f4a1b;hpb=9d54ab8900b69876c3249b4ed1bfa355dccb7f97 diff --git a/client/src/utils/storage.js b/client/src/utils/storage.js index f5c3b253..ecafe205 100644 --- a/client/src/utils/storage.js +++ b/client/src/utils/storage.js @@ -99,7 +99,7 @@ export const GameStorage = fen: o.fenStart, moves: [], clocks: [...Array(o.players.length)].fill(tc.mainTime), - started: [...Array(o.players.length)].fill(false), + initime: undefined, score: "*", }; @@ -123,7 +123,8 @@ export const GameStorage = { gameState.moves.push(o.move); gameState.fen = o.fen; - gameState.clocks[o.colorIdx] += (o.increment - o.elapsed); + if (!!o.elapsed) //NaN if first move in game + gameState.clocks[o.colorIdx] += (o.increment - o.elapsed); } if (!!o.initime) //just a flag (true) gameState.initime = Date.now(); @@ -168,7 +169,7 @@ export const GameStorage = callback({}); //everything's fine } transaction.onerror = function() { - callback({errmsg: "deleteGame failed: " + transaction.error}); + callback({errmsg: "game removal failed: " + transaction.error}); }; } transaction.objectStore("games").delete(gameId);