X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Futils%2Fstorage.js;h=8a7c52684813f35d11dfdcfa40aded8ee034aee4;hb=b4fb161253c5e7b4581ca37d22339111dd4aa861;hp=eb04078198d6c9b81def2b7b6fdd9914a72fe430;hpb=d6c1bf3726afae94867854dda76df2848770068c;p=vchess.git diff --git a/client/src/utils/storage.js b/client/src/utils/storage.js index eb040781..8a7c5268 100644 --- a/client/src/utils/storage.js +++ b/client/src/utils/storage.js @@ -1,5 +1,4 @@ import { extractTime } from "@/utils/timeControl"; -import { shuffle } from "@/utils/alea"; // TODO: show game structure //const newItem = [ @@ -79,10 +78,6 @@ export const GameStorage = // localStorage: init: function(o) { - // NOTE: when >= 3 players, better use an array + shuffle for mycolor - const mycolor = (Math.random() < 0.5 ? "w" : "b"); - // Shuffle players order (white then black then other colors). - const players = shuffle(o.players); // Extract times (in [milli]seconds), set clocks, store in localStorage const tc = extractTime(o.timeControl); @@ -91,9 +86,8 @@ export const GameStorage = { gameId: o.gameId, vname: o.vname, - mycolor: mycolor, fenStart: o.fenStart, - players: players, + players: o.players, timeControl: o.timeControl, increment: tc.increment, mode: "live", //function for live games only @@ -116,12 +110,12 @@ export const GameStorage = // localStorage: // TODO: also option to takeback a move ? Is fen included in move ? // NOTE: for live games only (all on server for corr) - update: function(fen, moves, clocks, started, score) + update: function(fen, move, clocks, started, score) { let gameState = JSON.parse(localStorage.getItem("gameState")); if (!!fen) { - gameState.moves = moves; + gameState.moves.push(move); gameState.fen = fen; gameState.clocks = clocks; }