Class: Player

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#agilityObject

Returns the value of attribute agility.



4
5
6
# File 'lib/player.rb', line 4

def agility
  @agility
end

#areaObject

Returns the value of attribute area.



4
5
6
# File 'lib/player.rb', line 4

def area
  @area
end

#armourObject

Returns the value of attribute armour.



4
5
6
# File 'lib/player.rb', line 4

def armour
  @armour
end

#enduranceObject

Returns the value of attribute endurance.



4
5
6
# File 'lib/player.rb', line 4

def endurance
  @endurance
end

#experienceObject

Returns the value of attribute experience.



4
5
6
# File 'lib/player.rb', line 4

def experience
  @experience
end

#goldObject

Returns the value of attribute gold.



4
5
6
# File 'lib/player.rb', line 4

def gold
  @gold
end

#intelligenceObject

Returns the value of attribute intelligence.



4
5
6
# File 'lib/player.rb', line 4

def intelligence
  @intelligence
end

#inventoryObject

Returns the value of attribute inventory.



4
5
6
# File 'lib/player.rb', line 4

def inventory
  @inventory
end

#levelObject

Returns the value of attribute level.



4
5
6
# File 'lib/player.rb', line 4

def level
  @level
end

#lifeObject

Returns the value of attribute life.



4
5
6
# File 'lib/player.rb', line 4

def life
  @life
end

#magicObject

Returns the value of attribute magic.



4
5
6
# File 'lib/player.rb', line 4

def magic
  @magic
end

#mapsObject

Returns the value of attribute maps.



4
5
6
# File 'lib/player.rb', line 4

def maps
  @maps
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/player.rb', line 4

def name
  @name
end

#partyObject

Returns the value of attribute party.



4
5
6
# File 'lib/player.rb', line 4

def party
  @party
end

#positionObject

Returns the value of attribute position.



4
5
6
# File 'lib/player.rb', line 4

def position
  @position
end

#spellsObject

Returns the value of attribute spells.



4
5
6
# File 'lib/player.rb', line 4

def spells
  @spells
end

#strengthObject

Returns the value of attribute strength.



4
5
6
# File 'lib/player.rb', line 4

def strength
  @strength
end

#visitedObject

Returns the value of attribute visited.



4
5
6
# File 'lib/player.rb', line 4

def visited
  @visited
end

#weaponObject

Returns the value of attribute weapon.



4
5
6
# File 'lib/player.rb', line 4

def weapon
  @weapon
end

Instance Method Details

#armour_ratingObject



28
29
30
31
32
33
34
# File 'lib/player.rb', line 28

def armour_rating
	initial_rating = 0
	self.armour.each do |armour|
		initial_rating += (armour.rating)
	end
	return initial_rating
end

#attributeObject



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