lib/pgn/move_calculator.rb
# From the destination square, move in each direction stopping if we
# reach the end of the board. If we encounter a piece, add it to the
# list of origin possibilities if it is the moving piece, or else
# check the next direction.
#
From the destination square, move in each direction stopping if we
reach the end of the board. If we encounter a piece, add it to the
list of origin possibilities if it is the moving piece, or else
check the next direction.
From the destination square move in each direction stopping if we reach the end of the board . If we encounter a piece add it to the list of origin possibilities if it is the moving piece or else check the next direction .
def direction_origins
      directions    = DIRECTIONS[move.piece.downcase]
      possibilities = []
      directions.each do |dir|
        piece, square = first_piece(destination_coords, dir)
        possibilities << square if piece == self.move.piece
      end
      possibilities
    end
def direction_origins directions = DIRECTIONS [ move . piece . downcase ] possibilities = [ ] directions . each do | dir | piece , square = first_piece ( destination_coords , dir ) possibilities << square if piece == self . move . piece end possibilities end
From the destination square, move in each direction stopping if we
reach the end of the board.
From the destination square move in each direction stopping if we reach the end of the board .