Class: Wowr::Classes::InfoCharacter

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

Overview

Made up of two parts, character and charactertab

Direct Known Subclasses

FullCharacter

Instance Attribute Summary collapse

Attributes inherited from Character

#battle_group, #contribution, #gender, #gender_id, #guild, #guild_id, #guild_url, #klass, #klass_id, #last_login, #level, #name, #race, #race_id, #rank, #realm, #relevance, #search_rank, #season_games_played, #season_games_won, #team_rank, #url

Instance Method Summary collapse

Methods inherited from Character

#class_icon, #icon, #race_icon

Constructor Details

#initialize(sheet, api = nil) ⇒ InfoCharacter

It’s made up of two parts Don’t care about battlegroups yet I don’t think I can call stuff from the constructor?



158
159
160
161
162
163
164
165
166
167
# File 'lib/wowr/character.rb', line 158

def initialize(sheet, api = nil)
	@api = api
	
	character_info(sheet%'character')
	
	# Check if characterTab is defined. If not, the character have no infos on the armory (not logged since last armory wipe)
	raise Wowr::Exceptions::CharacterNoInfo.new(@name) if (sheet%'characterTab').nil?
	
	character_tab(sheet%'characterTab')
end

Instance Attribute Details

#agilityObject (readonly) Also known as: agi

character_tab



140
141
142
# File 'lib/wowr/character.rb', line 140

def agility
  @agility
end

#arena_teamsObject (readonly)

character_info



133
134
135
# File 'lib/wowr/character.rb', line 133

def arena_teams
  @arena_teams
end

#buffsObject (readonly)

Returns the value of attribute buffs.



148
149
150
# File 'lib/wowr/character.rb', line 148

def buffs
  @buffs
end

#char_urlObject (readonly)

character_info



133
134
135
# File 'lib/wowr/character.rb', line 133

def char_url
  @char_url
end

#debuffsObject (readonly)

Returns the value of attribute debuffs.



148
149
150
# File 'lib/wowr/character.rb', line 148

def debuffs
  @debuffs
end

#defensesObject (readonly)

Returns the value of attribute defenses.



148
149
150
# File 'lib/wowr/character.rb', line 148

def defenses
  @defenses
end

#factionObject (readonly)

character_info



133
134
135
# File 'lib/wowr/character.rb', line 133

def faction
  @faction
end

#faction_idObject (readonly)

character_info



133
134
135
# File 'lib/wowr/character.rb', line 133

def faction_id
  @faction_id
end

#healthObject (readonly)

character_tab



140
141
142
# File 'lib/wowr/character.rb', line 140

def health
  @health
end

#intellectObject (readonly) Also known as: int

character_tab



140
141
142
# File 'lib/wowr/character.rb', line 140

def intellect
  @intellect
end

#itemsObject (readonly)

Returns the value of attribute items.



148
149
150
# File 'lib/wowr/character.rb', line 148

def items
  @items
end

#known_titlesObject (readonly)

character_info



133
134
135
# File 'lib/wowr/character.rb', line 133

def known_titles
  @known_titles
end

#last_modifiedObject (readonly)

character_info



133
134
135
# File 'lib/wowr/character.rb', line 133

def last_modified
  @last_modified
end

#meleeObject (readonly)

Returns the value of attribute melee.



148
149
150
# File 'lib/wowr/character.rb', line 148

def melee
  @melee
end

#pointsObject (readonly)

character_info



133
134
135
# File 'lib/wowr/character.rb', line 133

def points
  @points
end

#professionsObject (readonly)

Returns the value of attribute professions.



148
149
150
# File 'lib/wowr/character.rb', line 148

def professions
  @professions
end

#pvpObject (readonly)

Returns the value of attribute pvp.



148
149
150
# File 'lib/wowr/character.rb', line 148

def pvp
  @pvp
end

#rangedObject (readonly)

Returns the value of attribute ranged.



148
149
150
# File 'lib/wowr/character.rb', line 148

def ranged
  @ranged
end

#resistancesObject (readonly)

Returns the value of attribute resistances.



148
149
150
# File 'lib/wowr/character.rb', line 148

def resistances
  @resistances
end

#second_barObject (readonly)

character_tab



140
141
142
# File 'lib/wowr/character.rb', line 140

def second_bar
  @second_bar
end

#spellObject (readonly)

Returns the value of attribute spell.



148
149
150
# File 'lib/wowr/character.rb', line 148

def spell
  @spell
end

#spiritObject (readonly) Also known as: spi

character_tab



140
141
142
# File 'lib/wowr/character.rb', line 140

def spirit
  @spirit
end

#staminaObject (readonly) Also known as: sta

character_tab



140
141
142
# File 'lib/wowr/character.rb', line 140

def stamina
  @stamina
end

#strengthObject (readonly) Also known as: str

character_tab



140
141
142
# File 'lib/wowr/character.rb', line 140

def strength
  @strength
end

#talent_specObject (readonly)

Returns the value of attribute talent_spec.



148
149
150
# File 'lib/wowr/character.rb', line 148

def talent_spec
  @talent_spec
end

#titleObject (readonly)

character_info



133
134
135
# File 'lib/wowr/character.rb', line 133

def title
  @title
end

Instance Method Details

#character_info(elem) ⇒ Object

<character

battleGroup="Conviction"
charUrl="r=Genjuros&amp;n=Jonlok"
class="Warlock"
classId="9"
faction="Horde"
factionId="1"
gender="Male"
genderId="0"
guildName=""
lastModified="12 February 2008"
level="41"
name="Jonlok"
prefix="" 
points="2270"
race="Orc"
raceId="2"
realm="Genjuros"
suffix=""/>


189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
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
# File 'lib/wowr/character.rb', line 189

def character_info(elem)
	# basic info
	@name	 			= elem[:name]
	@level 			= elem[:level].to_i
	@char_url 	= elem[:charUrl]
	
	@klass 			= elem[:class]
	@klass_id		= elem[:classId].to_i

	@gender 		= elem[:gender]
	@gender_id 	= elem[:genderId].to_i

	@race 			= elem[:race]
	@race_id 		= elem[:raceId].to_i
	
	@faction 		= elem[:faction]
	@faction_id = elem[:factionId].to_i
	
	@guild			= elem[:guildName] == "" ? nil : elem[:guildName]
	@guild_url	= elem[:guildUrl] == "" ? nil : elem[:guildUrl]
	
	@prefix			= elem[:prefix] == "" ? nil : elem[:prefix]
	@suffix			= elem[:suffix] == "" ? nil : elem[:suffix]
	
	@points     = elem[:points].to_i
	
	@realm			= elem[:realm]
	
	@battle_group = elem[:battleGroup]
	
	# format is February 11, 2008
	# except when it's korean, and then it's 2008년 5월 11일 (일)
	# tw is 2008&#24180;5&#26376;11&#26085; (2008年5月11日)
	# TODO: Datetime doesn't parse other languages nicely
	# 			Until then, just save it as a string
	begin
		@last_modified 	= elem[:lastModified] == "" ? nil : DateTime.parse(elem[:lastModified])
	rescue
		@last_modified 	= elem[:lastModified] == "" ? nil : elem[:lastModified]
	end
	#@last_modified = elem[:lastModified]#.to_time
	
	@arena_teams = []
	(elem/:arenaTeam).each do |arena_team|
		@arena_teams << ArenaTeam.new(arena_team)
	end
	
end

#character_tab(elem) ⇒ Object



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
# File 'lib/wowr/character.rb', line 238

def character_tab(elem)
	# <title value=""/>
	@title				= (elem%'title')[:value] == "" ? nil : (elem%'title')[:value]

	@known_titles = []

	@known_titles << @title if (@title)
	(elem%'knownTitles'/:title).each do |entry|
	  @known_titles << entry[:value] if (!@known_titles.include?(entry[:value]))
	end

	@health 		= (elem%'characterBars'%'health')[:effective].to_i
	@second_bar = SecondBar.new(elem%'characterBars'%'secondBar')
	
	# base stats
	@strength 	= Strength.new(elem%'baseStats'%'strength')
	@agility 		= Agility.new(elem%'baseStats'%'agility')
	@stamina 		= Stamina.new(elem%'baseStats'%'stamina')
	@intellect 	= Intellect.new(elem%'baseStats'%'intellect')
	@spirit 		= Spirit.new(elem%'baseStats'%'spirit')
	
	# damage stuff
	@melee 		= Melee.new(elem%'melee')
	@ranged 	= Ranged.new(elem%'ranged')
	@spell 		= Spell.new(elem.at(' > spell'))	# TODO: hacky?
	@defenses = Defenses.new(elem%'defenses')
	
	# TODO: Massive problem, doesn't fill in resistances for some reason
	resist_types = ['arcane', 'fire', 'frost', 'holy', 'nature', 'shadow']
	@resistances = {}
	resist_types.each do |res|
		@resistances[res] = Resistance.new(elem%'resistances'%res)
	end
	
	@talent_spec = TalentSpec.new(elem%'talentSpec')
	
	@pvp = Pvp.new(elem%'pvp')
					
	@professions = []
	(elem%'professions'/:skill).each do |skill|
		@professions << Skill.new(skill)
	end
	
	@items = []
	(elem%'items'/:item).each do |item|
		@items << EquippedItem.new(item, @api)
	end
	
	@buffs = []
	(elem%'buffs'/:spell).each do |buff|
		@buffs << Buff.new(buff, @api)
	end
	
	@debuffs = []
	(elem%'debuffs'/:spell).each do |debuff|
		@debuffs << Buff.new(debuff, @api)
	end
end