X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fgame.js;h=3f3b55561456d29652bfd0bff21505e8d7a80ffe;hb=3fa426b632d92a65843038a161677069de5db27e;hp=6627252fd6d3c8e54fd068b879c92a0aef403a2d;hpb=5915f72002ae63b04620cebe47adf778174b1bee;p=vchess.git diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 6627252f..3f3b5556 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -443,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}) } }, [ @@ -467,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}) } }, [ @@ -1287,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) { @@ -1306,7 +1312,7 @@ Vue.component('my-game', { this.endGame(this.mycolor=="w"?"0-1":"1-0"); }, newGame: function(mode, fenInit, color, oppId) { - const fen = fenInit || VariantRules.GenRandInitFen(); + const fen = "nrqkbrnb/pppppppp/8/8/8/8/PPPPPPPP/RKQBNRBN w 1111 -";//fenInit || VariantRules.GenRandInitFen(); console.log(fen); //DEBUG if (mode=="human" && !oppId) { @@ -1344,8 +1350,6 @@ Vue.component('my-game', { return; } } - else if (score == "*") - return this.continueGame("computer"); } } else if (mode == "friend") @@ -1387,7 +1391,7 @@ Vue.component('my-game', { else if (mode == "computer") { this.compWorker.postMessage(["init",this.vr.getFen()]); - this.mycolor = (Math.random() < 0.5 ? 'w' : 'b'); + this.mycolor = "w";//(Math.random() < 0.5 ? 'w' : 'b'); if (this.mycolor != this.vr.turn) this.playComputerMove(); } @@ -1416,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 @@ -1618,7 +1622,10 @@ Vue.component('my-game', { if (["human","computer","friend"].includes(this.mode)) this.updateStorage(); //after our moves and opponent moves if (this.mode == "computer" && this.vr.turn != this.mycolor && this.score == "*") + { + console.log(this.vr.moves.length + " " + this.vr.turn + " " + this.mycolor); this.playComputerMove(); + } }, undo: function() { // Navigate after game is over