From: Benjamin Auder Date: Tue, 3 Dec 2019 19:42:19 +0000 (+0100) Subject: A few fixes X-Git-Url: https://git.auder.net/js/img/current/pieces/cn.svg?a=commitdiff_plain;h=d18bfa126e918ecc13f2a70612b1cfda25e1e25a;p=vchess.git A few fixes --- diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index 9f4b6df8..8e9ac36a 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -223,6 +223,8 @@ export default { this.lastMove = move; if (this.st.settings.sound == 2) new Audio("/sounds/move.mp3").play().catch(err => {}); + if (!this.analyze) + this.$emit("newmove", move); //post-processing (e.g. computer play) if (!navigate) { move.fen = this.vr.getFen(); @@ -235,10 +237,10 @@ export default { this.moves = this.moves.slice(0,this.cursor).concat([move]); } } - // Is opponent in check? (TODO: generalize, find all check squares) + // Is opponent in check? this.incheck = this.vr.getCheckSquares(this.vr.turn); const score = this.vr.getCurrentScore(); - if (score != "*") //TODO: generalize score for 3 or 4 players + if (score != "*") { if (!this.analyze) this.endGame(score); @@ -249,8 +251,6 @@ export default { this.showEndgameMsg(score + " . " + message); } } - if (!this.analyze) - this.$emit("newmove", move); //post-processing (e.g. computer play) }, undo: function(move) { const navigate = !move; diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 923e9400..bd9125f2 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -97,7 +97,7 @@ export default { }); const myTurn = (currentTurn == this.game.mycolor); let clockUpdate = setInterval(() => { - if (countdown <= 0 || this.vr.turn != currentTurn) + if (countdown <= 0 || this.vr.turn != currentTurn || this.game.score != "*") { clearInterval(clockUpdate); if (countdown <= 0 && myTurn) @@ -334,7 +334,7 @@ export default { game.initime[0] = Date.now(); if (myIdx >= 0) //I play in this game { - GameStorage.update(game.gameId, + GameStorage.update(game.id, { clocks: game.clocks, initime: game.initime, @@ -344,6 +344,14 @@ export default { const vModule = await import("@/variants/" + vname + ".js"); window.V = vModule.VariantRules; this.vr = new V(game.fen); + + + +//TODO: people, on connect, search for opponent....... +console.log(myIdx + " " + game.players[1-myIdx].sid); //otherwise this is undefined: + + + this.game = Object.assign({}, game, // NOTE: assign mycolor here, since BaseGame could also bs VS computer @@ -433,6 +441,7 @@ export default { // TODO: this update function should also work for corr games gameOver: function(score) { this.game.mode = "analyze"; + this.game.score = score; GameStorage.update(this.gameRef.id, { score: score }); }, }, diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 433151c7..547395db 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -381,8 +381,8 @@ export default { else { this.infoMessage = "New game started: " + - "" + - "/game/" + data.gameInfo.gameId + ""; + "" + + "#/game/" + data.gameInfo.gameId + ""; let modalBox = document.getElementById("modalInfo"); modalBox.checked = true; setTimeout(() => { modalBox.checked = false; }, 3000);