X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FRoyalrace.js;h=c9095558e2e38beb0b79667fc71380122b153015;hb=c583ef1c1dfd19aee88b22c2175202fbdf4dc1c0;hp=f5c7550a16b920b507d38a19a7375e231b96cb2d;hpb=6b7b2cf720e6255e4da0dc34fee363c456346a58;p=vchess.git diff --git a/client/src/variants/Royalrace.js b/client/src/variants/Royalrace.js index f5c7550a..c9095558 100644 --- a/client/src/variants/Royalrace.js +++ b/client/src/variants/Royalrace.js @@ -7,6 +7,10 @@ export const VariantRules = class RoyalraceRules extends ChessRules { return false; } + static get HasCastle() { + return false; + } + static get HasEnpassant() { return false; } @@ -133,15 +137,6 @@ export const VariantRules = class RoyalraceRules extends ChessRules { return this.getSlideNJumpMoves(sq, V.steps[V.KNIGHT]); } - // What are the king moves from square x,y ? - getPotentialKingMoves(sq) { - return this.getSlideNJumpMoves( - sq, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]), - "oneStep" - ); - } - filterValid(moves) { if (moves.length == 0) return []; const color = this.turn; @@ -155,16 +150,16 @@ export const VariantRules = class RoyalraceRules extends ChessRules { }); } - isAttackedByPawn([x, y], colors) { - const pawnShift = 1; - if (x + pawnShift < V.size.x) { - for (let c of colors) { + isAttackedByPawn([x, y], color) { + // Pawns can capture forward and backward: + for (let pawnShift of [-1, 1]) { + if (0 < x + pawnShift && 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) == c + this.getColor(x + pawnShift, y + i) == color ) { return true; } @@ -174,10 +169,10 @@ export const VariantRules = class RoyalraceRules extends ChessRules { return false; } - isAttackedByKnight(sq, colors) { + isAttackedByKnight(sq, color) { return this.isAttackedBySlideNJump( sq, - colors, + color, V.KNIGHT, V.steps[V.KNIGHT] );