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.conn
= new WebSocket(url
+ "/?sid=" + this.myid
+ "&page=" + variant
._id
);
22 const socketCloseListener
= () => {
23 this.conn
= new WebSocket(url
+ "/?sid=" + this.myid
+ "&page=" + variant
._id
);
25 this.conn
.onclose
= socketCloseListener
;
27 this.vr
= new VariantRules( V
.GenRandInitFen() );
30 setDisplay: function(elt
) {
32 // Close menu on small screens:
33 let menuToggle
= document
.getElementById("drawer-control");
35 menuToggle
.checked
= false;
38 // TEMPORARY: DEBUG (duplicate code)
39 play: function(move) {
40 // Not programmatic, or animation is over
42 move.notation
= this.vr
.getNotation(move);
45 move.fen
= this.vr
.getFen();
47 new Audio("/sounds/move.mp3").play().catch(err
=> {});
48 // Is opponent in check?
49 this.incheck
= this.vr
.getCheckSquares(this.vr
.turn
);
50 const score
= this.vr
.getCurrentScore();
52 undo: function(move) {
55 new Audio("/sounds/undo.mp3").play().catch(err
=> {});
56 this.incheck
= this.vr
.getCheckSquares(this.vr
.turn
);
61 //const continuation = (localStorage.getItem("variant") === variant.name);
62 // if (continuation) //game VS human has priority
63 // this.continueGame("human");
66 // si quand on arrive il y a une continuation "humaine" : display="game" et retour à la partie !