+ 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