- this.compWorker.postMessage(["scripts",this.vname]);
- this.compWorker.postMessage(["init",this.fen]);
- this.newGameFromFen(this.fen);
- },
- newGameFromFen: function(fen) {
- this.vr = new V(fen);
- this.gameInfo.fenStart = fen;
- this.gameInfo.mycolor = (Math.random() < 0.5 ? "w" : "b");
- this.gameInfo.players = ["Myself","Computer"];
- if (this.gameInfo.mycolor == "b")
- this.gameInfo.players = this.gameInfo.players.reverse();
- this.compWorker.postMessage(["init",fen]);
- if (this.gameInfo.mycolor != "w" || this.mode == "auto")
+ this.compWorker.postMessage(["scripts",this.gameInfo.vname]);
+ this.compWorker.postMessage(["init",this.gameInfo.fen]);
+ this.vr = new V(this.gameInfo.fen);
+ const mycolor = (Math.random() < 0.5 ? "w" : "b");
+ let players = ["Myself","Computer"];
+ if (mycolor == "b")
+ players = players.reverse();
+ // NOTE: (TODO?) fen and fenStart are redundant in game object
+ this.game = Object.assign({},
+ this.gameInfo,
+ {
+ fenStart: this.gameInfo.fen,
+ players: players,
+ mycolor: mycolor,
+ });
+ this.compWorker.postMessage(["init",this.gameInfo.fen]);
+ if (mycolor != "w" || this.gameInfo.mode == "auto")