+ case 32:
+ this.flip();
+ break;
+ }
+ },
+ handleScroll: function(e) {
+ e.preventDefault();
+ if (e.deltaY < 0) this.undo();
+ else if (e.deltaY > 0) this.play();
+ },
+ showRules: function() {
+ //this.$router.push("/variants/" + this.game.vname);
+ window.open("#/variants/" + this.game.vname, "_blank"); //better
+ },
+ re_setVariables: function(game) {
+ if (!game) game = this.game; //in case of...
+ this.endgameMessage = "";
+ // "w": default orientation for observed games
+ this.orientation = game.mycolor || "w";
+ this.moves = JSON.parse(JSON.stringify(game.moves || []));
+ // Post-processing: decorate each move with notation and FEN
+ this.vr = new V(game.fenStart);
+ const parsedFen = V.ParseFen(game.fenStart);
+ const firstMoveColor = parsedFen.turn;
+ this.firstMoveNumber = Math.floor(parsedFen.movesCount / 2);
+ let L = this.moves.length;
+ this.moves.forEach(move => {
+ // Strategy working also for multi-moves:
+ if (!Array.isArray(move)) move = [move];
+ move.forEach((m,idx) => {
+ m.notation = this.vr.getNotation(m);
+ this.vr.play(m);
+ if (idx < L - 1 && this.vr.getCheckSquares(this.vr.turn).length > 0)
+ m.notation += "+";
+ });
+ });
+ if (firstMoveColor == "b") {
+ // 'start' & 'end' is required for Board component
+ this.moves.unshift({
+ notation: "...",
+ start: { x: -1, y: -1 },
+ end: { x: -1, y: -1 },
+ fen: game.fenStart
+ });
+ L++;
+ }
+ this.positionCursorTo(this.moves.length - 1);
+ this.incheck = this.vr.getCheckSquares(this.vr.turn);
+ const score = this.vr.getCurrentScore();
+ if (L > 0 && this.moves[L - 1].notation != "...") {
+ if (["1-0","0-1"].includes(score))
+ this.moves[L - 1].notation += "#";
+ else if (this.vr.getCheckSquares(this.vr.turn).length > 0)
+ this.moves[L - 1].notation += "+";