From: Benjamin Auder Date: Thu, 11 Apr 2019 14:15:30 +0000 (+0200) Subject: Fix end of game + navigation after computer game ends X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/images/scripts/doc/current/%7B%7B%20targetUrl%20%7D%7D?a=commitdiff_plain;h=4494c17cdf17159badd2313549d01f2e562b991f;p=vchess.git Fix end of game + navigation after computer game ends --- diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index 28752181..aa19b477 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -62,6 +62,13 @@ export default { this.cursor = -1; this.lastMove = null; }, + analyze: function() { + if (this.analyze) + { + // Switched to analyze mode: game is over + this.endGame("*"); + } + }, }, computed: { showMoves: function() { @@ -127,7 +134,7 @@ export default { }, showScoreMsg: function(score) { this.setEndgameMessage(score); - let modalBox = document.getElementById("modal-eog"); + let modalBox = document.getElementById("modalEog"); modalBox.checked = true; setTimeout(() => { modalBox.checked = false; }, 2000); }, @@ -215,7 +222,8 @@ export default { else //just show score on screen (allow undo) this.showScoreMsg(score); } - this.$emit("newmove", move); //post-processing (e.g. computer play) + if (!this.analyze) + this.$emit("newmove", move); //post-processing (e.g. computer play) }, undo: function(move) { let navigate = !move; @@ -231,7 +239,7 @@ export default { if (this.st.settings.sound == 2) new Audio("/sounds/undo.mp3").play().catch(err => {}); this.incheck = this.vr.getCheckSquares(this.vr.turn); - if (this.analyze) //TODO: can this happen? + if (!navigate) this.moves.pop(); }, gotoMove: function(index) {