X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FWildebeest.js;h=6317c4bb5f1d283a63420bd7a1acfb17286e7fbd;hb=7e8a7ea1cb66adb4a987badfb0a3c2f99a21bd0a;hp=8664e5ed571b99cc46c58434cccd5b78d160c4d9;hpb=2c5d7b20742b802d9c47916915c1114bcfc9a9c3;p=vchess.git diff --git a/client/src/variants/Wildebeest.js b/client/src/variants/Wildebeest.js index 8664e5ed..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) { @@ -322,4 +316,5 @@ export class WildebeestRules extends ChessRules { " w 0 " + flags + " -" ); } + };