From: Benjamin Auder Date: Tue, 29 Dec 2020 15:35:40 +0000 (+0100) Subject: Fix Wildebeest FEN generation + castling rule X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/images/assets/doc/current/mini-custom.min.css?a=commitdiff_plain;h=a538d4b000f905da16206871bb8f11e7e93f0c6a;p=vchess.git Fix Wildebeest FEN generation + castling rule --- diff --git a/client/src/variants/Wildebeest.js b/client/src/variants/Wildebeest.js index a2fc6148..a49da9b2 100644 --- a/client/src/variants/Wildebeest.js +++ b/client/src/variants/Wildebeest.js @@ -83,7 +83,7 @@ export class WildebeestRules extends ChessRules { } ]; if (sx + 2 * step != ex) { - //3-squares move + // 3-squares move res.push({ x: sx + 2 * step, y: sy @@ -228,7 +228,12 @@ export class WildebeestRules extends ChessRules { for (let i = range[0]; i <= range[1]; i++) { if (i != rookPos && this.isAttacked([x, i], oppCol)) continue castlingCheck; - if (i != y) { + if ( + i != y && + // Do not end in the corner, except if starting square is too near + (i > 0 || y == 1) && + (i < V.size.y - 1 || y == V.size.y - 2) + ) { // Found a possible castle move: moves.push( new Move({ @@ -305,7 +310,6 @@ export class WildebeestRules extends ChessRules { } static GenRandInitFen(randomness) { - if (!randomness) randomness = 2; if (randomness == 0) { return ( "rnccwkqbbnr/ppppppppppp/92/92/92/92/92/92/PPPPPPPPPPP/RNBBQKWCCNR " +