X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBaseGame.vue;h=4a451f4f41c9e2fea2d0f771c9b16ddf7f611cca;hp=2517c78ab9832ed7685c4d6181bc8f8c15d25bf9;hb=6b9378a6b88b81f71ce5ad5d332ab6accfe1994b;hpb=23dbe4b8d02dbaacc54c9b1057be91b290dfb8e7 diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index 2517c78a..4a451f4f 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -95,34 +95,46 @@ export default { }; }, computed: { + turn: function() { + if (!this.vr) return ""; + if (this.vr.showMoves != "all") { + return this.st.tr[ + (this.vr.turn == 'w' ? "White" : "Black") + " to move"]; + } + // Cannot flip: racing king or circular chess + return ( + this.vr.movesCount == 0 && this.game.mycolor == "w" + ? this.st.tr["It's your turn!"] + : "" + ); + }, + // TODO: is it OK to pass "computed" as propoerties? + // Also, some are seemingly not recomputed when vr is initialized. showMoves: function() { return this.game.score != "*" ? "all" - : (this.vr ? this.vr.showMoves : "none"); + : (!!this.vr ? this.vr.showMoves : "none"); }, showTurn: function() { return ( this.game.score == '*' && - !!this.vr && this.vr.showTurn + !!this.vr && (this.vr.showMoves != "all" || !this.vr.canFlip) ); }, - turn: function() { - if (!this.vr) return ""; - if (this.vr.showMoves != "all") - return this.st.tr[(this.vr.turn == 'w' ? "White" : "Black") + " to move"]; - // Cannot flip: racing king or circular chess - return this.vr.movesCount == 0 && this.game.mycolor == "w" - ? this.st.tr["It's your turn!"] - : ""; - }, canAnalyze: function() { - return this.game.mode != "analyze" && this.vr && this.vr.canAnalyze; + return ( + this.game.mode != "analyze" && + !!this.vr && this.vr.canAnalyze + ); }, canFlip: function() { - return this.vr && this.vr.canFlip; + return !!this.vr && this.vr.canFlip; }, allowDownloadPGN: function() { - return this.game.score != "*" || (this.vr && this.vr.showMoves == "all"); + return ( + this.game.score != "*" || + (!!this.vr && this.vr.showMoves == "all") + ); } }, created: function() {