X-Git-Url: https://git.auder.net/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fvariants%2FGrand.js;h=aeb7b6f4dfb86690a20f48433d58d729526eb9db;hb=472c0c4f5aa29d96e080873ebfce2a04f664d852;hp=0809a65dc075d3adceae3b86595049637c0ee646;hpb=6f2f94374f1e73c375edf732d9425e575e81fff7;p=vchess.git diff --git a/client/src/variants/Grand.js b/client/src/variants/Grand.js index 0809a65d..aeb7b6f4 100644 --- a/client/src/variants/Grand.js +++ b/client/src/variants/Grand.js @@ -9,20 +9,13 @@ export class GrandRules extends ChessRules { if (!ChessRules.IsGoodFen(fen)) return false; const fenParsed = V.ParseFen(fen); // 5) Check captures - if (!fenParsed.captured || !fenParsed.captured.match(/^[0-9]{14,14}$/)) + if (!fenParsed.captured || !fenParsed.captured.match(/^[0-9]{12,12}$/)) return false; return true; } 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; } @@ -139,7 +132,7 @@ export class GrandRules extends ChessRules { } ]; if (sx + 2 * step != ex) { - //3-squares move + // 3-squares jump res.push({ x: sx + 2 * step, y: sy @@ -225,7 +218,7 @@ export class GrandRules 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) { @@ -328,9 +321,11 @@ export class GrandRules extends ChessRules { static GenRandInitFen(randomness) { if (randomness == 0) { - // No castling in the official initial setup - return "r8r/1nbqkmcbn1/pppppppppp/91/91/91/91/PPPPPPPPPP/1NBQKMCBN1/R8R " + - "w 0 zzzz - 00000000000000"; + return ( + "r8r/1nbqkmcbn1/pppppppppp/91/91/91/91/PPPPPPPPPP/1NBQKMCBN1/R8R " + + // No castling in the official initial setup + "w 0 zzzz - 00000000000000" + ); } let pieces = { w: new Array(10), b: new Array(10) }; @@ -378,7 +373,8 @@ export class GrandRules extends ChessRules { let cardinalPos = positions[randIndex]; positions.splice(randIndex, 1); - // Rooks and king positions are now fixed, because of the ordering rook-king-rook + // Rooks and king positions are now fixed, + // because of the ordering rook-king-rook let rook1Pos = positions[0]; let kingPos = positions[1]; let rook2Pos = positions[2];