lib/GameApp.rb
# Opens a leaderboard of heroes with the most journeys
Opens a leaderboard of heroes with the most journeys
Opens a leaderboard of heroes with the most journeys
def leader_board
    display_leaderboard
    unranked_hero_journey_count = Journey.group(:hero_id).count(:monster_id)
    leaderboard = Hash[unranked_hero_journey_count.sort_by{|k,v|v}.reverse[0..4]]
    leaderboard.each do |hero_id, journey_count|
      puts "  Name: #{Hero.find(hero_id).name}, Journeys: #{journey_count}"
    end
    puts "\n\n"
    selection = @@prompt.select("Back to Main Menu?", %w(Main\ Menu), cycle: true)
    main_menu if selection == "Main Menu"
  end
def leader_board display_leaderboard unranked_hero_journey_count = Journey . group ( :hero_id ) . count ( :monster_id ) leaderboard = Hash [ unranked_hero_journey_count . sort_by { | k , v | v } . reverse [ 0 .. 4 ] ] leaderboard . each do | hero_id , journey_count | puts "  Name: #{Hero.find(hero_id).name}, Journeys: #{journey_count}" end puts "\n\n" selection = @@prompt . select ( "Back to Main Menu?" , %w( Main\ Menu ) , cycle : true ) main_menu if selection == "Main Menu" end
Opens a leaderboard of heroes with the most journeys
Opens a leaderboard of heroes with the most journeys