- getCastleMoves([x, y]) {
+ // "castleInCheck" arg to let some variants castle under check
+ getCastleMoves([x, y], castleInCheck) {
const c = this.getColor(x, y);
if (x != (c == "w" ? V.size.x - 1 : 0) || y != this.INIT_COL_KING[c])
return []; //x isn't first rank, or king has moved (shortcut)
const c = this.getColor(x, y);
if (x != (c == "w" ? V.size.x - 1 : 0) || y != this.INIT_COL_KING[c])
return []; //x isn't first rank, or king has moved (shortcut)
if (this.castleFlags[c][castleSide] >= V.size.y) continue;
// If this code is reached, rooks and king are on initial position
if (this.castleFlags[c][castleSide] >= V.size.y) continue;
// If this code is reached, rooks and king are on initial position
if (this.getColor(x, rookPos) != c)
// Rook is here but changed color (see Benedict)
continue;
if (this.getColor(x, rookPos) != c)
// Rook is here but changed color (see Benedict)
continue;
(this.board[x][i] != V.EMPTY &&
// NOTE: next check is enough, because of chessboard constraints
(this.getColor(x, i) != c ||
(this.board[x][i] != V.EMPTY &&
// NOTE: next check is enough, because of chessboard constraints
(this.getColor(x, i) != c ||
new Move({
appear: [
new PiPo({ x: x, y: finalSquares[castleSide][0], p: V.KING, c: c }),
new Move({
appear: [
new PiPo({ x: x, y: finalSquares[castleSide][0], p: V.KING, c: c }),
- new PiPo({ x: x, y: finalSquares[castleSide][1], p: V.ROOK, c: c })
+ new PiPo({ x: x, y: finalSquares[castleSide][1], p: castlingPiece, c: c })
],
vanish: [
new PiPo({ x: x, y: y, p: V.KING, c: c }),
],
vanish: [
new PiPo({ x: x, y: y, p: V.KING, c: c }),
- new PiPo({ x: x, y: rookPos, p: V.ROOK, c: c })
+ new PiPo({ x: x, y: rookPos, p: castlingPiece, c: c })