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;
+ }
+
// Some variants always show the same orientation
static get CanFlip() {
return true;
return V.CanFlip;
}
+ // For (generally old) variants without checkered board
+ static get Monochrome() {
+ return false;
+ }
+
+ // Some variants require lines drawing
+ static get Lines() {
+ if (V.Monochrome) {
+ let lines = [];
+ // Draw all inter-squares lines
+ for (let i = 0; i <= V.size.x; i++)
+ lines.push([[i, 0], [i, V.size.y]]);
+ for (let j = 0; j <= V.size.y; j++)
+ lines.push([[0, j], [V.size.x, j]]);
+ return lines;
+ }
+ return null;
+ }
+
// Some variants use click infos:
doClick() {
return null;
}
+ // Some variants may need to highlight squares on hover (Hamilton, Weiqi...)
+ hoverHighlight() {
+ return false;
+ }
+
static get IMAGE_EXTENSION() {
// All pieces should be in the SVG format
return ".svg";
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) {
// 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 (
// 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
if (this.board[i][j] != V.EMPTY && this.getColor(i, j) == color) {
const moves = this.getPotentialMovesFrom([i, j]);
if (moves.length > 0) {
- for (let k = 0; k < moves.length; k++) {
+ for (let k = 0; k < moves.length; k++)
if (this.filterValid([moves[k]]).length > 0) return true;
- }
}
}
}
}
// Is square x,y attacked by 'color' pawns ?
- isAttackedByPawn([x, y], color) {
+ isAttackedByPawn(sq, color) {
const pawnShift = (color == "w" ? 1 : -1);
- if (x + pawnShift >= 0 && x + pawnShift < V.size.x) {
- for (let i of [-1, 1]) {
- if (
- y + i >= 0 &&
- y + i < V.size.y &&
- this.getPiece(x + pawnShift, y + i) == V.PAWN &&
- this.getColor(x + pawnShift, y + i) == color
- ) {
- return true;
- }
- }
- }
- return false;
+ return this.isAttackedBySlideNJump(
+ sq,
+ color,
+ V.PAWN,
+ [[pawnShift, 1], [pawnShift, -1]],
+ "oneStep"
+ );
}
// Is square x,y attacked by 'color' rooks ?