+ const afterMove = (smove, initurn) => {
+ if (this.vr.turn != initurn) {
+ // Turn has changed: move is complete
+ if (!smove.fen)
+ // NOTE: only FEN of last sub-move is required (=> setting it here)
+ smove.fen = this.vr.getFen();
+ this.emitFenIfAnalyze();
+ this.inMultimove = false;
+ this.incheck = this.vr.getCheckSquares();
+ if (this.incheck.length > 0) smove.notation += "+";
+ this.score = computeScore();
+ if (this.autoplay) {
+ if (this.cursor < this.moves.length - 1)
+ setTimeout(() => this.play(null, null, null, "autoplay"), 1000);
+ else {
+ this.autoplay = false;
+ if (this.stackToPlay.length > 0)
+ // Move(s) arrived in-between
+ this.play(this.stackToPlay.pop(), "received");
+ }
+ }
+ if (this.mode != "analyze" && !navigate) {
+ if (!received) {
+ // Post-processing (e.g. computer play).
+ const L = this.moves.length;
+ // NOTE: always emit the score, even in unfinished
+ this.$emit("newmove", this.moves[L-1], { score: this.score });
+ }
+ else {
+ this.inPlay = false;
+ if (this.stackToPlay.length > 0)
+ // Move(s) arrived in-between
+ this.play(this.stackToPlay.pop(), "received");
+ }
+ }
+ }
+ };
+ // NOTE: navigate and received are mutually exclusive
+ if (navigate) {
+ // The move to navigate to is necessarily full:
+ if (this.cursor == this.moves.length - 1) return; //no more moves
+ move = this.moves[this.cursor + 1];
+ if (!this.autoplay) {
+ // Just play the move:
+ if (!Array.isArray(move)) move = [move];
+ for (let i=0; i < move.length; i++) this.vr.play(move[i]);
+ if (!light) {
+ this.lastMove = move;
+ this.incheck = this.vr.getCheckSquares();
+ this.score = computeScore();
+ this.emitFenIfAnalyze();
+ }
+ this.cursor++;
+ return;
+ }