X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FRoyalrace.js;h=346ca5f0b2a3749c003a6655110c5698f6879115;hp=f5c7550a16b920b507d38a19a7375e231b96cb2d;hb=68e19a449db7a12e0a168e99cd750d985c983ba1;hpb=11589e7c4bb1b69473588d133db8b6d1d37b8fee diff --git a/client/src/variants/Royalrace.js b/client/src/variants/Royalrace.js index f5c7550a..346ca5f0 100644 --- a/client/src/variants/Royalrace.js +++ b/client/src/variants/Royalrace.js @@ -155,16 +155,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 +174,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] );