lib/chess/board.rb
# Helper function for #valid_move? that returns true if the
# move the pawn is trying to make is true or false on the board state
Helper function for #valid_move. that returns true if the
move the pawn is trying to make is true or false on the board state
Helper function for #valid_move . that returns true if the move the pawn is trying to make is true or false on the board state
def pawn_valid_move?(pawn, new_location, to_column, from_column)
      if to_column == from_column
        if (new_location[0] - pawn.location[0]).abs == 2
          return false if pawn.moved == true
        end
        empty_location?(new_location)
      else
        if enemy_piece_at_location?(pawn.color, new_location)
          true
        else
          valid_en_passant_move?(pawn.color, pawn.location[0], to_column)
        end
      end
    end
def pawn_valid_move? ( pawn , new_location , to_column , from_column ) if to_column == from_column if ( new_location [ 0 ] - pawn . location [ 0 ] ) . abs == 2 return false if pawn . moved == true end empty_location? ( new_location ) else if enemy_piece_at_location? ( pawn . color , new_location ) true else valid_en_passant_move? ( pawn . color , pawn . location [ 0 ] , to_column ) end end end
Helper function for #valid_move?
Helper function for #valid_move?
pawn
<not_specific>
new_location
<not_specific>
to_column
<not_specific>
from_column
<not_specific>