Class: Player

Inherits:
Object
  • Object
show all
Defined in:
lib/studio_game/rubynotes.rb

Direct Known Subclasses

BerserkPlayer

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#healthObject (readonly)

Returns the value of attribute health.



86
87
88
# File 'lib/studio_game/rubynotes.rb', line 86

def health
  @health
end

#nameObject

Returns the value of attribute name.



87
88
89
# File 'lib/studio_game/rubynotes.rb', line 87

def name
  @name
end

#roleObject (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_namesObject



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