+ continueGame: function(mode) {
+ this.mode = mode;
+ this.oppid = (mode=="human" ? localStorage.getItem("oppid") : undefined);
+ const prefix = (mode=="computer" ? "comp-" : "");
+ this.mycolor = localStorage.getItem(prefix+"mycolor");
+ const moves = JSON.parse(localStorage.getItem(prefix+"moves"));
+ const fen = localStorage.getItem(prefix+"fen");
+ const score = localStorage.getItem(prefix+"score"); //set in "endGame()"
+ this.fenStart = localStorage.getItem(prefix+"fenStart");
+ if (mode == "human")
+ {
+ this.gameId = localStorage.getItem("gameId");
+ // Send ping to server (answer pong if opponent is connected)
+ this.conn.send(JSON.stringify({
+ code:"ping",oppid:this.oppid,gameId:this.gameId}));
+ }
+ else
+ this.compWorker.postMessage(["init",fen]);
+ this.vr = new VariantRules(fen, moves);
+ if (moves.length > 0)
+ {
+ const lastMove = moves[moves.length-1];
+ this.vr.undo(lastMove);
+ this.incheck = this.vr.getCheckSquares(lastMove);
+ this.vr.play(lastMove, "ingame");
+ }
+ if (score != "*")
+ {
+ // Small delay required when continuation run faster than drawing page
+ setTimeout(() => this.endGame(score), 100);
+ }
+ },