Class: Wowr::Classes::Dungeon

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elem) ⇒ Dungeon

Returns a new instance of Dungeon.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/wowr/dungeon.rb', line 24

def initialize(elem)				
	@id							= elem[:id].to_i
	@key						= elem[:key]
	@level_minimum	= elem[:levelMin].to_i
	@level_maximum	= elem[:levelMax].to_i
	@party_size			= elem[:partySize].to_i
	@raid						= (elem[:raid].to_i == 1) ? true : false
	@release				= elem[:release].to_i
	@heroic					= (elem[:hasHeroic].to_i == 1) ? true : false
	
	# Ideally want to be able to get the boss by both ID and key
	#	but by using normal hash.
	# After a test it seems the method below creates 2 references to an object.
	@bosses = {}
	
	(elem/:boss).each do |elem|
		# TODO: Is this insane?
		#				After object test, appears this will be references to the same object
		boss = Boss.new(elem)
		@bosses[boss.id]	= boss	if boss.id
		@bosses[boss.key]	= boss	if boss.key
	end
end

Instance Attribute Details

#bossesObject (readonly)

Returns the value of attribute bosses.



14
15
16
# File 'lib/wowr/dungeon.rb', line 14

def bosses
  @bosses
end

#heroicObject (readonly)

Returns the value of attribute heroic.



14
15
16
# File 'lib/wowr/dungeon.rb', line 14

def heroic
  @heroic
end

#idObject (readonly) Also known as: to_i

Returns the value of attribute id.



14
15
16
# File 'lib/wowr/dungeon.rb', line 14

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



14
15
16
# File 'lib/wowr/dungeon.rb', line 14

def key
  @key
end

#level_maximumObject (readonly) Also known as: max_level

Returns the value of attribute level_maximum.



14
15
16
# File 'lib/wowr/dungeon.rb', line 14

def level_maximum
  @level_maximum
end

#level_minimumObject (readonly) Also known as: min_level

Returns the value of attribute level_minimum.



14
15
16
# File 'lib/wowr/dungeon.rb', line 14

def level_minimum
  @level_minimum
end

#nameObject (readonly) Also known as: to_s

Returns the value of attribute name.



14
15
16
# File 'lib/wowr/dungeon.rb', line 14

def name
  @name
end

#party_sizeObject (readonly)

Returns the value of attribute party_size.



14
15
16
# File 'lib/wowr/dungeon.rb', line 14

def party_size
  @party_size
end

#raidObject (readonly)

Returns the value of attribute raid.



14
15
16
# File 'lib/wowr/dungeon.rb', line 14

def raid
  @raid
end

#releaseObject (readonly)

Returns the value of attribute release.



14
15
16
# File 'lib/wowr/dungeon.rb', line 14

def release
  @release
end

Instance Method Details

#add_name_data(elem) ⇒ Object

Add the name data from dungeonStrings.xml



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/wowr/dungeon.rb', line 49

def add_name_data(elem)
	# puts elem.raw_string.to_yaml
	@name = elem.attributes["name"]
	
	(elem/:boss).each do |boss_elem|
		id = boss_elem[:id].to_i
		key = boss_elem[:key]
		
		@bosses[id].add_name_data(boss_elem)	if id
		@bosses[key].add_name_data(boss_elem)	if key
	end
end