X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBaseGame.vue;h=228d9c4be4ab17923a40080d974d09470c23a7d9;hb=130cca8b28bbba4fe586f4ddad22808d2aa9a537;hp=2c133fbec9359ca4790e5444e76fa5e4189f14c9;hpb=de6860abfca2fee63d61b6ec7145dfc89d9e50c8;p=vchess.git diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index 2c133fbe..228d9c4b 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -274,6 +274,7 @@ export default { fen = mv[mv.length-1].fen; } this.vr = new V(fen); + this.incheck = this.vr.getCheckSquares(); document.getElementById("analyzeBtn").classList.remove("active"); } }, @@ -417,8 +418,27 @@ 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") { console.log("received move"); + console.log(move); } + + 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 +447,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); @@ -475,6 +496,9 @@ export default { if (animate && smove.start.x >= 0) { self.animateMove(smove, () => { playSubmove(smove); + +console.log(moveIdx + " " + move.length); + if (moveIdx < move.length) setTimeout(executeMove, 500); else afterMove(smove, initurn); @@ -506,6 +530,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) @@ -548,22 +575,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() {