- newGame: function(gameInfo) {
- localStorage["gid"] = getRandString();
- // Extract times (in [milli]seconds), set clocks, store in localStorage
- const tc = extractTime(gameInfo.timeControl);
- 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["mysid"] = this.st.user.sid;
- localStorage["vname"] = this.getVname(gameInfo.vid);
- localStorage["fenInit"] = gameInfo.fen;
- localStorage["players"] = JSON.stringify(gameInfo.players);
+ startNewGame: function(gameInfo) {
+ // Extract times (in [milli]seconds), set clocks
+ const tc = extractTime(c.timeControl);
+ const game = Object.assign({}, gameInfo, {
+ // (other) Game infos: constant
+ fenStart: gameInfo.fen,
+ // Game state (including FEN): will be updated
+ moves: [],
+ clocks: [tc.mainTime, tc.mainTime],
+ initime: [Date.now(), 0],
+ score: "*",
+ });
+ GameStorage.add(game);