+ static IsGoodEnpassant(enpassant) {
+ if (enpassant != "-") {
+ const epParts = enpassant.split(",");
+ const epSq = V.SquareToCoords(epParts[0]);
+ if (isNaN(epSq.x) || isNaN(epSq.y) || !V.OnBoard(epSq)) return false;
+ const arrCol = V.ColumnToCoord(epParts[1]);
+ if (isNaN(arrCol) || arrCol < 0 || arrCol >= V.size.y) return false;
+ }
+ return true;
+ }
+
+ getEnpassantFen() {
+ const L = this.epSquares.length;
+ if (!this.epSquares[L - 1]) return "-"; //no en-passant
+ return (
+ V.CoordsToSquare(this.epSquares[L - 1][0]) +
+ "," +
+ V.CoordToColumn(this.epSquares[L - 1][1])
+ );
+ }
+
+ getEnpassantCaptures([x, y], shift) {
+ const Lep = this.epSquares.length;
+ const epSquare = this.epSquares[Lep - 1]; //always at least one element
+ if (
+ !!epSquare &&
+ epSquare[0].x == x + shift &&
+ epSquare[0].y == y
+ ) {
+ let enpassantMove = this.getBasicMove([x, y], [x + shift, y]);
+ enpassantMove.vanish.push({
+ x: x,
+ y: epSquare[1],
+ p: "p",
+ c: this.getColor(x, epSquare[1])
+ });
+ return [enpassantMove];
+ }
+ return [];
+ }
+