Class: Player
- Inherits:
-
Object
- Object
- Player
- Defined in:
- lib/studio_game/rubynotes.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#health ⇒ Object
readonly
Returns the value of attribute health.
-
#name ⇒ Object
Returns the value of attribute name.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Instance Method Summary collapse
-
#initialize(name) ⇒ Player
constructor
A new instance of Player.
- #role_names ⇒ Object
Constructor Details
#initialize(name) ⇒ Player
Returns a new instance of Player.
89 90 91 92 93 |
# File 'lib/studio_game/rubynotes.rb', line 89 def initialize(name) @name = name.capitalize @health = rand(50..100) @role = role_names.sample end |
Instance Attribute Details
#health ⇒ Object (readonly)
Returns the value of attribute health.
86 87 88 |
# File 'lib/studio_game/rubynotes.rb', line 86 def health @health end |
#name ⇒ Object
Returns the value of attribute name.
87 88 89 |
# File 'lib/studio_game/rubynotes.rb', line 87 def name @name end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
86 87 88 |
# File 'lib/studio_game/rubynotes.rb', line 86 def role @role end |
Instance Method Details
#role_names ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/studio_game/rubynotes.rb', line 95 def role_names [ "Barbarian", "Bard", "Cleric", "Druid", "Fighter", "Monk", "Paladin", "Ranger", "Rogue", "Sorcerer", "Wizard", ] end |