X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FWildebeest.js;h=526da1a7f37c82b2df26518385481b74699b8c2b;hb=472c0c4f5aa29d96e080873ebfce2a04f664d852;hp=fe2a0c04dd35f490cc768f4914f2f69c33ea56b1;hpb=6f2f94374f1e73c375edf732d9425e575e81fff7;p=vchess.git diff --git a/client/src/variants/Wildebeest.js b/client/src/variants/Wildebeest.js index fe2a0c04..526da1a7 100644 --- a/client/src/variants/Wildebeest.js +++ b/client/src/variants/Wildebeest.js @@ -39,14 +39,7 @@ export class WildebeestRules extends ChessRules { } static IsGoodEnpassant(enpassant) { - if (enpassant != "-") { - const squares = enpassant.split(","); - if (squares.length > 2) return false; - for (let sq of squares) { - const ep = V.SquareToCoords(sq); - if (isNaN(ep.x) || !V.OnBoard(ep)) return false; - } - } + if (enpassant != "-") return !!enpassant.match(/^([a-j][0-9]{1,2},?)+$/); return true; } @@ -162,7 +155,7 @@ export class WildebeestRules extends ChessRules { // En passant const Lep = this.epSquares.length; const epSquare = this.epSquares[Lep - 1]; - if (epSquare) { + if (!!epSquare) { for (let epsq of epSquare) { // TODO: some redundant checks if (epsq.x == x + shiftX && Math.abs(epsq.y - y) == 1) { @@ -245,8 +238,12 @@ 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 w 0 akak -"; + if (randomness == 0) { + return ( + "rnccwkqbbnr/ppppppppppp/92/92/92/92/92/92/PPPPPPPPPPP/RNBBQKWCCNR " + + "w 0 akak -" + ); + } let pieces = { w: new Array(11), b: new Array(11) }; let flags = "";