- this.compWorker.postMessage(["init", this.gameInfo.fen]);
- this.vr = new V(this.gameInfo.fen);
- const mycolor = Math.random() < 0.5 ? "w" : "b";
- let players = [{ name: "Myself" }, { name: "Computer" }];
- if (mycolor == "b") players = players.reverse();
+ if (!game) {
+ game = {
+ vname: this.gameInfo.vname,
+ fenStart: V.GenRandInitFen(options),
+ moves: []
+ };
+ game.fen = game.fenStart;
+ if (this.gameInfo.mode == "versus") CompgameStorage.add(game);
+ }
+ if (!game.mycolor) game.mycolor = (Math.random() < 0.5 ? "w" : "b");
+ this.compWorker.postMessage(["init", game.fen]);
+ this.vr = new V(game.fen);
+ game.players = [{ name: "Computer" }, { name: "Computer" }];
+ if (this.gameInfo.mode == "versus")
+ game.players[game.mycolor == 'w' ? 0 : 1] = { name: "Myself" };
+ game.score = "*"; //finished games are removed
+ game.mode = this.gameInfo.mode;