Closed TheMadSword closed 9 months ago
parseCastlingFen
works on Setup
-level (or specifically Board
), i.e., matching rooks because it's necessary to understand the notation, but not yet taking rules into account. An equivalent parseEpSquare
is basically just parseSquare
.
Since this is about the board editor specifically ... the castling toggles are always there. Toggles can be used and rooks can be placed in any order. It would be consistent to allow selecting any en passant file at all times.
Currently in chessops, you have to setup a whole Position to know if a legalEpSquare exist. I think it may be logical to have a parseCastlingFen equivalent for enPassant; something like parseEnPassantFen(board, turnPart, epPart), returning a square if valid or undefined if the epPart isn't valid (e.g. 'd3' but no pawn or missing other pawn on the board).
I'm creating this issue as I'm doing lichess-org/lila#14139, and you need to wait for the "legalFen" [editor/src/ctrl.ts] to be created, which uses getSetup, which call parseFen & parseCastlingFen; so it is weird to not be able to valid enPassant there (while it is done with castling).
I also notice that in parseFen@fen.ts, only the fact that the square exist is validated, but not it's en-passant properties.
What do you think of it ?
edit : also possibly a way of getting all epSquares possibility.