- // Caution: last move in moves array might be a multi-move
- if (index >= 0) {
- if (Array.isArray(this.moves[index])) {
- const L = this.moves[index].length;
- this.lastMove = this.moves[index][L - 1];
- } else {
- this.lastMove = this.moves[index];
+ // Note: last move in moves array might be a multi-move
+ if (index >= 0) this.lastMove = this.moves[index];
+ else this.lastMove = null;
+ },
+ toggleAnalyze: function() {
+ // Freeze while choices are shown (and autoplay has priority)
+ if (this.$refs["board"].choices.length > 0 || this.autoplay) return;
+ if (this.mode != "analyze") {
+ // Enter analyze mode:
+ if (this.inMultimove) this.cancelCurrentMultimove();
+ this.gameMode = this.mode; //was not 'analyze'
+ this.mode = "analyze";
+ this.gameCursor = this.cursor;
+ this.gameMoves = JSON.parse(JSON.stringify(this.moves));
+ document.getElementById("analyzeBtn").classList.add("active");
+ }
+ else {
+ // Exit analyze mode:
+ this.mode = this.gameMode ;
+ this.cursor = this.gameCursor;
+ this.moves = this.gameMoves;
+ let fen = this.game.fenStart;
+ if (this.cursor >= 0) {
+ let mv = this.moves[this.cursor];
+ if (!Array.isArray(mv)) mv = [mv];
+ fen = mv[mv.length-1].fen;