X-Git-Url: https://git.auder.net/images/pieces/Cwda/bd.svg?a=blobdiff_plain;f=client%2Fsrc%2Futils%2Fstorage.js;h=48435b51175b2efb4fd5b03ec3c15a51735e929e;hb=4b0384faf03d3842ba2f80ccd6d104c5e34a355e;hp=2c2d4be27f3c8b23b4870e68c27e7f0e4596a89e;hpb=8f5780d8cc67245c01cb381853a56cb510ad9ab2;p=vchess.git diff --git a/client/src/utils/storage.js b/client/src/utils/storage.js index 2c2d4be2..48435b51 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 @@ -137,7 +131,7 @@ export const GameStorage = // indexedDB: // Since DB requests are asynchronous, require a callback using the result // TODO: option for remote retrieval (third arg, or just "gameRef") - getLocal: function(callback, gameId) + getLocal: function(gameId, callback) { let games = []; dbOperation((db) => { @@ -200,6 +194,6 @@ export const GameStorage = } // Game is local and not running - getLocal(callback, gid); + GameStorage.getLocal(gid, callback); }, };