Class: GamesParadise::MightAndMagic::Hero
- Defined in:
- lib/games_paradise/might_and_magic/hero.rb
Overview
GamesParadise::MightAndMagic::Hero
Direct Known Subclasses
GamesParadise::MightAndMagic::HeroTypes::Archer, GamesParadise::MightAndMagic::HeroTypes::Barbarian, GamesParadise::MightAndMagic::HeroTypes::Cleric, GamesParadise::MightAndMagic::HeroTypes::Druid, GamesParadise::MightAndMagic::HeroTypes::Fighter, GamesParadise::MightAndMagic::HeroTypes::Ninja, GamesParadise::MightAndMagic::HeroTypes::Paladin, GamesParadise::MightAndMagic::HeroTypes::Ranger, GamesParadise::MightAndMagic::HeroTypes::Rogue, GamesParadise::MightAndMagic::HeroTypes::Sorcerer
Constant Summary
Constants inherited from Character
Instance Attribute Summary collapse
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#hp ⇒ Object
Returns the value of attribute hp.
-
#level ⇒ Object
Returns the value of attribute level.
-
#n_attacks ⇒ Object
Returns the value of attribute n_attacks.
-
#name ⇒ Object
Returns the value of attribute name.
-
#race ⇒ Object
(also: #race?)
Returns the value of attribute race.
Instance Method Summary collapse
-
#initialize(name_of_the_class = nil, race_to_use = 'rand', hp_bonus = 0, number_of_attacks_per_round = 1) ⇒ Hero
constructor
# === initialize.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
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_paradise/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
#gender ⇒ Object
Returns the value of attribute gender.
19 20 21 |
# File 'lib/games_paradise/might_and_magic/hero.rb', line 19 def gender @gender end |
#hp ⇒ Object
Returns the value of attribute hp.
20 21 22 |
# File 'lib/games_paradise/might_and_magic/hero.rb', line 20 def hp @hp end |
#level ⇒ Object
Returns the value of attribute level.
24 25 26 |
# File 'lib/games_paradise/might_and_magic/hero.rb', line 24 def level @level end |
#n_attacks ⇒ Object
Returns the value of attribute n_attacks.
25 26 27 |
# File 'lib/games_paradise/might_and_magic/hero.rb', line 25 def n_attacks @n_attacks end |
#name ⇒ Object
Returns the value of attribute name.
21 22 23 |
# File 'lib/games_paradise/might_and_magic/hero.rb', line 21 def name @name end |
#race ⇒ Object Also known as: race?
Returns the value of attribute race.
22 23 24 |
# File 'lib/games_paradise/might_and_magic/hero.rb', line 22 def race @race end |
Instance Method Details
#reset ⇒ Object
#
reset (reset tag)
#
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/games_paradise/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 |