return V.ShowMoves;
}
+ // Sometimes moves must remain hidden until game ends
+ static get SomeHiddenMoves() {
+ return false;
+ }
+ get someHiddenMoves() {
+ return V.SomeHiddenMoves;
+ }
+
+ // Generally true, unless the variant includes random effects
+ static get CorrConfirm() {
+ return true;
+ }
+
// Used for Monochrome variant (TODO: harmonize: !canFlip ==> showFirstTurn)
get showFirstTurn() {
return false;
if (x2 == lastRank) {
// promotions arg: special override for Hiddenqueen variant
if (!!promotions) finalPieces = promotions;
- else if (!!V.PawnSpecs.promotions)
- finalPieces = V.PawnSpecs.promotions;
+ else if (!!V.PawnSpecs.promotions) finalPieces = V.PawnSpecs.promotions;
}
let tr = null;
for (let piece of finalPieces) {
const [sizeX, sizeY] = [V.size.x, V.size.y];
const pawnShiftX = V.PawnSpecs.directions[color];
const firstRank = (color == "w" ? sizeX - 1 : 0);
+ const forward = (color == 'w' ? -1 : 1);
// Pawn movements in shiftX direction:
const getPawnMoves = (shiftX) => {
// NOTE: next condition is generally true (no pawn on last rank)
if (x + shiftX >= 0 && x + shiftX < sizeX) {
if (this.board[x + shiftX][y] == V.EMPTY) {
- // One square forward
+ // One square forward (or backward)
this.addPawnMoves([x, y], [x + shiftX, y], moves, promotions);
// Next condition because pawns on 1st rank can generally jump
if (
(color == 'b' && x <= V.PawnSpecs.initShift['b'])
)
) {
- if (this.board[x + 2 * shiftX][y] == V.EMPTY) {
+ if (
+ shiftX == forward &&
+ this.board[x + 2 * shiftX][y] == V.EMPTY
+ ) {
// Two squares jump
moves.push(this.getBasicMove([x, y], [x + 2 * shiftX, y]));
if (
// Captures
if (V.PawnSpecs.canCapture) {
for (let shiftY of [-1, 1]) {
- if (
- y + shiftY >= 0 &&
- y + shiftY < sizeY
- ) {
+ if (y + shiftY >= 0 && y + shiftY < sizeY) {
if (
this.board[x + shiftX][y + shiftY] != V.EMPTY &&
this.canTake([x, y], [x + shiftX, y + shiftY])
);
}
if (
- V.PawnSpecs.captureBackward &&
+ V.PawnSpecs.captureBackward && shiftX == forward &&
x - shiftX >= 0 && x - shiftX < V.size.x &&
this.board[x - shiftX][y + shiftY] != V.EMPTY &&
this.canTake([x, y], [x - shiftX, y + shiftY])
) {
this.addPawnMoves(
- [x, y], [x + shiftX, y + shiftY],
+ [x, y], [x - shiftX, y + shiftY],
moves, promotions
);
}
if (
// NOTE: "castling" arg is used by some variants (Monster),
// where "isAttacked" is overloaded in an infinite-recursive way.
+ // TODO: not used anymore (Monster + Doublemove2 are simplified).
(!castleInCheck && this.isAttacked([x, i], oppCol, "castling")) ||
(this.board[x][i] != V.EMPTY &&
// NOTE: next check is enough, because of chessboard constraints
piece = move.appear[0].p;
// Update king position + flags
- if (piece == V.KING && move.appear.length > 0) {
- this.kingPos[c][0] = move.appear[0].x;
- this.kingPos[c][1] = move.appear[0].y;
- }
+ if (piece == V.KING && move.appear.length > 0)
+ this.kingPos[c] = [move.appear[0].x, move.appear[0].y];
if (V.HasCastle) this.updateCastleFlags(move, piece);
}