- // TODO: check FEN integrity with opponent
- this.newGame("human", localStorage.getItem("fen"),
- localStorage.getItem("mycolor"), localStorage.getItem("oppid"), true);
- // Send ping to server, which answers pong if opponent is connected
- this.conn.send(JSON.stringify({code:"ping", oppid:this.oppId}));
+ const fen = localStorage.getItem("fen");
+ const mycolor = localStorage.getItem("mycolor");
+ const oppid = localStorage.getItem("oppid");
+ const moves = JSON.parse(localStorage.getItem("moves"));
+ this.newGame("human", fen, mycolor, oppid, moves, true);
+ // Send ping to server (answer pong if opponent is connected)
+ this.conn.send(JSON.stringify({code:"ping",oppid:this.oppId}));
+ }
+ else if (localStorage.getItem("newgame") === variant)
+ {
+ // New game request has been cancelled on disconnect
+ this.seek = true;
+ this.newGame("human", undefined, undefined, undefined, undefined, "reconnect");