- this.vr.play(move);
- this.cursor++;
- this.lastMove = move;
- if (this.st.settings.sound == 2)
- new Audio("/sounds/move.mp3").play().catch(() => {});
- if (!navigate) {
- move.fen = this.vr.getFen();
- // Stack move on movesList at current cursor
- if (this.cursor == this.moves.length) this.moves.push(move);
- else this.moves = this.moves.slice(0, this.cursor).concat([move]);
+ this.inPlay = true;
+ if (this.mode == "analyze") this.toggleAnalyze();
+ if (this.cursor < this.moves.length - 1)
+ // To play a received move, cursor must be at the end of the game:
+ this.gotoEnd();
+ }
+ // The board may show some 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);