X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBaseGame.vue;h=d9540eb38b83b8bdf91beffe258e2d422fc0c3a2;hb=57d9b2c4f08948bd5a5fc4a01a0b62d4c80523e2;hp=cd71fcb6158dd47b9b53826935cbd2658e2a1f9a;hpb=54ec15ebc0cc874cb40307d0d674964b2f0e11a4;p=vchess.git diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index cd71fcb6..d9540eb3 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -95,36 +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.showMoves != "all" || !this.vr.canFlip) + !!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() { @@ -377,7 +387,7 @@ export default { }; const playMove = () => { const animate = ( - V.ShowMoves == "all" && + ["all", "highlight"].includes(V.ShowMoves) && (this.autoplay || !!received) ); if (!Array.isArray(move)) move = [move]; @@ -465,6 +475,7 @@ export default { // Sufficient condition because Board already knows which turn it is. if ( this.game.mode != "analyze" && + !navigate && !received && (this.game.score != "*" || this.cursor < this.moves.length - 1) ) {