+ 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;
+ }
+ }
+ return true;
+ }
+
+ static ParseFen(fen)
+ {
+ const fenParts = fen.split(" ");
+ return Object.assign(
+ ChessRules.ParseFen(fen),
+ { captured: fenParts[5] }
+ );
+ }
+
+ getFen()
+ {
+ return super.getFen() + " " + this.getCapturedFen();
+ }
+
+ getCapturedFen()
+ {
+ let counts = _.map(_.range(14), 0);
+ let i = 0;
+ for (let j=0; j<V.PIECES.length; j++)
+ {
+ if (V.PIECES[j] == V.KING) //no king captured
+ continue;
+ counts[i] = this.captured["w"][V.PIECES[i]];
+ counts[7+i] = this.captured["b"][V.PIECES[i]];
+ i++;
+ }
+ return counts.join("");
+ }
+
+ setOtherVariables(fen)
+ {
+ super.setOtherVariables(fen);
+ const fenParsed = V.ParseFen(fen);
+ // Initialize captured pieces' counts from FEN
+ this.captured =
+ {
+ "w":
+ {
+ [V.PAWN]: parseInt(fenParsed.captured[0]),
+ [V.ROOK]: parseInt(fenParsed.captured[1]),
+ [V.KNIGHT]: parseInt(fenParsed.captured[2]),
+ [V.BISHOP]: parseInt(fenParsed.captured[3]),
+ [V.QUEEN]: parseInt(fenParsed.captured[4]),
+ [V.MARSHALL]: parseInt(fenParsed.captured[5]),
+ [V.CARDINAL]: parseInt(fenParsed.captured[6]),
+ },
+ "b":
+ {
+ [V.PAWN]: parseInt(fenParsed.captured[7]),
+ [V.ROOK]: parseInt(fenParsed.captured[8]),
+ [V.KNIGHT]: parseInt(fenParsed.captured[9]),
+ [V.BISHOP]: parseInt(fenParsed.captured[10]),
+ [V.QUEEN]: parseInt(fenParsed.captured[11]),
+ [V.MARSHALL]: parseInt(fenParsed.captured[12]),
+ [V.CARDINAL]: parseInt(fenParsed.captured[13]),
+ }
+ };
+ }
+
+ static get size() { return {x:10,y:10}; }