Skip to content

Commit

Permalink
Will yell at you if you try to open your king to a check
Browse files Browse the repository at this point in the history
  • Loading branch information
Everesh committed Jun 15, 2024
1 parent 58ca47e commit 1fb6fe3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/board.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ def legal_move?(algebraic_notation, active_player, history)

if capture && (board[target[0]][target[1]] == ' ' || board[target[0]][target[1]].color == active_player || !en_passant?(active_player, history))
puts '## Invalid capture target'
return false
return false
end

return false if king_would_be_in_check?
if king_would_be_in_check?
puts '## Would result in putting your king in check'
return false
end

if enemy_would_be_in_check?
if would_conclude?
Expand Down

0 comments on commit 1fb6fe3

Please sign in to comment.