this.vr = new V(game.fenStart);
const parsedFen = V.ParseFen(game.fenStart);
const firstMoveColor = parsedFen.turn;
- this.firstMoveNumber = Math.floor(parsedFen.movesCount / 2);
+ this.firstMoveNumber = Math.floor(parsedFen.movesCount / 2) + 1;
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.index = this.vr.movesCount;
m.notation = this.vr.getNotation(m);
m.unambiguous = V.GetUnambiguousNotation(m);
this.vr.play(m);
if (firstMoveColor == "b") {
// 'start' & 'end' is required for Board component
this.moves.unshift({
- index: parsedFen.movesCount,
notation: "...",
unambiguous: "...",
start: { x: -1, y: -1 },
// Adjust dots notation for a better display:
let fullNotation = getFullNotation(this.moves[i]);
if (fullNotation == "...") fullNotation = "..";
- pgn += (this.moves[i].index / 2 + 1) + "." + fullNotation;
+ pgn += (i / 2 + this.firstMoveNumber) + "." + fullNotation;
if (i+1 < this.moves.length)
pgn += " " + getFullNotation(this.moves[i+1]);
}
pgn += "\n\n";
for (let i = 0; i < this.moves.length; i += 2) {
- const moveNumber = this.moves[i].index / 2 + 1;
+ const moveNumber = i / 2 + this.firstMoveNumber;
// Skip "dots move", useless for machine reading:
if (this.moves[i].notation != "...") {
pgn += moveNumber + ".w " +
}
// There was something on x2,y2, maybe our color, pushed/pulled.
- // Also, the pushed/pulled piece must exit the board.
isAprioriValidExit([x1, y1], [x2, y2], color2) {
const color1 = this.getColor(x1, y1);
const pawnShift = (color1 == 'w' ? -1 : 1);
// Piece at subTurn 1 just exited the board.
// Can I be a piece which caused the exit?
if (
+ // Only "turn" color can do actions
+ sqCol == color &&
this.isAprioriValidExit(
[x, y],
[fm.start.x, fm.start.y],
// Seems so:
const dir = this.getNormalizedDirection(
[fm.start.x - x, fm.start.y - y]);
- return this.getMovesInDirection([x, y], dir);
+ const nbSteps =
+ ([V.PAWN,V.KING,V.KNIGHT].includes(this.getPiece(x, y)) ? 1 : null);
+ return this.getMovesInDirection([x, y], dir, nbSteps);
}
}
else {