# File lib/libttc.rb, line 448
  def possible_moves(die_result, player = @current_player)
    moves = []
    @pieces.each do |key, piece|
      # only move current player's pieces, and only if they're not captured
      if piece.colour == player and (not piece.captured)
        (@board.valid_moves[piece.position.place][die_result]).each do |destination|
          if destination.safe?
            if (@pieces.find_all {|k, p| p.position == destination}).length < 3
              moves << Move.new(piece, destination, false)
            end
          else
            moves << Move.new(piece, destination, false) unless destination.base?
          end
        end
        # if we can move to our base (but not already on it), add moves via that...
        if @board.distance_between[piece.position.place][player] <= die_result and 
            not piece.position.place == player and
            not piece.contains.empty?
          distance_after_base = die_result - board.distance_between[piece.position.place][player]
          (@board.valid_moves[player][distance_after_base]).each do |destination|
            if destination.safe?
              if (@pieces.find_all {|k, p| p.position == destination}).length < 3
                moves << Move.new(piece, destination, true)
              end
            else
              moves << Move.new(piece, destination, true)
            end
          end
        end
      end
    end
    moves
  end