lib/pgn/move_calculator.rb
# Computes the possbile pawn origins based on the destination square
# and whether or not the move is a capture.
#
Computes the possbile pawn origins based on the destination square
and whether or not the move is a capture.
Computes the possbile pawn origins based on the destination square and whether or not the move is a capture .
def pawn_origins
      _, rank     = destination_coords
      double_rank = (rank == 3 && self.move.white?) || (rank == 4 && self.move.black?)
      pawn_moves = PAWN_MOVES[self.move.piece]
      moves = self.move.capture ? pawn_moves[:capture] : pawn_moves[:normal]
      moves += pawn_moves[:double] if double_rank
      move_origins(moves)
    end
def pawn_origins _ , rank = destination_coords double_rank = ( rank == 3 && self . move . white? ) || ( rank == 4 && self . move . black? ) pawn_moves = PAWN_MOVES [ self . move . piece ] moves = self . move . capture ? pawn_moves [ :capture ] : pawn_moves [ :normal ] moves += pawn_moves [ :double ] if double_rank move_origins ( moves ) end
Computes the possbile pawn origins based on the destination square
and whether or not the move is a capture.
Computes the possbile pawn origins based on the destination square and whether or not the move is a capture .