+ // 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);
+ this.vr.play(smove);
+ if (this.inMultimove && !!this.lastMove) {
+ if (!Array.isArray(this.lastMove))
+ this.lastMove = [this.lastMove, smove];
+ else this.lastMove.push(smove);
+ }
+ // Is opponent (or me) in check?
+ this.incheck = this.vr.getCheckSquares();
+ if (this.incheck.length > 0) smove.notation += "+";
+ if (!this.inMultimove) {
+ // First sub-move:
+ this.lastMove = smove;
+ // Condition is "!navigate" but we mean "!this.autoplay"
+ if (!navigate) {
+ if (this.cursor < this.moves.length - 1)
+ this.moves = this.moves.slice(0, this.cursor + 1);
+ this.moves.push(smove);
+ }
+ this.inMultimove = true; //potentially
+ this.cursor++;
+ } else if (!navigate) {
+ // Already in the middle of a multi-move
+ const L = this.moves.length;
+ if (!Array.isArray(this.moves[L-1]))
+ this.$set(this.moves, L-1, [this.moves[L-1], smove]);
+ else this.moves[L-1].push(smove);
+ }
+ };
+ const playMove = () => {
+ const animate = (
+ ["all", "highlight"].includes(V.ShowMoves) &&
+ (this.autoplay || !!received)
+ );
+ if (!Array.isArray(move)) move = [move];
+ let moveIdx = 0;
+ let self = this;
+ const initurn = this.vr.turn;
+ (function executeMove() {
+ const smove = move[moveIdx++];
+ // NOTE: condition "smove.start.x >= 0" required for Dynamo,
+ // because second move may be empty.
+ 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);
+ });
+ } else {
+ playSubmove(smove);
+ if (moveIdx < move.length) executeMove();
+ else afterMove(smove, initurn);
+ }
+ })();
+ };
+ const computeScore = () => {
+ const score = this.vr.getCurrentScore();
+ if (!navigate) {
+ if (["1-0","0-1"].includes(score)) {
+ if (Array.isArray(this.lastMove)) {
+ const L = this.lastMove.length;
+ this.lastMove[L - 1].notation += "#";
+ }
+ else this.lastMove.notation += "#";
+ }
+ }
+ if (score != "*" && this.mode == "analyze") {
+ const message = getScoreMessage(score);