X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FComputerGame.vue;h=8c0ac3825cac644106e77ba0a9e0a0173310194c;hb=37cdcbf303d3c2e57b388a1abc9f853ba68a55cd;hp=b3db07f902d73836d75d34654fdad8a5319224ca;hpb=1acda11cd124a446c8bb451feae380efcc8a1cbc;p=vchess.git diff --git a/client/src/components/ComputerGame.vue b/client/src/components/ComputerGame.vue index b3db07f9..8c0ac382 100644 --- a/client/src/components/ComputerGame.vue +++ b/client/src/components/ComputerGame.vue @@ -75,27 +75,20 @@ export default { const vModule = await import("@/variants/" + this.vname + ".js"); window.V = vModule.VariantRules; this.compWorker.postMessage(["scripts",this.vname]); + this.compWorker.postMessage(["init",this.fen]); this.newGameFromFen(this.fen); }, newGameFromFen: function(fen) { this.vr = new V(fen); - this.moves = []; - this.cursor = -1; this.fenStart = fen; - this.score = "*"; - if (this.mode == "analyze") - { - this.mycolor = V.ParseFen(fen).turn; - this.orientation = this.mycolor; - } - else if (this.mode == "computer") //only other alternative (HH with gameId) - { - this.mycolor = (Math.random() < 0.5 ? "w" : "b"); - this.orientation = this.mycolor; - this.compWorker.postMessage(["init",fen]); - if (this.mycolor != "w" || this.subMode == "auto") - this.playComputerMove(); - } + this.mycolor = (Math.random() < 0.5 ? "w" : "b"); + console.log(this.mycolor); + this.players = ["Myself","Computer"]; + if (this.mycolor == "b") + this.players = this.players.reverse(); + this.compWorker.postMessage(["init",fen]); + if (this.mycolor != "w" || this.mode == "auto") + this.playComputerMove(); }, playComputerMove: function() { this.timeStart = Date.now();