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
21 window
.onhashchange
= this.setDisplay
;
23 this.myid
= "abcdefghij";
24 //console.log(this.myid + " " + variant);
25 //myid: localStorage.getItem("myid"), //our ID, always set
27 this.conn
= new WebSocket(socketUrl
+ "/?sid=" + this.myid
+ "&page=" + variant
.id
);
28 const socketCloseListener
= () => {
29 this.conn
= new WebSocket(socketUrl
+ "/?sid=" + this.myid
+ "&page=" + variant
.id
);
31 this.conn
.onclose
= socketCloseListener
;
33 //this.vr = new VariantRules( V.GenRandInitFen() );
36 setDisplay: function() {
38 //TODO: prevent set display if there is a running game
41 location
.hash
= "#room"; //default
42 this.display
= location
.hash
.substr(1);
43 // Close menu on small screens:
44 let menuToggle
= document
.getElementById("drawer-control");
46 menuToggle
.checked
= false;
49 // TEMPORARY: DEBUG (duplicate code)
50 play: function(move) {
51 // Not programmatic, or animation is over
53 move.notation
= this.vr
.getNotation(move);
56 move.fen
= this.vr
.getFen();
58 new Audio("/sounds/move.mp3").play().catch(err
=> {});
59 // Is opponent in check?
60 this.incheck
= this.vr
.getCheckSquares(this.vr
.turn
);
61 const score
= this.vr
.getCurrentScore();
63 undo: function(move) {
66 new Audio("/sounds/undo.mp3").play().catch(err
=> {});
67 this.incheck
= this.vr
.getCheckSquares(this.vr
.turn
);
72 //const continuation = (localStorage.getItem("variant") === variant.name);
73 // if (continuation) //game VS human has priority
74 // this.continueGame("human");
77 // si quand on arrive il y a une continuation "humaine" : display="game" et retour à la partie !