X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fgame.js;h=30ed7e0b910606fa64755b7ff64b7e5ef13e2fab;hb=0706ea91c99bc75c526fc9ac1ab62fe7999c7069;hp=7af9c8e32976295cfc442fa863b7c89381ee81e8;hpb=ecf44502c1ed7c408b8ea4d1be5234203aa3d314;p=vchess.git diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 7af9c8e3..30ed7e0b 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -40,6 +40,7 @@ Vue.component('my-game', { attrs: { "aria-label": 'New game VS human' }, 'class': { "tooltip": true, + "bottom": true, //display below "seek": this.seek, "playing": playingHuman, }, @@ -51,6 +52,7 @@ Vue.component('my-game', { attrs: { "aria-label": 'New game VS computer' }, 'class': { "tooltip":true, + "bottom": true, "playing": playingComp, }, }, @@ -180,7 +182,10 @@ Vue.component('my-game', { { on: { click: this.resign }, attrs: { "aria-label": 'Resign' }, - 'class': { "tooltip":true }, + 'class': { + "tooltip":true, + "bottom": true, + }, }, [h('i', { 'class': { "material-icons": true } }, "flag")]) ); @@ -203,32 +208,6 @@ Vue.component('my-game', { // elementArray.push(reserve); // } const eogMessage = this.getEndgameMessage(this.score); - let elemsOfEog = - [ - h('label', - { - attrs: { "for": "modal-eog" }, - "class": { "modal-close": true }, - } - ), - h('h3', - { - "class": { "section": true }, - domProps: { innerHTML: eogMessage }, - } - ) - ]; - if (this.score != "*") - { - elemsOfEog.push( - h('p', //'textarea', //TODO: selectable! - { - domProps: { innerHTML: this.vr.getPGN(this.mycolor, this.score, this.fenStart) }, - //attrs: { "readonly": true }, - } - ) - ); - } const modalEog = [ h('input', { @@ -244,7 +223,20 @@ Vue.component('my-game', { { "class": { "card": true, "smallpad": true }, }, - elemsOfEog + [ + h('label', + { + attrs: { "for": "modal-eog" }, + "class": { "modal-close": true }, + } + ), + h('h3', + { + "class": { "section": true }, + domProps: { innerHTML: eogMessage }, + } + ) + ] ) ] ) @@ -299,6 +291,23 @@ Vue.component('my-game', { actionArray ); elementArray.push(actions); + if (this.score != "*") + { + elementArray.push( + h('div', + { }, + [ + h('p', + { + domProps: { + innerHTML: this.vr.getPGN(this.mycolor, this.score, this.fenStart, this.mode) + } + } + ) + ] + ) + ); + } return h( 'div', { @@ -426,7 +435,7 @@ Vue.component('my-game', { this.score = score; let modalBox = document.getElementById("modal-eog"); modalBox.checked = true; - //setTimeout(() => { modalBox.checked = false; }, 2000); //disabled, to show PGN + setTimeout(() => { modalBox.checked = false; }, 2000); if (this.mode == "human") this.clearStorage(); this.mode = "idle"; @@ -485,13 +494,12 @@ Vue.component('my-game', { if (this.mode == "human") return; //no newgame while playing if (this.seek) + { delete localStorage["newgame"]; //cancel game seek + this.seek = false; + } else - { - localStorage["newgame"] = variant; this.newGame("human"); - } - this.seek = !this.seek; }, clickComputerGame: function() { if (this.mode == "human") @@ -507,11 +515,12 @@ Vue.component('my-game', { const storageVariant = localStorage.getItem("variant"); if (!!storageVariant && storageVariant !== variant) { - // TODO: find a better way to ensure this. Newgame system is currently a mess. alert("Finish your " + storageVariant + " game first!"); return; } // Send game request and wait.. + localStorage["newgame"] = variant; + this.seek = true; this.clearStorage(); //in case of try { this.conn.send(JSON.stringify({code:"newgame", fen:fen})); @@ -538,7 +547,7 @@ Vue.component('my-game', { if (!continuation) { // Not playing sound on game continuation: - new Audio("/sounds/newgame.mp3").play().catch(err => {}); + new Audio("/sounds/newgame.mp3").play().then(() => {}).catch(err => {}); document.getElementById("modal-newgame").checked = false; } this.oppid = oppId; @@ -549,7 +558,7 @@ Vue.component('my-game', { { const oppCol = this.vr.turn; const lastMove = moves[moves.length-1]; - this.vr.undo(lastMove, "ingame"); + this.vr.undo(lastMove); this.incheck = this.vr.getCheckSquares(lastMove, oppCol); this.vr.play(lastMove, "ingame"); } @@ -685,7 +694,7 @@ Vue.component('my-game', { // Not programmatic, or animation is over if (this.mode == "human" && this.vr.turn == this.mycolor) this.conn.send(JSON.stringify({code:"newmove", move:move, oppid:this.oppid})); - new Audio("/sounds/chessmove1.mp3").play().catch(err => {}); + new Audio("/sounds/chessmove1.mp3").play().then(() => {}).catch(err => {}); this.vr.play(move, "ingame"); if (this.mode == "human") this.updateStorage(); //after our moves and opponent moves