hints: (getCookie("hints") === "1" ? true : false),
color: getCookie("color", "lichess"), //lichess, chesscom or chesstempo
// sound level: 0 = no sound, 1 = sound only on newgame, 2 = always
- sound: getCookie("sound", "2"),
+ sound: parseInt(getCookie("sound", "2")),
};
},
render(h) {
const [sizeX,sizeY] = VariantRules.size;
- const smallScreen = (screen.width <= 420);
+ const smallScreen = (window.innerWidth <= 420);
// Precompute hints squares to facilitate rendering
let hintSquares = doubleArray(sizeX, sizeY, false);
this.possibleMoves.forEach(m => { hintSquares[m.end.x][m.end.y] = true; });
"value": "0",
innerHTML: "None"
},
+ attrs: { "selected": this.sound==0 },
}
),
h("option",
"value": "1",
innerHTML: "Newgame"
},
+ attrs: { "selected": this.sound==1 },
}
),
h("option",
"value": "2",
innerHTML: "All"
},
+ attrs: { "selected": this.sound==2 },
}
),
],
created: function() {
const url = socketUrl;
const continuation = (localStorage.getItem("variant") === variant);
- this.myid = continuation ? localStorage.getItem("myid") : getRandString();
+ this.myid = (continuation ? localStorage.getItem("myid") : getRandString());
if (!continuation)
{
// HACK: play a small silent sound to allow "new game" sound later
const data = JSON.parse(msg.data);
switch (data.code)
{
+ case "duplicate":
+ // We opened another tab on the same game
+ this.mode = "idle";
+ this.vr = null;
+ alert("Already playing a game in this variant on another tab!");
+ break;
case "newgame": //opponent found
// oppid: opponent socket ID
this.newGame("human", data.fen, data.color, data.oppid);
this.endGame(this.mycolor=="w"?"0-1":"1-0");
},
newGame: function(mode, fenInit, color, oppId, moves, continuation) {
- const fen = fenInit || VariantRules.GenRandInitFen();
+ const fen = "3N1K2/2n2q2/P1R1kPnN/p3b1p1/b7/5Q2/4r3/8 0000";//fenInit || VariantRules.GenRandInitFen();
console.log(fen); //DEBUG
if (mode=="human" && !oppId)
{
document.getElementById("modal-newgame").checked = false;
}
this.oppid = oppId;
- this.oppConnected = true;
+ this.oppConnected = !continuation;
this.mycolor = color;
this.seek = false;
if (!!moves && moves.length > 0) //imply continuation
}
else if (mode == "computer")
{
- this.mycolor = Math.random() < 0.5 ? 'w' : 'b';
+ this.mycolor = "w";//Math.random() < 0.5 ? 'w' : 'b';
if (this.mycolor == 'b')
setTimeout(this.playComputerMove, 500);
}