X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FGrand.js;h=398a96cca55ed7316ac2ca05dbdd927f705a75b3;hb=7e8a7ea1cb66adb4a987badfb0a3c2f99a21bd0a;hp=743f01f9571b04edac1cb35d7f46b7a1f9ab37b9;hpb=6e47d367d4b1b4500bc46d65b44c5e55b52221bb;p=vchess.git diff --git a/client/src/variants/Grand.js b/client/src/variants/Grand.js index 743f01f9..398a96cc 100644 --- a/client/src/variants/Grand.js +++ b/client/src/variants/Grand.js @@ -5,6 +5,7 @@ import { randInt } from "@/utils/alea"; // NOTE: initial setup differs from the original; see // https://www.chessvariants.com/large.dir/freeling.html export class GrandRules extends ChessRules { + static IsGoodFen(fen) { if (!ChessRules.IsGoodFen(fen)) return false; const fenParsed = V.ParseFen(fen); @@ -55,24 +56,25 @@ export class GrandRules extends ChessRules { setOtherVariables(fen) { super.setOtherVariables(fen); - const fenParsed = V.ParseFen(fen); + const captured = + V.ParseFen(fen).captured.split("").map(x => parseInt(x, 10)); // Initialize captured pieces' counts from FEN this.captured = { w: { - [V.ROOK]: parseInt(fenParsed.captured[0]), - [V.KNIGHT]: parseInt(fenParsed.captured[1]), - [V.BISHOP]: parseInt(fenParsed.captured[2]), - [V.QUEEN]: parseInt(fenParsed.captured[3]), - [V.MARSHALL]: parseInt(fenParsed.captured[4]), - [V.CARDINAL]: parseInt(fenParsed.captured[5]) + [V.ROOK]: captured[0], + [V.KNIGHT]: captured[1], + [V.BISHOP]: captured[2], + [V.QUEEN]: captured[3], + [V.MARSHALL]: captured[4], + [V.CARDINAL]: captured[5] }, b: { - [V.ROOK]: parseInt(fenParsed.captured[6]), - [V.KNIGHT]: parseInt(fenParsed.captured[7]), - [V.BISHOP]: parseInt(fenParsed.captured[8]), - [V.QUEEN]: parseInt(fenParsed.captured[9]), - [V.MARSHALL]: parseInt(fenParsed.captured[10]), - [V.CARDINAL]: parseInt(fenParsed.captured[11]) + [V.ROOK]: captured[6], + [V.KNIGHT]: captured[7], + [V.BISHOP]: captured[8], + [V.QUEEN]: captured[9], + [V.MARSHALL]: captured[10], + [V.CARDINAL]: captured[11] } }; } @@ -390,4 +392,5 @@ export class GrandRules extends ChessRules { " w 0 " + flags + " - 00000000000000" ); } + };