4 display: "undefined", //default to main hall; see "created()" function
5 gameid: "undefined", //...yet
15 // TODO: navigation becomes a little more complex
16 const url
= window
.location
.href
;
17 const hashPos
= url
.indexOf("#");
18 const page
= (hashPos
>= 0 ? url
.substr(hashPos
+1) : "room");
19 this.setDisplay(page
);
21 this.vr
= new VariantRules( V
.GenRandInitFen() );
24 setDisplay: function(elt
) {
26 // Close menu on small screens:
27 let menuToggle
= document
.getElementById("drawer-control");
29 menuToggle
.checked
= false;
32 // TEMPORARY: DEBUG (duplicate code)
33 play: function(move) {
34 // Not programmatic, or animation is over
36 move.notation
= this.vr
.getNotation(move);
39 move.fen
= this.vr
.getFen();
41 new Audio("/sounds/move.mp3").play().catch(err
=> {});
42 // Is opponent in check?
43 this.incheck
= this.vr
.getCheckSquares(this.vr
.turn
);
44 const score
= this.vr
.getCurrentScore();
46 undo: function(move) {
49 new Audio("/sounds/undo.mp3").play().catch(err
=> {});
50 this.incheck
= this.vr
.getCheckSquares(this.vr
.turn
);
55 //const continuation = (localStorage.getItem("variant") === variant.name);
56 // if (continuation) //game VS human has priority
57 // this.continueGame("human");
60 // si quand on arrive il y a une continuation "humaine" : display="game" et retour à la partie !