Module: CastlingRights

Included in:
Player
Defined in:
lib/sapphire-chess/movement_rules/castling_rights.rb

Instance Method Summary collapse

Instance Method Details

#castle_rights?(side) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
5
6
7
8
# File 'lib/sapphire-chess/movement_rules/castling_rights.rb', line 2

def castle_rights?(side)
  !king_and_rook_moved?(side) &&
    castling_line_free?(side) &&
    !board.in_check?(color) &&
    !results_in_check?(side) &&
    !king_crosses_attack_line?(side)
end