From 748eef1fe9eb666318e2a4c84c1627085666ab07 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sun, 23 Dec 2018 18:58:37 +0100
Subject: [PATCH] Fix computer game continuation when it's computer turn

---
 public/javascripts/components/game.js | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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];
-- 
2.44.0