X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FInterweave.js;h=3277c742a6ec30b72fec4e5ae4eab5f27341e6e6;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=8e0c3cc6ac021aa7568b3a8816ef1ec1de5f08b2;hpb=7ddfec38b0804bf0bd0c5b5c6972d355902e9fb0;p=vchess.git diff --git a/client/src/variants/Interweave.js b/client/src/variants/Interweave.js index 8e0c3cc6..3277c742 100644 --- a/client/src/variants/Interweave.js +++ b/client/src/variants/Interweave.js @@ -3,17 +3,18 @@ import { ArrayFun } from "@/utils/array"; import { randInt, shuffle } from "@/utils/alea"; export class InterweaveRules extends ChessRules { + static get HasFlags() { return false; } - static GenRandInitFen(randomness) { - if (randomness == 0) + static GenRandInitFen(options) { + if (options.randomness == 0) return "rbnkknbr/pppppppp/8/8/8/8/PPPPPPPP/RBNKKNBR w 0 - 000000"; let pieces = { w: new Array(8), b: new Array(8) }; for (let c of ["w", "b"]) { - if (c == 'b' && randomness == 1) { + if (c == 'b' && options.randomness == 1) { pieces['b'] = pieces['w']; break; } @@ -56,7 +57,7 @@ export class InterweaveRules extends ChessRules { if (['K','k'].includes(row[i])) kings[row[i]]++; if (V.PIECES.includes(row[i].toLowerCase())) sumElts++; else { - const num = parseInt(row[i]); + const num = parseInt(row[i], 10); if (isNaN(num)) return false; sumElts += num; } @@ -97,18 +98,19 @@ export class InterweaveRules 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.ROOK]: captured[0], + [V.KNIGHT]: captured[1], + [V.BISHOP]: captured[2] }, b: { - [V.ROOK]: parseInt(fenParsed.captured[3]), - [V.KNIGHT]: parseInt(fenParsed.captured[4]), - [V.BISHOP]: parseInt(fenParsed.captured[5]), + [V.ROOK]: captured[3], + [V.KNIGHT]: captured[4], + [V.BISHOP]: captured[5] } }; // Stack of "last move" only for intermediate captures @@ -638,4 +640,5 @@ export class InterweaveRules extends ChessRules { if (move.vanish.length >= 2) notation += "X"; return notation; } + };