Class: Wowr::Classes::FullCharacter

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

Overview

Full character details uses characterInfo element Made up of two parts, character and charactertab

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, skills, reputation, api = nil) ⇒ FullCharacter

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



164
165
166
167
168
169
170
171
# File 'lib/wowr/character.rb', line 164

def initialize(sheet, skills, reputation, api = nil)
	@api = api
	
	character_info(sheet%'character')
	character_tab(sheet%'characterTab')
	character_skills(skills)
	character_reputation(reputation)
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



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

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



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

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



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

def faction
  @faction
end

#faction_idObject (readonly)

character_info



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

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

#last_modifiedObject (readonly)

character_info



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

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

#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

#reputation_categoriesObject (readonly) Also known as: rep, reputation

Returns the value of attribute reputation_categories.



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

def reputation_categories
  @reputation_categories
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

#skill_categoriesObject (readonly) Also known as: skills

Returns the value of attribute skill_categories.



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

def skill_categories
  @skill_categories
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



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

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="" 
race="Orc"
raceId="2"
realm="Genjuros"
suffix=""/>


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

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]
	
	@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_reputation(elem) ⇒ Object

character-reputation.xml



304
305
306
307
308
309
# File 'lib/wowr/character.rb', line 304

def character_reputation(elem)
	@reputation_categories = {}
	(elem/:factionCategory).each do |category|
		@reputation_categories[category[:key]] = RepFactionCategory.new(category)
	end
end

#character_skills(elem) ⇒ Object

character-skills.xml



296
297
298
299
300
301
# File 'lib/wowr/character.rb', line 296

def character_skills(elem)
	@skill_categories = {}
	(elem/:skillCategory).each do |category|
		@skill_categories[category[:key]] = SkillCategory.new(category)
	end
end

#character_tab(elem) ⇒ Object



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

def character_tab(elem)
	
	# <title value=""/>
	@title				= (elem%'title')[:value] == "" ? nil : (elem%'title')[:value]
	#@known_titles = <knownTitles/>
	
	@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')
					
	# Also accessible from
	# character.skills['professions']
	@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