Skip to content

Commit

Permalink
Refactored isPinned()
Browse files Browse the repository at this point in the history
  • Loading branch information
programarivm committed Sep 27, 2024
1 parent f73f067 commit d86d9a6
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Variant/AbstractBoard.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,7 @@ protected function isPinned(AbstractPiece $piece): bool
{
$clone = $this->clone();
if ($clone->move($piece)) {
if ($king = $clone->piece($piece->color, Piece::K)) {
return !empty($king->attacking());
}
return !empty($clone->piece($piece->color, Piece::K)?->attacking());
}

return false;
Expand Down

0 comments on commit d86d9a6

Please sign in to comment.