- localStorage["timeControl"] = gameInfo.timeControl;
- localStorage["clocks"] = JSON.stringify(
- [...Array(gameInfo.players.length)].fill(tc.mainTime));
- localStorage["increment"] = tc.increment;
- localStorage["started"] = JSON.stringify(
- [...Array(gameInfo.players.length)].fill(false));
- localStorage["vname"] = this.getVname(gameInfo.vid);
- localStorage["fenInit"] = gameInfo.fen;
- localStorage["players"] = JSON.stringify(gameInfo.players);
+ let initime = [...Array(gameInfo.players.length)];
+ initime[0] = Date.now();
+ const game =
+ {
+ // Game infos: constant
+ gameId: gameInfo.gameId,
+ vname: this.getVname(gameInfo.vid),
+ fenStart: gameInfo.fen,
+ players: gameInfo.players,
+ timeControl: gameInfo.timeControl,
+ increment: tc.increment,
+ mode: "live", //function for live games only
+ // Game state: will be updated
+ fen: gameInfo.fen,
+ moves: [],
+ clocks: [...Array(gameInfo.players.length)].fill(tc.mainTime),
+ initime: initime,
+ score: "*",
+ };
+ GameStorage.add(game);