Class: Wowr::Classes::ItemInfo

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

Overview

uses item-info.xml

Instance Attribute Summary collapse

Attributes inherited from Item

#icon_base, #id, #name

Instance Method Summary collapse

Methods inherited from Item

#icon

Constructor Details

#initialize(elem, api = nil) ⇒ ItemInfo

Returns a new instance of ItemInfo.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/wowr/item.rb', line 89

def initialize(elem, api = nil)
	super(elem, api)
	
	@level 		= elem[:level].to_i
	@quality 	= elem[:quality].to_i
	@type 		= elem[:type]
	
	# Cost can be in gold, or tokens
	@cost = ItemCost.new(elem%'cost') if (elem%'cost')
		
		
		
	# is costs really an array?
	#@costs 		= []
	#(elem/:cost).each do |cost|
	#	@costs << ItemCost.new(cost)
	#end
	
	etc = [
		['disenchantLoot', 		'@disenchant_items', 		'item', 		DisenchantItem, true],
		['objectiveOfQuests', '@objective_of_quests', 'quest', 		ItemQuest, false],
		['rewardFromQuests', 	'@reward_from_quests', 	'quest', 		ItemQuest, false],
		['vendors', 					'@vendors', 						'creature', ItemVendor, false],
		['dropCreatures', 		'@drop_creatures', 			'creature', ItemDropCreature, false],
		['plansFor', 					'@plans_for', 					'spell', 		ItemPlansFor, true],
		['createdBy', 				'@created_by', 					'spell', 		ItemCreatedBy, true],
	]
	
	etc.each do |b|
		ele = b[0]
		var = b[1]
		list = b[2]
		my_class = b[3]
		requires_api = b[4]
		
		if elem%ele
			tmp_arr = []
			(elem%ele/list).each do |x|
				if requires_api
					tmp_arr << my_class.new(x, api)
				else	
					tmp_arr << my_class.new(x)
				end
			end
			self.instance_variable_set(var, tmp_arr)
		end
	end
	
	if (elem%'disenchantLoot')
		@disenchant_skill_rank = (elem%'disenchantLoot')[:requiredSkillRank].to_i 
		
		# @disenchant_items = []
		# (elem%'disenchantLoot'/:item).each do |item|
		# 	@disenchant_items << DisenchantItem.new(item)
		# end
	end
		
	# if (elem%'objectiveOfQuests')
	# 	@objective_of_quests = []
	# 	(elem%'objectiveOfQuests'/:quest).each do |quest|
	# 		@objective_of_quests << ItemQuest.new(quest)
	# 	end
	# end
	# 		
	# if (elem%'rewardFromQuests')
	# 	@reward_from_quests = []
	# 	(elem%'rewardFromQuests'/:quest).each do |quest|
	# 		@reward_from_quests << ItemQuest.new(quest)
	# 	end
	# end
	# 
	# if (elem%'vendors')
	# 	@vendors = []
	# 	(elem%'vendors'/:creature).each do |vendor|
	# 		@vendors << ItemVendor.new(vendor)
	# 	end
	# end
	# 		
	# if (elem%'dropCreatures')
	# 	@drop_creatures = []
	# 	(elem%'dropCreatures'/:creature).each do |creature|
	# 		@drop_creatures << ItemDropCreature.new(creature)
	# 	end
	# end
	# 		
	# if (elem%'plansFor')
	# 	@plans_for = []
	# 	(elem%'plansFor'/:spell).each do |plan|
	# 		@plans_for << ItemPlansFor.new(plan)
	# 	end
	# end
	# 		
	# if (elem%'createdBy')
	# 	@created_by = []
	# 	(elem%'createdBy'/:spell).each do |c|
	# 		@created_by << ItemCreatedBy.new(c)
	# 	end
	# end
end

Instance Attribute Details

#costObject (readonly)

Returns the value of attribute cost.



80
81
82
# File 'lib/wowr/item.rb', line 80

def cost
  @cost
end

#created_byObject (readonly)

Returns the value of attribute created_by.



80
81
82
# File 'lib/wowr/item.rb', line 80

def created_by
  @created_by
end

#disenchant_itemsObject (readonly) Also known as: disenchants

Returns the value of attribute disenchant_items.



80
81
82
# File 'lib/wowr/item.rb', line 80

def disenchant_items
  @disenchant_items
end

#disenchant_skill_rankObject (readonly)

Returns the value of attribute disenchant_skill_rank.



80
81
82
# File 'lib/wowr/item.rb', line 80

def disenchant_skill_rank
  @disenchant_skill_rank
end

#drop_creaturesObject (readonly)

Returns the value of attribute drop_creatures.



80
81
82
# File 'lib/wowr/item.rb', line 80

def drop_creatures
  @drop_creatures
end

#levelObject (readonly)

Returns the value of attribute level.



80
81
82
# File 'lib/wowr/item.rb', line 80

def level
  @level
end

#objective_of_questsObject (readonly)

Returns the value of attribute objective_of_quests.



80
81
82
# File 'lib/wowr/item.rb', line 80

def objective_of_quests
  @objective_of_quests
end

#plans_forObject (readonly)

Returns the value of attribute plans_for.



80
81
82
# File 'lib/wowr/item.rb', line 80

def plans_for
  @plans_for
end

#qualityObject (readonly)

Returns the value of attribute quality.



80
81
82
# File 'lib/wowr/item.rb', line 80

def quality
  @quality
end

#reward_from_questsObject (readonly)

Returns the value of attribute reward_from_quests.



80
81
82
# File 'lib/wowr/item.rb', line 80

def reward_from_quests
  @reward_from_quests
end

#typeObject (readonly)

Returns the value of attribute type.



80
81
82
# File 'lib/wowr/item.rb', line 80

def type
  @type
end

#vendorsObject (readonly)

Returns the value of attribute vendors.



80
81
82
# File 'lib/wowr/item.rb', line 80

def vendors
  @vendors
end