X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBaseGame.vue;h=5ee5e0c72ae9d9d1bb2ff2072f61d5f26ab0d9da;hb=b4fb161253c5e7b4581ca37d22339111dd4aa861;hp=d0b584b101e9ecd8c9d0515dff606fbb7a2db50b;hpb=834c202a003ca6285106133336701b340939ba12;p=vchess.git diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index d0b584b1..5ee5e0c7 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -55,14 +55,7 @@ export default { watch: { // game initial FEN changes when a new game starts "game.fenStart": function() { - // Reset all variables - this.endgameMessage = ""; - this.orientation = this.game.mycolor || "w"; //default orientation for observed games - this.score = this.game.score || "*"; //mutable (if initially "*") - this.moves = JSON.parse(JSON.stringify(this.game.moves || [])); - const L = this.moves.length; - this.cursor = L-1; - this.lastMove = (L > 0 ? this.moves[L-1] : null); + this.re_setVariables(); }, }, computed: { @@ -77,7 +70,20 @@ export default { return this.game.mode == "analyze"; }, }, + created: function() { + if (!!this.game.fenStart) + this.re_setVariables(); + }, methods: { + re_setVariables: function() { + this.endgameMessage = ""; + this.orientation = this.game.mycolor || "w"; //default orientation for observed games + this.score = this.game.score || "*"; //mutable (if initially "*") + this.moves = JSON.parse(JSON.stringify(this.game.moves || [])); + const L = this.moves.length; + this.cursor = L-1; + this.lastMove = (L > 0 ? this.moves[L-1] : null); + }, setEndgameMessage: function(score) { let eogMessage = "Undefined"; switch (score) @@ -139,7 +145,7 @@ export default { endGame: function(score) { this.score = score; this.showScoreMsg(score); - this.$emit("gameover"); //score not required (TODO?) + this.$emit("gameover", score); }, animateMove: function(move) { let startSquare = document.getElementById(getSquareId(move.start));