summaryrefslogtreecommitdiff
path: root/Libraries/LibChess
diff options
context:
space:
mode:
authorPeter Elliott <pelliott@ualberta.ca>2020-08-18 15:17:20 -0600
committerAndreas Kling <kling@serenityos.org>2020-08-21 12:26:30 +0200
commite80d0abb2c5030bb63be905efe9b1d8f62ce5a40 (patch)
treeb5d18d73724bcbe1ffcae0b1e9463be9c73da80d /Libraries/LibChess
parentd2cb5e0f48fe9fa48b1d90f8ad44c334f7afea06 (diff)
downloadserenity-e80d0abb2c5030bb63be905efe9b1d8f62ce5a40.zip
LibChess: Fix the ability to counter check with another check
fixes #3187,#3171
Diffstat (limited to 'Libraries/LibChess')
-rw-r--r--Libraries/LibChess/Chess.cpp6
1 files changed, 1 insertions, 5 deletions
diff --git a/Libraries/LibChess/Chess.cpp b/Libraries/LibChess/Chess.cpp
index 7220d7b6d5..58f8985670 100644
--- a/Libraries/LibChess/Chess.cpp
+++ b/Libraries/LibChess/Chess.cpp
@@ -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;
}