feat: en passant generally implemented
This commit is contained in:
parent
1842e25918
commit
10a4dcb60b
4 changed files with 53 additions and 12 deletions
|
|
@ -392,6 +392,10 @@ std::vector<Move> Pawn::getLegalMoves(const Square &from, Board &board) const {
|
|||
if(target && target->getColour() != this->getColour()) {
|
||||
// legal capture
|
||||
moveList.push_back({from, targetSquare});
|
||||
} else if(targetSquare.rank == board.getEnPassantTargetSquare().rank &&
|
||||
targetSquare.file == board.getEnPassantTargetSquare().file) {
|
||||
// en passant capture
|
||||
moveList.push_back({from, targetSquare});
|
||||
} else
|
||||
continue;
|
||||
} else { // normal one square forward
|
||||
|
|
@ -419,6 +423,10 @@ std::vector<Move> Pawn::getLegalMoves(const Square &from, Board &board) const {
|
|||
if(target && target->getColour() != this->getColour()) { // can only move there if it's a capture
|
||||
// legal capture
|
||||
moveList.push_back({from, targetSquare});
|
||||
} else if(targetSquare.rank == board.getEnPassantTargetSquare().rank &&
|
||||
targetSquare.file == board.getEnPassantTargetSquare().file) {
|
||||
// en passant capture
|
||||
moveList.push_back({from, targetSquare});
|
||||
} else
|
||||
continue;
|
||||
} else { // normal one square forward
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue