Class: Wowr::Classes::ItemTooltip

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

Overview

Provides detailed item information Note that the item-tooltip.xml just returns an empty document when the item can’t be found.

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) ⇒ ItemTooltip

Returns a new instance of ItemTooltip.



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/wowr/item.rb', line 206

def initialize(elem, api = nil)
	super(elem, api)
	@id									= (elem%'id').html.to_i
	@name								= (elem%'name').html
	@icon_base					= (elem%'icon').html
	@desc								= (elem%'desc').html if (elem%'desc')
	@overall_quality_id	= (elem%'overallQualityId').html.to_i
	@bonding						= (elem%'bonding').html.to_i
	@stackable					= (elem%'stackable').html.to_i if (elem%'stackable')
	@max_count					= (elem%'maxCount').html.to_i if (elem%'maxCount')
	@class_id						= (elem%'classId').html.to_i
	@required_level			= (elem%'requiredLevel').html.to_i if (elem%'requiredLevel')
	
	@equipData					= ItemEquipData.new(elem%'equipData')
	
	# TODO: This appears to be a plain string at the moment
	#<gemProperties>+26 Healing +9 Spell Damage and 2% Reduced Threat</gemProperties>
	@gem_properties			= (elem%'gemProperties').html if (elem%'gemProperties')
	
	# not all items have damage data
	@damage							= ItemDamageData.new(elem%'damageData') if !(elem%'damageData').html.empty?
	
	
	# TODO: Test socket data with a variety of items
	# TODO: replace with socket Class?
	if (elem%'socketData')
		@sockets = []
		(elem%'socketData'/:socket).each do |socket|
			@sockets << socket[:color]
		end
		
		@socket_match_enchant = (elem%'socketData'%'socketMatchEnchant')
	end
	
	
	# When there is no data, stats are not present in @bonuses
	# TODO: When there is no stats at all, @bonuses shouldn't be set
	@bonuses = {}
	
	bonus_stats = {
		:strength => :bonusStrength,
		:agility => :bonusAgility,
		:stamina => :bonusStamina,
		:intellect => :bonusIntellect,
		:spirit => :bonusSpirit
	}
	bonus_stats.each do |stat, xml_elem|
		@bonuses[stat] = test_stat(elem/xml_elem) if test_stat(elem/xml_elem)
	end
	
	# Resistances
	@resistances = {}
	
	resist_stats = {
		:arcane => :arcaneResist,
		:fire => :fireResist,
		:frost => :frostResist,
		:holy => :holyResist,
		:nature => :natureResist,
		:shadow => :shadowResist
	}
	resist_stats.each do |stat, xml_elem|
		@resistances[stat] = test_stat(elem/xml_elem) if test_stat(elem/xml_elem)
	end
	
	
	if (elem%'allowableClasses')
		@allowable_classes = []
		(elem%'allowableClasses'/:class).each do |klass|
			@allowable_classes << klass.html
		end
	end
	
	# NOTE not representing armor bonus
	@armor			= (elem%'armor').html.to_i 						if (elem%'armor')
	
	# NOTE not representing max
	@durability	= (elem%'durability')[:current].to_i	if (elem%'durability')
	
	if (elem%'spellData')
		@spells = []
		(elem%'spellData'/:spell).each do |spell|
			@spells << ItemSpell.new(spell)
		end
	end
	
	@setData = ItemSetData.new(elem%'setData') if (elem%'setData')
		
	# @item_sources = []
	# (elem/:itemSource).each do |source|
	# 	@item_sources << ItemSource.new(source)
	# end
	@item_source = ItemSource.new(elem%'itemSource') if (elem%'itemSource')	 # TODO: More than once source?
end

Instance Attribute Details

#allowable_classesObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def allowable_classes
  @allowable_classes
end

#armorObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def armor
  @armor
end

#bondingObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def bonding
  @bonding
end

#bonusesObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def bonuses
  @bonuses
end

#class_idObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def class_id
  @class_id
end

#descObject (readonly) Also known as: description

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def desc
  @desc
end

#durabilityObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def durability
  @durability
end

#gem_propertiesObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def gem_properties
  @gem_properties
end

#item_sourceObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def item_source
  @item_source
end

#max_countObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def max_count
  @max_count
end

#overall_quality_idObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def overall_quality_id
  @overall_quality_id
end

#required_levelObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def required_level
  @required_level
end

#resistancesObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def resistances
  @resistances
end

#socket_match_enchantObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def socket_match_enchant
  @socket_match_enchant
end

#socketsObject (readonly)

:id, :name, :icon,



196
197
198
# File 'lib/wowr/item.rb', line 196

def sockets
  @sockets
end