- continueGame: function() {
- this.oppid = localStorage.getItem("oppid");
- this.mycolor = localStorage.getItem("mycolor");
- const moves = JSON.parse(localStorage.getItem("moves"));
- const fen = localStorage.getItem("fen");
- const score = localStorage.getItem("score"); //always "*" ?!
- this.fenStart = localStorage.getItem("fenStart");
- this.vr = new VariantRules(fen);
- this.incheck = this.vr.getCheckSquares(this.vr.turn);
- 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}));
+ // user: last person to accept the challenge
+ newGame: function(chall, user) {
+ const fen = chall.fen || VariantRules.GenRandInitFen();
+ const game = {}; //TODO: fen, players, time ...
+ //setStorage(game); //TODO
+ game.players.forEach(p => {
+ this.conn.send(JSON.stringify({code:"newgame", oppid:p.id, game:game});
+ });
+ if (this.settings.sound >= 1)
+ new Audio("/sounds/newgame.mp3").play().catch(err => {});