X-Git-Url: https://git.auder.net/images/pieces/current/gitweb.js?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBaseGame.vue;h=dc15413f7c3eeef167c0c948afe3628a078f1a91;hb=49dc04f91386f8af97994b9f8734a0cde9b3d4b0;hp=a0bcef0a37e9c6c597a20aa795d122f721b66c01;hpb=07052665845283c65b50a76537669d0602ba436b;p=vchess.git diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index a0bcef0a..dc15413f 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -417,8 +417,23 @@ export default { play: function(move, received, light, noemit) { // Freeze while choices are shown: if (this.$refs["board"].choices.length > 0) return; - // The board may show some the possible moves: (TODO: bad solution) - this.$refs["board"].resetCurrentAttempt(); + const navigate = !move; + // Forbid playing outside analyze mode, except if move is received. + // Sufficient condition because Board already knows which turn it is. + if ( + this.mode != "analyze" && + !navigate && + !received && + (this.game.score != "*" || this.cursor < this.moves.length - 1) + ) { + return; + } + if (!!received) { + if (this.mode == "analyze") this.toggleAnalyze(); + if (this.cursor < this.moves.length - 1) + // To play a received move, cursor must be at the end of the game: + this.gotoEnd(); + } if (!!noemit) { if (this.inPlay) { // Received moves in observed games can arrive too fast: @@ -427,7 +442,8 @@ export default { } this.inPlay = true; } - const navigate = !move; + // The board may show some the possible moves: (TODO: bad solution) + this.$refs["board"].resetCurrentAttempt(); const playSubmove = (smove) => { smove.notation = this.vr.getNotation(smove); smove.unambiguous = V.GetUnambiguousNotation(smove); @@ -506,6 +522,9 @@ export default { }; const afterMove = (smove, initurn) => { if (this.vr.turn != initurn) { + +console.log(smove); + // Turn has changed: move is complete if (!smove.fen) // NOTE: only FEN of last sub-move is required (=> setting it here) @@ -514,7 +533,7 @@ export default { this.inMultimove = false; this.score = computeScore(); if (this.mode != "analyze" && !navigate) { - if (!noemit) { + if (!noemit && this.mode != "analyze") { // Post-processing (e.g. computer play). const L = this.moves.length; // NOTE: always emit the score, even in unfinished, @@ -548,22 +567,6 @@ export default { return; } } - // Forbid playing outside analyze mode, except if move is received. - // Sufficient condition because Board already knows which turn it is. - if ( - this.mode != "analyze" && - !navigate && - !received && - (this.game.score != "*" || this.cursor < this.moves.length - 1) - ) { - return; - } - if (!!received) { - if (this.mode == "analyze") this.toggleAnalyze(); - if (this.cursor < this.moves.length - 1) - // To play a received move, cursor must be at the end of the game: - this.gotoEnd(); - } playMove(); }, cancelCurrentMultimove: function() {