Class: GamesAndRpgParadise::MightAndMagic::Hero

Inherits:
Character
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/games/might_and_magic/hero.rb

Overview

GamesParadise::MightAndMagic::Hero

Constant Summary

Constants inherited from Character

Character::AVAILABLE_RACES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Character

#alive=, #alive?, #do_die, #hero_type?, #select_random_race, #set_age, #set_gender, #set_hero_type, #set_level, #set_number_of_attacks

Constructor Details

#initialize(name_of_the_class = nil, race_to_use = 'rand', hp_bonus = 0, number_of_attacks_per_round = 1) ⇒ Hero

#

initialize

The constructor has to accept at the least four arguments:

(1) Name
(2) Race
(3) HP Bonus (or base hp)
(4) Attacks per round
#


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/games_and_rpg_paradise/games/might_and_magic/hero.rb', line 52

def initialize(
    name_of_the_class           = nil,
    race_to_use                 = 'rand',
    hp_bonus                    = 0,
    number_of_attacks_per_round = 1
  )
  reset
  if name_of_the_class
    set_hero_type(name_of_the_class)
  end
  if race_to_use
    @race = race_to_use
  end
  if hp_bonus
    @hp = 10+rand(2)+hp_bonus.to_i # default is 0 für Sorcerer
  end
  if number_of_attacks_per_round
    set_number_of_attacks(number_of_attacks_per_round)
  end
end

Instance Attribute Details

#genderObject

Returns the value of attribute gender.



19
20
21
# File 'lib/games_and_rpg_paradise/games/might_and_magic/hero.rb', line 19

def gender
  @gender
end

#hpObject

Returns the value of attribute hp.



20
21
22
# File 'lib/games_and_rpg_paradise/games/might_and_magic/hero.rb', line 20

def hp
  @hp
end

#levelObject

Returns the value of attribute level.



24
25
26
# File 'lib/games_and_rpg_paradise/games/might_and_magic/hero.rb', line 24

def level
  @level
end

#n_attacksObject

Returns the value of attribute n_attacks.



25
26
27
# File 'lib/games_and_rpg_paradise/games/might_and_magic/hero.rb', line 25

def n_attacks
  @n_attacks
end

#nameObject

Returns the value of attribute name.



21
22
23
# File 'lib/games_and_rpg_paradise/games/might_and_magic/hero.rb', line 21

def name
  @name
end

#raceObject Also known as: race?

Returns the value of attribute race.



22
23
24
# File 'lib/games_and_rpg_paradise/games/might_and_magic/hero.rb', line 22

def race
  @race
end

Instance Method Details

#resetObject

#

reset (reset tag)

#


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/games_and_rpg_paradise/games/might_and_magic/hero.rb', line 76

def reset
  # ======================================================================= #
  # === @name
  # ======================================================================= #
  @name = RpgParadise.generate_name('westreich',1)
  # ======================================================================= #
  # === @hp
  # ======================================================================= #
  @hp = 10+rand(2) # hp_bonus.to_i # default is 0 für Sorcerer
  set_gender(:random)
  set_hero_type(:random)
  @race = 'rand' # other races?
  select_random_race if @race == 'rand'
  set_age(:random)
  set_number_of_attacks(1)
  set_level(rand(15)) # temporary for now.
end