1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:48:10 +00:00

LibChess: Fix the ability to counter check with another check

fixes #3187,#3171
This commit is contained in:
Peter Elliott 2020-08-18 15:17:20 -06:00 committed by Andreas Kling
parent d2cb5e0f48
commit e80d0abb2c

View file

@ -334,11 +334,7 @@ bool Board::in_check(Colour colour) const
bool check = false;
Square::for_each([&](const Square& square) {
if (is_legal({ square, king_square }, opposing_colour(colour))) {
check = true;
return IterationDecision::Break;
} else if (get_piece(square) == Piece(opposing_colour(colour), Type::King) && is_legal_no_check({ square, king_square }, opposing_colour(colour))) {
// The King is a special case, because it would be in check if it put the opposing king in check.
if (is_legal_no_check({ square, king_square }, opposing_colour(colour))) {
check = true;
return IterationDecision::Break;
}