Class: Gemwarrior::Arena

Inherits:
Object
  • Object
show all
Defined in:
lib/gemwarrior/arena.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Arena

Returns a new instance of Arena.



11
12
13
14
# File 'lib/gemwarrior/arena.rb', line 11

def initialize(options)
  self.world    = options.fetch(:world)
  self.player   = options.fetch(:player)
end

Instance Attribute Details

#playerObject

Returns the value of attribute player.



9
10
11
# File 'lib/gemwarrior/arena.rb', line 9

def player
  @player
end

#worldObject

Returns the value of attribute world.



9
10
11
# File 'lib/gemwarrior/arena.rb', line 9

def world
  @world
end

Instance Method Details

#startObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/gemwarrior/arena.rb', line 16

def start
  print_arena_intro

  monsters_vanquished = 0

  loop do
    monster = generate_monster
    battle = Battle.new({:world => self.world, :player => self.player, :monster => monster})
    battle.start(is_arena = true)

    monsters_vanquished += 1

    puts 'Do you wish to continue fighting in the Arena? (Y/N)'
    answer = gets.chomp.downcase

    case answer
    when 'yes', 'y'
      next
    else
      bonus_rox = monsters_vanquished * 25
      bonus_xp = monsters_vanquished * 10
      player.rox = player.rox + bonus_rox
      player.xp = player.xp + bonus_xp
      puts 'You decided you\'ve had enough of the exhausting Arena for one day and exit the main stage.'
      puts "You have gained #{bonus_rox} rox and #{bonus_xp} XP!"

      return print_arena_outro
    end
  end
end