X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fgame.js;h=4c369e4c5d990695416da38a451b2f25c08164d0;hb=5188295933c6628a7f52473b8f61c93a0aaac179;hp=94340e6605ce77c363d16cd0c7323c661d4494cc;hpb=dbcc32e95d526fe518ac866f7b3cdac546f1178e;p=vchess.git diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 94340e66..4c369e4c 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -62,9 +62,8 @@ Vue.component('my-game', { }, [h('i', { 'class': { "material-icons": true } }, "accessibility")]) ); - if (variant != "Dark" && - (["idle","computer","friend"].includes(this.mode) - || ["friend","human"].includes(this.mode) && this.score != "*")) + if (["idle","computer","friend"].includes(this.mode) + || (this.mode == "human" && this.score != "*")) { actionArray.push( h('button', @@ -81,9 +80,8 @@ Vue.component('my-game', { [h('i', { 'class': { "material-icons": true } }, "computer")]) ); } - if (variant != "Dark" && - (["idle","friend"].includes(this.mode) - || ["computer","human"].includes(this.mode) && this.score != "*")) + if (variant != "Dark" && (["idle","friend"].includes(this.mode) + || (["computer","human"].includes(this.mode) && this.score != "*"))) { actionArray.push( h('button', @@ -445,7 +443,7 @@ Vue.component('my-game', { { myReservePiecesArray.push(h('div', { - 'class': {'board':true, ['board'+sizeY+'-reserve']:true}, + 'class': {'board':true, ['board'+sizeY]:true}, attrs: { id: this.getSquareId({x:sizeX+shiftIdx,y:i}) } }, [ @@ -469,7 +467,7 @@ Vue.component('my-game', { { oppReservePiecesArray.push(h('div', { - 'class': {'board':true, ['board'+sizeY+'-reserve']:true}, + 'class': {'board':true, ['board'+sizeY]:true}, attrs: { id: this.getSquareId({x:sizeX+(1-shiftIdx),y:i}) } }, [ @@ -1130,12 +1128,13 @@ Vue.component('my-game', { // before they appear on page: const delay = Math.max(500-(Date.now()-self.timeStart), 0); setTimeout(() => { + const animate = (variant!="Dark" ? "animate" : null); if (self.mode == "computer") //warning: mode could have changed! - self.play(compMove[0], "animate"); + self.play(compMove[0], animate); if (compMove.length == 2) setTimeout( () => { if (self.mode == "computer") - self.play(compMove[1], "animate"); + self.play(compMove[1], animate); }, 750); }, delay); } @@ -1288,6 +1287,12 @@ Vue.component('my-game', { }, clickComputerGame: function(e) { this.getRidOfTooltip(e.currentTarget); + if (this.mode == "computer" && this.score == "*" + && this.vr.turn != this.mycolor) + { + // Wait for computer reply first (avoid potential "ghost move" bug) + return; + } this.newGame("computer"); }, clickFriendGame: function(e) { @@ -1345,8 +1350,6 @@ Vue.component('my-game', { return; } } - else if (score == "*") - return this.continueGame("computer"); } } else if (mode == "friend") @@ -1417,7 +1420,7 @@ Vue.component('my-game', { else if (mode == "computer") { this.compWorker.postMessage(["init",fen]); - if (this.mycolor != this.vr.turn) + if (score == "*" && this.mycolor != this.vr.turn) this.playComputerMove(); } //else: nothing special to do in friend mode