X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FInterweave.js;h=973797d64b3f55655fcc88e2588f80b33ba498e5;hp=8e0c3cc6ac021aa7568b3a8816ef1ec1de5f08b2;hb=e50a802531b99829c533f22ecd21e359e7e1e049;hpb=204b0bb5dc8b5f2760fcbf60cc23deb4552f4305 diff --git a/client/src/variants/Interweave.js b/client/src/variants/Interweave.js index 8e0c3cc6..973797d6 100644 --- a/client/src/variants/Interweave.js +++ b/client/src/variants/Interweave.js @@ -56,7 +56,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 +97,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