lib/journey.rb
# Handles logic for reward after Hero wins a journey
Handles logic for reward after Hero wins a journey
Handles logic for reward after Hero wins a journey
def reward
    display_reward
    rewards = ["some bandages", "a weapon", "a piece of armor"]
    reward = rewards.sample
    case reward
    when "some bandages"
      hero.update(current_health: hero.max_health)
      puts "Found #{reward}. Your health is restored."
    when "a weapon"
      weapon_power = rand(1..5)
      hero.update(power: hero.power + weapon_power)
      puts "Found #{reward}. Power increased by #{weapon_power}."
    when "a piece of armor"
      armor_power = rand(1..10)
      hero.update(max_health: hero.max_health + armor_power)
      puts "Found #{reward}. Max health increased by #{armor_power}."
    end
    sleep(3)
  end
def reward display_reward rewards = [ "some bandages" , "a weapon" , "a piece of armor" ] reward = rewards . sample case reward when "some bandages" hero . update ( current_health : hero . max_health ) puts "Found #{reward}. Your health is restored." when "a weapon" weapon_power = rand ( 1 .. 5 ) hero . update ( power : hero . power + weapon_power ) puts "Found #{reward}. Power increased by #{weapon_power}." when "a piece of armor" armor_power = rand ( 1 .. 10 ) hero . update ( max_health : hero . max_health + armor_power ) puts "Found #{reward}. Max health increased by #{armor_power}." end sleep ( 3 ) end
Handles logic for reward after Hero wins a journey
Handles logic for reward after Hero wins a journey