Class: Gemwarrior::Arena

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

Constant Summary collapse

BONUS_ROX_MULTIPLIER =

CONSTANTS

25
BONUS_XP_MULTIPLIER =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Arena

Returns a new instance of Arena.



14
15
16
17
# File 'lib/gemwarrior/arena.rb', line 14

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

Instance Attribute Details

#playerObject

Returns the value of attribute player.



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

def player
  @player
end

#worldObject

Returns the value of attribute world.



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

def world
  @world
end

Instance Method Details

#startObject



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
46
47
48
49
50
51
52
53
# File 'lib/gemwarrior/arena.rb', line 19

def start
  print_arena_intro

  arena_monsters_vanquished = 0

  loop do
    monster = generate_monster
    battle = Battle.new(world: world, player: player, monster: monster)
    result = battle.start(is_arena: true)

    return 'death' if result.eql?('death')

    arena_monsters_vanquished += 1

    print '  Do you wish to continue fighting in the Arena? (y/n) '
    answer = gets.chomp.downcase

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

      return print_arena_outro
    end
  end
end