X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FRoyalrace.js;h=346ca5f0b2a3749c003a6655110c5698f6879115;hb=68e19a449db7a12e0a168e99cd750d985c983ba1;hp=9318c1229a56336bee3e18f33323be63054cfa8d;hpb=f35b9960e1c527fc400ebac85321bd4712459da3;p=vchess.git diff --git a/client/src/variants/Royalrace.js b/client/src/variants/Royalrace.js index 9318c122..346ca5f0 100644 --- a/client/src/variants/Royalrace.js +++ b/client/src/variants/Royalrace.js @@ -21,7 +21,7 @@ export const VariantRules = class RoyalraceRules extends ChessRules { static GenRandInitFen(randomness) { if (randomness == 0) - return "11/11/11/11/11/11/11/11/11/QRBNP1pnbrq/KRBNP1pnbrk w 0"; + return "11/11/11/11/11/11/11/11/11/qrbnp1PNBRQ/krbnp1PNBRK w 0"; let pieces = { w: new Array(10), b: new Array(10) }; // Shuffle pieces on first and second rank @@ -93,13 +93,13 @@ export const VariantRules = class RoyalraceRules extends ChessRules { const blackFen = pieces["b"].join(""); return ( "11/11/11/11/11/11/11/11/11/" + - whiteFen.substr(5).split("").reverse().join("") + + blackFen.substr(5).split("").reverse().join("") + "1" + - blackFen.substr(5).split("").join("") + + whiteFen.substr(5).split("").join("") + "/" + - whiteFen.substr(0,5) + + blackFen.substr(0,5) + "1" + - blackFen.substr(0,5).split("").reverse().join("") + + whiteFen.substr(0,5).split("").reverse().join("") + " w 0" ); } @@ -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] ); @@ -189,8 +189,7 @@ export const VariantRules = class RoyalraceRules extends ChessRules { if (this.kingPos[color][0] == 0) // The opposing edge is reached! return color == "w" ? "1-0" : "0-1"; - if (this.atLeastOneMove()) - return "*"; + if (this.atLeastOneMove()) return "*"; // Stalemate (will probably never happen) return "1/2"; }