4 display: "undefined", //default to main hall; see "created()" function
5 gameid: undefined, //...yet
16 fen: V
.GenRandInitFen(),
19 // TODO: navigation becomes a little more complex
23 this.myid
= "abcdefghij";
24 //console.log(this.myid + " " + variant);
26 this.conn
= new WebSocket(socketUrl
+ "/?sid=" + this.myid
+ "&page=" + variant
.id
);
27 const socketCloseListener
= () => {
28 this.conn
= new WebSocket(socketUrl
+ "/?sid=" + this.myid
+ "&page=" + variant
.id
);
30 this.conn
.onclose
= socketCloseListener
;
32 window
.onhashchange
= this.setDisplay
;
33 //this.vr = new VariantRules( V.GenRandInitFen() );
36 setDisplay: function() {
38 //TODO: prevent set display if there is a running game
40 const page
= (location
.hash
|| "#room").substr(1);
42 // Close menu on small screens:
43 let menuToggle
= document
.getElementById("drawer-control");
45 menuToggle
.checked
= false;
48 // TEMPORARY: DEBUG (duplicate code)
49 play: function(move) {
50 // Not programmatic, or animation is over
52 move.notation
= this.vr
.getNotation(move);
55 move.fen
= this.vr
.getFen();
57 new Audio("/sounds/move.mp3").play().catch(err
=> {});
58 // Is opponent in check?
59 this.incheck
= this.vr
.getCheckSquares(this.vr
.turn
);
60 const score
= this.vr
.getCurrentScore();
62 undo: function(move) {
65 new Audio("/sounds/undo.mp3").play().catch(err
=> {});
66 this.incheck
= this.vr
.getCheckSquares(this.vr
.turn
);
71 //const continuation = (localStorage.getItem("variant") === variant.name);
72 // if (continuation) //game VS human has priority
73 // this.continueGame("human");
76 // si quand on arrive il y a une continuation "humaine" : display="game" et retour à la partie !