.addEventListener("click", processModalClick);
},
beforeDestroy: function() {
.addEventListener("click", processModalClick);
},
beforeDestroy: function() {
const firstMoveColor = parsedFen.turn;
this.firstMoveNumber = Math.floor(parsedFen.movesCount / 2) + 1;
let L = this.moves.length;
const firstMoveColor = parsedFen.turn;
this.firstMoveNumber = Math.floor(parsedFen.movesCount / 2) + 1;
let L = this.moves.length;
this.moves.forEach((move,idx) => {
// Strategy working also for multi-moves:
if (!Array.isArray(move)) move = [move];
this.moves.forEach((move,idx) => {
// Strategy working also for multi-moves:
if (!Array.isArray(move)) move = [move];
if (idxM == Lm - 1) m.fen = this.vr.getFen();
if (idx == L - 1 && idxM == Lm - 1) {
this.incheck = checkSquares;
if (idxM == Lm - 1) m.fen = this.vr.getFen();
if (idx == L - 1 && idxM == Lm - 1) {
this.incheck = checkSquares;
- const score = this.vr.getCurrentScore();
- if (["1-0", "0-1"].includes(score)) m.notation += "#";
+ this.score = this.vr.getCurrentScore();
+ if (["1-0", "0-1"].includes(this.score)) m.notation += "#";
- const infinitePlay = () => {
- if (this.cursor == this.moves.length - 1) {
- clearInterval(this.autoplayLoop);
- this.autoplayLoop = null;
- this.autoplay = false;
- return;
- }
- if (this.inPlay || this.inMultimove)
- // Wait next tick
- return;
- this.play();
- };
- clearInterval(this.autoplayLoop);
- this.autoplayLoop = null;
- } else {
+ if (this.stackToPlay.length > 0)
+ // Move(s) arrived in-between
+ this.play(this.stackToPlay.pop(), "received");
+ }
+ else if (this.cursor < this.moves.length - 1) {
-
- if (this.mode == "analyze") { console.log("received move");
- console.log(move); }
-
- 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();
- }
- if (!!noemit) {
- if (this.inPlay) {
- // Received moves in observed games can arrive too fast:
+ if (this.autoplay || this.inPlay) {
+ // Received moves while autoplaying are stacked,
+ // and in observed games they could arrive too fast:
}
// The board may show some the possible moves: (TODO: bad solution)
this.$refs["board"].resetCurrentAttempt();
}
// The board may show some the possible moves: (TODO: bad solution)
this.$refs["board"].resetCurrentAttempt();
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);
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);
+ if (moveIdx < move.length) setTimeout(executeMove, 500);
if (Array.isArray(this.lastMove)) {
const L = this.lastMove.length;
this.lastMove[L - 1].notation += "#";
if (Array.isArray(this.lastMove)) {
const L = this.lastMove.length;
this.lastMove[L - 1].notation += "#";
this.showEndgameMsg(score + " . " + this.st.tr[message]);
}
return score;
};
const afterMove = (smove, initurn) => {
if (this.vr.turn != initurn) {
this.showEndgameMsg(score + " . " + this.st.tr[message]);
}
return score;
};
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)
// Turn has changed: move is complete
if (!smove.fen)
// NOTE: only FEN of last sub-move is required (=> setting it here)
+ if (this.autoplay) {
+ if (this.cursor < this.moves.length - 1)
+ setTimeout(this.play, 1000);
+ else {
+ this.autoplay = false;
+ if (this.stackToPlay.length > 0)
+ // Move(s) arrived in-between
+ this.play(this.stackToPlay.pop(), "received");
+ }
+ }
- // NOTE: always emit the score, even in unfinished,
- // to tell Game::processMove() that it's not a received move.
+ // 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.$emit("newmove", this.moves[L-1], { score: this.score });
} else {
this.inPlay = false;
if (this.stackToPlay.length > 0)
// Move(s) arrived in-between