X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FWildebeest.js;h=6317c4bb5f1d283a63420bd7a1acfb17286e7fbd;hb=7e8a7ea1cb66adb4a987badfb0a3c2f99a21bd0a;hp=fe2a0c04dd35f490cc768f4914f2f69c33ea56b1;hpb=6f2f94374f1e73c375edf732d9425e575e81fff7;p=vchess.git diff --git a/client/src/variants/Wildebeest.js b/client/src/variants/Wildebeest.js index fe2a0c04..6317c4bb 100644 --- a/client/src/variants/Wildebeest.js +++ b/client/src/variants/Wildebeest.js @@ -3,6 +3,7 @@ import { ArrayFun } from "@/utils/array"; import { sample, randInt } from "@/utils/alea"; export class WildebeestRules extends ChessRules { + static get size() { return { x: 10, y: 11 }; } @@ -39,14 +40,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 +156,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 +239,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 = ""; @@ -318,4 +316,5 @@ export class WildebeestRules extends ChessRules { " w 0 " + flags + " -" ); } + };