X-Git-Url: https://git.auder.net/pieces/Checkered/cq.svg?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBaseGame.vue;h=100f7efb49b6cb997c528ed0c2cf1e9265599275;hb=cc00b83cd8e91a3defa99acc95ee8bc7e6c8a819;hp=3820dc1b5e9750628b62f371bf3b86c5a1bb4ce2;hpb=5b3dc10e34bf5bf970494be6ee1fa0b67e2ca88c;p=vchess.git diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index 3820dc1b..100f7efb 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -296,6 +296,15 @@ export default { callback(); }, 250); }, + // For Analyse mode: + emitFenIfAnalyze: function() { + if (this.game.mode == "analyze") { + this.$emit( + "fenchange", + this.lastMove ? this.lastMove.fen : this.game.fenStart + ); + } + }, // "light": if gotoMove() or gotoEnd() // data: some custom data (addTime) to be re-emitted play: function(move, received, light, data) { @@ -309,7 +318,7 @@ export default { if (!navigate) { if (!this.inMultimove) { if (this.cursor < this.moves.length - 1) - this.moves = this.moves.slice(0, Math.max(this.cursor, 0)); + this.moves = this.moves.slice(0, this.cursor + 1); this.moves.push(smove); this.inMultimove = true; //potentially this.cursor++; @@ -350,6 +359,9 @@ export default { new Audio("/sounds/move.mp3").play().catch(() => {}); if (this.vr.turn != initurn) { // Turn has changed: move is complete + if (!smove.fen) + // NOTE: only FEN of last sub-move is required (thus setting it here) + smove.fen = this.vr.getFen(); this.inMultimove = false; const score = this.vr.getCurrentScore(); if (score != "*") { @@ -376,7 +388,10 @@ export default { if (!Array.isArray(move)) move = [move]; for (let i=0; i < move.length; i++) this.vr.play(move[i]); } - else playMove(); + else { + playMove(); + this.emitFenIfAnalyze(); + } this.cursor++; return; } @@ -393,6 +408,7 @@ export default { if (received && this.cursor < this.moves.length - 1) this.gotoEnd(); playMove(); + this.emitFenIfAnalyze(); }, cancelCurrentMultimove: function() { // Cancel current multi-move @@ -427,6 +443,7 @@ export default { if (this.st.settings.sound == 2) new Audio("/sounds/undo.mp3").play().catch(() => {}); this.incheck = this.vr.getCheckSquares(this.vr.turn); + this.emitFenIfAnalyze(); } } }, @@ -445,6 +462,7 @@ export default { // NOTE: next line also re-assign cursor, but it's very light this.positionCursorTo(index); this.incheck = this.vr.getCheckSquares(this.vr.turn); + this.emitFenIfAnalyze(); }, gotoBegin: function() { if (this.inMultimove) this.cancelCurrentMultimove(); @@ -457,10 +475,12 @@ export default { this.lastMove = null; } this.incheck = []; + this.emitFenIfAnalyze(); }, gotoEnd: function() { if (this.cursor == this.moves.length - 1) return; this.gotoMove(this.moves.length - 1); + this.emitFenIfAnalyze(); }, flip: function() { this.orientation = V.GetOppCol(this.orientation);