lib/chess/board.rb
# Returns true if en passant is allowed on a recently moved pawn
Returns true if en passant is allowed on a recently moved pawn
Returns true if en passant is allowed on a recently moved pawn
def en_passant_allowed?(pawn, from_row)
      return false if pawn.moved == true || 
                      (pawn.location[0] - from_row).abs != 2
      [pawn.location[1] - 1, pawn.location[1] + 1].any? do |column|
        return false unless column.between?(0,7)
        possible_pawn = @state[pawn.location[0]][column]
        possible_pawn.class == Pawn && possible_pawn.color != pawn.color
      end
    end
def en_passant_allowed? ( pawn , from_row ) return false if pawn . moved == true || ( pawn . location [ 0 ] - from_row ) . abs != 2 [ pawn . location [ 1 ] - 1 , pawn . location [ 1 ] + 1 ] . any? do | column | return false unless column . between? ( 0 , 7 ) possible_pawn = @state [ pawn . location [ 0 ] ] [ column ] possible_pawn . class == Pawn && possible_pawn . color != pawn . color end end
Returns true if en passant is allowed on a recently moved pawn
Returns true if en passant is allowed on a recently moved pawn
pawn
<not_specific>
from_row
<not_specific>