From: Benjamin Auder Date: Sun, 23 Dec 2018 17:58:37 +0000 (+0100) Subject: Fix computer game continuation when it's computer turn X-Git-Url: https://git.auder.net/js/css/%7B%7B%20path%28%27mixstore_static_about%27%29%20%7D%7D?a=commitdiff_plain;h=748eef1fe9eb666318e2a4c84c1627085666ab07;p=vchess.git Fix computer game continuation when it's computer turn --- diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 462ab9a4..d8fbe47d 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -1356,6 +1356,7 @@ Vue.component('my-game', { const fen = localStorage.getItem(prefix+"fen"); const score = localStorage.getItem(prefix+"score"); //set in "endGame()" this.fenStart = localStorage.getItem(prefix+"fenStart"); + this.vr = new VariantRules(fen, moves); if (mode == "human") { this.gameId = localStorage.getItem("gameId"); @@ -1364,8 +1365,11 @@ Vue.component('my-game', { code:"ping",oppid:this.oppid,gameId:this.gameId})); } else + { this.compWorker.postMessage(["init",fen]); - this.vr = new VariantRules(fen, moves); + if (this.mycolor != this.vr.turn) + this.playComputerMove(); + } if (moves.length > 0) { const lastMove = moves[moves.length-1];