X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fgame.js;h=297ccc9dc55b011830412e0941a4a0cc3bd9c94a;hp=8009edd70f0b429fd6451f2b3adfef32924cccb8;hb=8d7e2786f5a67a1b9a77c742d7951e0efbe8747d;hpb=7192f4711467ae73a0f813189f8a4d8cca252bf1 diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 8009edd7..297ccc9d 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -82,7 +82,7 @@ Vue.component('my-game', { }, created: function() { const url = socketUrl; - this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant); + this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id); // const socketOpenListener = () => { // }; @@ -95,7 +95,7 @@ Vue.component('my-game', { switch (data.code) { case "newmove": //..he played! - this.play(data.move, (variant!="Dark" ? "animate" : null)); + this.play(data.move, (variant.name!="Dark" ? "animate" : null)); break; case "pong": //received if we sent a ping (game still alive on our side) if (this.gameId != data.gameId) @@ -161,7 +161,7 @@ Vue.component('my-game', { }; const socketCloseListener = () => { - this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant); + this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id); //this.conn.addEventListener('open', socketOpenListener); this.conn.addEventListener('message', socketMessageListener); this.conn.addEventListener('close', socketCloseListener); @@ -187,7 +187,7 @@ Vue.component('my-game', { // Computer moves web worker logic: (TODO: also for observers in HH games) - this.compWorker.postMessage(["scripts",variant]); + this.compWorker.postMessage(["scripts",variant.name]); const self = this; this.compWorker.onmessage = function(e) { let compMove = e.data; @@ -201,7 +201,7 @@ 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); + const animate = (variant.name!="Dark" ? "animate" : null); if (self.mode == "computer") //warning: mode could have changed! self.play(compMove[0], animate); if (compMove.length == 2)