+ // NOTE: variants array might not be available yet, thus the two next lines
+ const variantCell = this.st.variants.filter(v => v.id == game.vid);
+ const vname = (variantCell.length > 0 ? variantCell[0].name : "");
+ if (!game.fen)
+ game.fen = game.fenStart; //game wasn't started
+ const gtype = (game.timeControl.indexOf('d') >= 0 ? "corr" : "live");
+ if (gtype == "corr")
+ {
+ // corr game: needs to compute the clocks + initime
+ //if (game.players[i].rtime < 0) initime = Date.now(), else compute,
+ //also using move.played fields
+ game.clocks = [-1, -1];
+ game.initime = [0, 0];
+ // TODO: compute clocks + initime
+ }
+ const tc = extractTime(game.timeControl);
+ // TODO: this is not really beautiful (uid on corr players...)
+ if (gtype == "corr" && game.players[0].color == "b")
+ [ game.players[0], game.players[1] ] = [ game.players[1], game.players[0] ];
+ const myIdx = game.players.findIndex(p => {
+ return p.sid == this.st.user.sid || p.uid == this.st.user.id;
+ });
+ if (game.clocks[0] < 0) //game unstarted
+ {
+ game.clocks = [tc.mainTime, tc.mainTime];
+ game.initime[0] = Date.now();
+ if (myIdx >= 0) //I play in this game
+ {
+ GameStorage.update(game.gameId,
+ {
+ clocks: game.clocks,
+ initime: game.initime,
+ });
+ }
+ }
+ const vModule = await import("@/variants/" + vname + ".js");