lib/GameApp.rb
# Allows player to load previous games (any living Hero)
Allows player to load previous games (any living Hero)
Allows player to load previous games ( any living Hero )
def load_game
    if Hero.count > 0
      living_heroes = Hero.where("current_health > ?", 0).order('id DESC')
      display_living_heroes = living_heroes
        .map { |h| "#{h.name} with Experience: #{h.experience} and Current Health: #{h.current_health}"}
      load_choice = @@prompt.select("Select the hero who's journey you want to continue", display_living_heroes)
      @hero = living_heroes.find_by(name: load_choice.split[0])
      current_game
    else
      display_no_heroes
      main_menu
    end
  end
def load_game if Hero . count > 0 living_heroes = Hero . where ( "current_health > ?" , 0 ) . order ( 'id DESC' ) display_living_heroes = living_heroes . map { | h | "#{h.name} with Experience: #{h.experience} and Current Health: #{h.current_health}" } load_choice = @@prompt . select ( "Select the hero who's journey you want to continue" , display_living_heroes ) @hero = living_heroes . find_by ( name : load_choice . split [ 0 ] ) current_game else display_no_heroes main_menu end end
Allows player to load previous games (any living Hero)
Allows player to load previous games ( any living Hero )