Class: Player
- Inherits:
-
Object
- Object
- Player
- Defined in:
- lib/player.rb
Instance Attribute Summary collapse
-
#agility ⇒ Object
Returns the value of attribute agility.
-
#area ⇒ Object
Returns the value of attribute area.
-
#armour ⇒ Object
Returns the value of attribute armour.
-
#endurance ⇒ Object
Returns the value of attribute endurance.
-
#experience ⇒ Object
Returns the value of attribute experience.
-
#gold ⇒ Object
Returns the value of attribute gold.
-
#intelligence ⇒ Object
Returns the value of attribute intelligence.
-
#inventory ⇒ Object
Returns the value of attribute inventory.
-
#level ⇒ Object
Returns the value of attribute level.
-
#life ⇒ Object
Returns the value of attribute life.
-
#magic ⇒ Object
Returns the value of attribute magic.
-
#maps ⇒ Object
Returns the value of attribute maps.
-
#name ⇒ Object
Returns the value of attribute name.
-
#party ⇒ Object
Returns the value of attribute party.
-
#position ⇒ Object
Returns the value of attribute position.
-
#spells ⇒ Object
Returns the value of attribute spells.
-
#strength ⇒ Object
Returns the value of attribute strength.
-
#visited ⇒ Object
Returns the value of attribute visited.
-
#weapon ⇒ Object
Returns the value of attribute weapon.
Instance Method Summary collapse
- #armour_rating ⇒ Object
- #attribute ⇒ Object
-
#initialize(name, strength, endurance, agility, intelligence, level = 1, experience = 0, gold = 0) ⇒ Player
constructor
A new instance of Player.
Constructor Details
#initialize(name, strength, endurance, agility, intelligence, level = 1, experience = 0, gold = 0) ⇒ Player
Returns a new instance of Player.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/player.rb', line 6 def initialize (name, strength, endurance, agility, intelligence, level = 1, experience = 0, gold = 0) @name = name @strength = strength @endurance = endurance @agility = agility @intelligence = intelligence @life = endurance * 10 @magic = intelligence * 3 @experience = experience @level = level @inventory = ['potion'] @spells = ['fire'] @weapon = [] @armour = [] @gold = gold @area = [] @position = [] @maps = [] @party = [] @visited = [] end |
Instance Attribute Details
#agility ⇒ Object
Returns the value of attribute agility.
4 5 6 |
# File 'lib/player.rb', line 4 def agility @agility end |
#area ⇒ Object
Returns the value of attribute area.
4 5 6 |
# File 'lib/player.rb', line 4 def area @area end |
#armour ⇒ Object
Returns the value of attribute armour.
4 5 6 |
# File 'lib/player.rb', line 4 def armour @armour end |
#endurance ⇒ Object
Returns the value of attribute endurance.
4 5 6 |
# File 'lib/player.rb', line 4 def endurance @endurance end |
#experience ⇒ Object
Returns the value of attribute experience.
4 5 6 |
# File 'lib/player.rb', line 4 def experience @experience end |
#gold ⇒ Object
Returns the value of attribute gold.
4 5 6 |
# File 'lib/player.rb', line 4 def gold @gold end |
#intelligence ⇒ Object
Returns the value of attribute intelligence.
4 5 6 |
# File 'lib/player.rb', line 4 def intelligence @intelligence end |
#inventory ⇒ Object
Returns the value of attribute inventory.
4 5 6 |
# File 'lib/player.rb', line 4 def inventory @inventory end |
#level ⇒ Object
Returns the value of attribute level.
4 5 6 |
# File 'lib/player.rb', line 4 def level @level end |
#life ⇒ Object
Returns the value of attribute life.
4 5 6 |
# File 'lib/player.rb', line 4 def life @life end |
#magic ⇒ Object
Returns the value of attribute magic.
4 5 6 |
# File 'lib/player.rb', line 4 def magic @magic end |
#maps ⇒ Object
Returns the value of attribute maps.
4 5 6 |
# File 'lib/player.rb', line 4 def maps @maps end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/player.rb', line 4 def name @name end |
#party ⇒ Object
Returns the value of attribute party.
4 5 6 |
# File 'lib/player.rb', line 4 def party @party end |
#position ⇒ Object
Returns the value of attribute position.
4 5 6 |
# File 'lib/player.rb', line 4 def position @position end |
#spells ⇒ Object
Returns the value of attribute spells.
4 5 6 |
# File 'lib/player.rb', line 4 def spells @spells end |
#strength ⇒ Object
Returns the value of attribute strength.
4 5 6 |
# File 'lib/player.rb', line 4 def strength @strength end |
#visited ⇒ Object
Returns the value of attribute visited.
4 5 6 |
# File 'lib/player.rb', line 4 def visited @visited end |
#weapon ⇒ Object
Returns the value of attribute weapon.
4 5 6 |
# File 'lib/player.rb', line 4 def weapon @weapon end |
Instance Method Details
#armour_rating ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/player.rb', line 28 def = 0 self.armour.each do |armour| += (armour.) end return end |
#attribute ⇒ Object
36 37 38 39 40 |
# File 'lib/player.rb', line 36 def attribute {:strength => strength, :endurance => endurance, :agility => agility, :intelligence => intelligence}.each do |attribute, value| puts 'Your ' + attribute.to_s.capitalize + ' is ' + value.to_s end end |