line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::WoW::Armory; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
108207
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
79
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
67
|
|
5
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
214
|
|
6
|
2
|
|
|
2
|
|
11
|
use base qw(Class::Accessor::Fast); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10728
|
|
7
|
2
|
|
|
2
|
|
37068
|
use LWP::UserAgent; |
|
2
|
|
|
|
|
334450
|
|
|
2
|
|
|
|
|
86
|
|
8
|
2
|
|
|
2
|
|
2542
|
use XML::Simple; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Data::Dumper; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( |
12
|
|
|
|
|
|
|
qw(character url team guild) |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.0.7'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Games::WoW::Armory - Access to the WoW Armory |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Games::WoW::Armory; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $armory = Games::WoW::Armory->new(); |
27
|
|
|
|
|
|
|
$armory->search_character( { realm => 'Elune', |
28
|
|
|
|
|
|
|
character => 'Aarnn', |
29
|
|
|
|
|
|
|
country => 'EU } ); |
30
|
|
|
|
|
|
|
print $armory->character->name; |
31
|
|
|
|
|
|
|
print $armory->character->race; |
32
|
|
|
|
|
|
|
print $armory->character->level; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 METHOD |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head3 fetch_data |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Fetch the data, and store the result in $self->{data} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head3 search_character |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Search a character. Required params: |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
realm | character | country |
45
|
|
|
|
|
|
|
realm : name of the realm |
46
|
|
|
|
|
|
|
character : name of a character |
47
|
|
|
|
|
|
|
country : name of the country (EU|US) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
List of accessor for character: |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=over 4 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item * name: character name |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item * guildName: guild name |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item * arenaTeams: list of teams the character is in. Each team in the array is a Games::WoW::Armory::Team object |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
foreach my $team (@{$armory->character->arenaTeams}){ |
61
|
|
|
|
|
|
|
print $team->name; |
62
|
|
|
|
|
|
|
foreach my $char (@{$team}){ |
63
|
|
|
|
|
|
|
print $char->name . " " . $char->race; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * battleGroup: the battlegroup name |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * realm: realm name |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * race: race name |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item * gender: gender of the character |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item * faction: faction the character belongs to |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * level: level of the character |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item * lastModified: |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * title: highest rank in the old PVP mode |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * class: class name |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * rank: rank |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * teamRank: rank in the team |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * seasonGamesPlayed: number of games played in the current season |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * seasonGamesWon: number of games win in the current season |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * heroic_access: list of heroic access for the character |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
foreach my $key ( @{ $armory->character->heroic_access } ) { |
98
|
|
|
|
|
|
|
print "Have access to the $key.\n"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * characterinfo: a hash with lot of informations about the character |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * skill: a hash with all the skill reputation |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * reputation: a hash with all the character reputation |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=back |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head3 get_arena_teams |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Get arena teams for a player |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head3 get_reputation |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Get reputation for a player |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head3 search_guild |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Search for a guild. required params : |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
realm | guild | country |
123
|
|
|
|
|
|
|
realm : name of the realm |
124
|
|
|
|
|
|
|
guild : name of the guild |
125
|
|
|
|
|
|
|
country : name of the country (EU|US) |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
List of accessor for guild: |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=over 4 |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * realm: name of the realm |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * name: name of the guild |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * battleGroup: name of the battleGroup |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * members: array with all the member. Each member is a Games::WoW::Armory::Character object. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
foreach my $member (@{$armory->guild->members}){ |
142
|
|
|
|
|
|
|
print $member->name; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head3 search_team |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Search for a team. required params : |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
team | ts | battlegroup | country |
150
|
|
|
|
|
|
|
battlegroup : name of the battlegroup |
151
|
|
|
|
|
|
|
ts : type (2vs2 | 3vs3 | 5vs5) juste the number (eg: ts => 5) |
152
|
|
|
|
|
|
|
team : name of the team |
153
|
|
|
|
|
|
|
country : name of the country (EU|US) |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
List of accessor for team: |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=over 4 |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * seasonGamesPlayed: number of games played this season |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * rating: |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * size: number of members in the team |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * battleGroup: name of the battlegroup |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * realm: name of the realm |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * lastSeasonRanking: ranking in the last season |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * factionId: faction ID, 0 for alliance, 1 for Horde |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item * ranking: |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * name: name of the team |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * relevance: |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * seasonGamesWon: number of games won |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * members: team members in an array, all the members are a Games::WoW::Armory::Character object |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
foreach my $member (@{$armory->team->members}){ |
186
|
|
|
|
|
|
|
print $member->name; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head3 get_heroic_access |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Store in $self->character->heroic_access the list of keys the user can buy for the instances in heroic mode. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
our $WOW_EUROPE = "http://eu.wowarmory.com/"; |
196
|
|
|
|
|
|
|
our $WOW_US = 'http://www.wowarmory.com/'; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
our $HEROIC_REPUTATIONS = { |
199
|
|
|
|
|
|
|
"Keepers of Time" => "Key of Time", |
200
|
|
|
|
|
|
|
"Lower City" => "Auchenai Key", |
201
|
|
|
|
|
|
|
"The Sha'tar" => "Warpforged Key", |
202
|
|
|
|
|
|
|
"Honor Hold" => "Flamewrought Key", |
203
|
|
|
|
|
|
|
"Thrallmar" => "Flamewrought Key", |
204
|
|
|
|
|
|
|
"Cenarion Expedition" => "Reservoir Key", |
205
|
|
|
|
|
|
|
}; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub fetch_data { |
208
|
|
|
|
|
|
|
my ( $self, $params ) = @_; |
209
|
|
|
|
|
|
|
$self->{ ua } = LWP::UserAgent->new() || croak $!; |
210
|
|
|
|
|
|
|
$self->{ ua }->agent( |
211
|
|
|
|
|
|
|
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1" |
212
|
|
|
|
|
|
|
); |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
my $base_url; |
215
|
|
|
|
|
|
|
if ( $$params{ country } =~ /eu/i ) { |
216
|
|
|
|
|
|
|
$base_url = $WOW_EUROPE; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
elsif ( $$params{ country } =~ /us/i ) { |
219
|
|
|
|
|
|
|
$base_url = $WOW_US; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
else { |
222
|
|
|
|
|
|
|
croak "Unknow region code, please choose US or EU"; |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
if ( defined $$params{ team } ) { |
226
|
|
|
|
|
|
|
$self->url( $base_url |
227
|
|
|
|
|
|
|
. $$params{ xml } . "?r=" |
228
|
|
|
|
|
|
|
. $$params{ realm } . "&ts=" |
229
|
|
|
|
|
|
|
. $$params{ ts } . "&t=" |
230
|
|
|
|
|
|
|
. $$params{ team } ); |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
else { |
234
|
|
|
|
|
|
|
$self->url( $base_url |
235
|
|
|
|
|
|
|
. $$params{ xml } . "?r=" |
236
|
|
|
|
|
|
|
. $$params{ realm } . "&n=" |
237
|
|
|
|
|
|
|
. $$params{ name } ); |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
$self->{ resultat } = $self->{ ua }->get( $self->url ); |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
$self->{ xp } = XML::Simple->new; |
244
|
|
|
|
|
|
|
$self->{ data } = $self->{ xp }->XMLin( $self->{ resultat }->content ); |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub search_character { |
248
|
|
|
|
|
|
|
my ( $self, $params ) = @_; |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
my $xml = 'character-sheet.xml'; |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
croak "you need to specify a character name" |
253
|
|
|
|
|
|
|
unless defined $$params{ character }; |
254
|
|
|
|
|
|
|
croak "you need to specify a realm" unless defined $$params{ realm }; |
255
|
|
|
|
|
|
|
croak "you need to specify a country name" |
256
|
|
|
|
|
|
|
unless defined $$params{ country }; |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
$self->fetch_data( |
259
|
|
|
|
|
|
|
{ xml => $xml, |
260
|
|
|
|
|
|
|
realm => $$params{ realm }, |
261
|
|
|
|
|
|
|
name => $$params{ character }, |
262
|
|
|
|
|
|
|
country => $$params{ country } |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
); |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
my $character = $self->{ data }{ characterInfo }{ character }; |
267
|
|
|
|
|
|
|
my $skill = $self->{ data }{ characterInfo }{ skillTab }; |
268
|
|
|
|
|
|
|
my $characterinfo = $self->{ data }{ characterInfo }{ characterTab }; |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
$self->character( Games::WoW::Armory::Character->new ); |
271
|
|
|
|
|
|
|
$self->character->name( $$character{ name } ); |
272
|
|
|
|
|
|
|
$self->character->class( $$character{ class } ); |
273
|
|
|
|
|
|
|
$self->character->guildName( $$character{ guildName } ); |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
$self->character->battleGroup( $$character{ battleGroup } ); |
276
|
|
|
|
|
|
|
$self->character->realm( $$character{ realm } ); |
277
|
|
|
|
|
|
|
$self->character->race( $$character{ race } ); |
278
|
|
|
|
|
|
|
$self->character->gender( $$character{ gender } ); |
279
|
|
|
|
|
|
|
$self->character->faction( $$character{ faction } ); |
280
|
|
|
|
|
|
|
$self->character->level( $$character{ level } ); |
281
|
|
|
|
|
|
|
$self->character->lastModified( $$character{ lastModified } ); |
282
|
|
|
|
|
|
|
$self->character->title( $$character{ title } ); |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
$self->character->skill( $skill ); |
285
|
|
|
|
|
|
|
$self->character->characterinfo( $characterinfo ); |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
# Reputation information requires a separate XML file. |
288
|
|
|
|
|
|
|
$self->get_reputation( $params ); |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
$self->get_arena_teams( $params ); |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
sub get_reputation { |
294
|
|
|
|
|
|
|
my ( $self, $params ) = @_; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
my $xml = 'character-reputation.xml'; |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
croak "you need to specify a character name" |
299
|
|
|
|
|
|
|
unless defined $$params{ character }; |
300
|
|
|
|
|
|
|
croak "you need to specify a realm" unless defined $$params{ realm }; |
301
|
|
|
|
|
|
|
croak "you need to specify a country name" |
302
|
|
|
|
|
|
|
unless defined $$params{ country }; |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
$self->fetch_data( |
305
|
|
|
|
|
|
|
{ xml => $xml, |
306
|
|
|
|
|
|
|
realm => $$params{ realm }, |
307
|
|
|
|
|
|
|
name => $$params{ character }, |
308
|
|
|
|
|
|
|
country => $$params{ country } |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
); |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
my $reputation = $self->{ data }{ characterInfo }{ reputationTab }; |
313
|
|
|
|
|
|
|
$self->character->reputation( $reputation ); |
314
|
|
|
|
|
|
|
$self->get_heroic_access; |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
sub get_arena_teams { |
318
|
|
|
|
|
|
|
my ( $self, $params ) = @_; |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
my $xml = 'character-arenateams.xml'; |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
croak "you need to specify a character name" |
323
|
|
|
|
|
|
|
unless defined $$params{ character }; |
324
|
|
|
|
|
|
|
croak "you need to specify a realm" unless defined $$params{ realm }; |
325
|
|
|
|
|
|
|
croak "you need to specify a country name" |
326
|
|
|
|
|
|
|
unless defined $$params{ country }; |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
$self->fetch_data( |
329
|
|
|
|
|
|
|
{ xml => $xml, |
330
|
|
|
|
|
|
|
realm => $$params{ realm }, |
331
|
|
|
|
|
|
|
name => $$params{ character }, |
332
|
|
|
|
|
|
|
country => $$params{ country } |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
); |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
my $arena_team |
337
|
|
|
|
|
|
|
= $self->{data}{characterInfo}{character}{arenaTeams}{arenaTeam}; |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
# XML::Simple will not divide team information up into keys |
340
|
|
|
|
|
|
|
# (based on team name) unless the character is a member of more |
341
|
|
|
|
|
|
|
# than one team. The following logic tries to figure this out: |
342
|
|
|
|
|
|
|
my @teams = ( exists $$arena_team{name} ) |
343
|
|
|
|
|
|
|
? ( $arena_team ) |
344
|
|
|
|
|
|
|
: map { $$arena_team{$_} } keys %{$arena_team}; |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
my @team_objs; |
347
|
|
|
|
|
|
|
foreach my $team ( @teams ){ |
348
|
|
|
|
|
|
|
my $t = Games::WoW::Armory::Team->new; |
349
|
|
|
|
|
|
|
$t->name($$team{name}); |
350
|
|
|
|
|
|
|
$t->seasonGamesPlayed($$team{seasonGamesPlayed}); |
351
|
|
|
|
|
|
|
$t->size($$team{size}); |
352
|
|
|
|
|
|
|
$t->rating($$team{rating}); |
353
|
|
|
|
|
|
|
$t->battleGroup($$team{battleGroup}); |
354
|
|
|
|
|
|
|
$t->realm($$team{realm}); |
355
|
|
|
|
|
|
|
$t->lastSeasonRanking($$team{lastSeasonRanking}); |
356
|
|
|
|
|
|
|
$t->factionId($$team{factionId}); |
357
|
|
|
|
|
|
|
$t->ranking($$team{ranking}); |
358
|
|
|
|
|
|
|
$t->seasonGamesWon($$team{seasonGamesWon}); |
359
|
|
|
|
|
|
|
my @members; |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
my $members = $$team{members}{character}; |
362
|
|
|
|
|
|
|
foreach my $member (keys %{$members}){ |
363
|
|
|
|
|
|
|
my $m = Games::WoW::Armory::Character->new; |
364
|
|
|
|
|
|
|
$m->name($member); |
365
|
|
|
|
|
|
|
$m->race($$members{$member}{race}); |
366
|
|
|
|
|
|
|
$m->seasonGamesPlayed($$members{$member}{seasonGamesPlayed}); |
367
|
|
|
|
|
|
|
$m->teamRank($$members{$member}{teamRank}); |
368
|
|
|
|
|
|
|
$m->race($$members{$member}{race}); |
369
|
|
|
|
|
|
|
$m->gender($$members{$member}{gender}); |
370
|
|
|
|
|
|
|
$m->seasonGamesWon($$members{$member}{seasonGamesWon}); |
371
|
|
|
|
|
|
|
$m->guildName($$members{$member}{guild}); |
372
|
|
|
|
|
|
|
$m->class($$members{$member}{class}); |
373
|
|
|
|
|
|
|
push @members, $m; |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
$t->members(\@members); |
376
|
|
|
|
|
|
|
push @team_objs, $t; |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
$self->character->arenaTeams( \@team_objs ); |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
sub search_guild { |
382
|
|
|
|
|
|
|
my ( $self, $params ) = @_; |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
my $xml = "guild-info.xml"; |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
croak "you need to specify a guild name" unless defined $$params{ guild }; |
387
|
|
|
|
|
|
|
croak "you need to specify a realm" unless defined $$params{ realm }; |
388
|
|
|
|
|
|
|
croak "you need to specify a country name" |
389
|
|
|
|
|
|
|
unless defined $$params{ country }; |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
$self->fetch_data( |
392
|
|
|
|
|
|
|
{ xml => $xml, |
393
|
|
|
|
|
|
|
realm => $$params{ realm }, |
394
|
|
|
|
|
|
|
name => $$params{ guild }, |
395
|
|
|
|
|
|
|
country => $$params{ country } |
396
|
|
|
|
|
|
|
} |
397
|
|
|
|
|
|
|
); |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
$self->guild( Games::WoW::Armory::Guild->new ); |
400
|
|
|
|
|
|
|
my $guild = $self->{ data }{ guildInfo }{ guild }; |
401
|
|
|
|
|
|
|
my $members |
402
|
|
|
|
|
|
|
= $self->{ data }{ guildInfo }{ guild }{ members }{ character }; |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
$self->guild->name( $$guild{ name } ); |
405
|
|
|
|
|
|
|
$self->guild->battleGroup( $$guild{ battleGroup } ); |
406
|
|
|
|
|
|
|
$self->guild->realm( $$guild{ realm } ); |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
my @members; |
409
|
|
|
|
|
|
|
foreach my $member ( keys %{ $members } ) { |
410
|
|
|
|
|
|
|
my $m = Games::WoW::Armory::Character->new; |
411
|
|
|
|
|
|
|
$m->name( $member ); |
412
|
|
|
|
|
|
|
$m->level( $$members{ $member }{ level } ); |
413
|
|
|
|
|
|
|
$m->race( $$members{ $member }{ race } ); |
414
|
|
|
|
|
|
|
$m->class( $$members{ $member }{ class } ); |
415
|
|
|
|
|
|
|
$m->rank( $$members{ $member }{ rank } ); |
416
|
|
|
|
|
|
|
$m->gender( $$members{ $member }{ gender } ); |
417
|
|
|
|
|
|
|
push @members, $m; |
418
|
|
|
|
|
|
|
} |
419
|
|
|
|
|
|
|
$self->guild->members( \@members ); |
420
|
|
|
|
|
|
|
} |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
sub search_team { |
423
|
|
|
|
|
|
|
my ( $self, $params ) = @_; |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
my $xml = "team-info.xml"; |
426
|
|
|
|
|
|
|
croak "you need to specify a team name" unless defined $$params{ team }; |
427
|
|
|
|
|
|
|
croak "you need to specify a country name" |
428
|
|
|
|
|
|
|
unless defined $$params{ country }; |
429
|
|
|
|
|
|
|
croak "you need to specify a team style" unless defined $$params{ ts }; |
430
|
|
|
|
|
|
|
croak "you need to specify a realm name" |
431
|
|
|
|
|
|
|
unless defined $$params{ realm }; |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
$self->fetch_data( |
434
|
|
|
|
|
|
|
{ xml => $xml, |
435
|
|
|
|
|
|
|
team => $$params{ team }, |
436
|
|
|
|
|
|
|
realm => $$params{ realm }, |
437
|
|
|
|
|
|
|
ts => $$params{ ts }, |
438
|
|
|
|
|
|
|
country => $$params{ country } |
439
|
|
|
|
|
|
|
} |
440
|
|
|
|
|
|
|
); |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
my $arena_team = $self->{ data }{ teamInfo }{ arenaTeam }; |
443
|
|
|
|
|
|
|
my $members |
444
|
|
|
|
|
|
|
= $self->{ data }{ teamInfo }{ arenaTeam }{ members }{ character }; |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
$self->team( Games::WoW::Armory::Team->new() ); |
447
|
|
|
|
|
|
|
$self->team->seasonGamesPlayed( $$arena_team{ seasonGamesPlayed } ); |
448
|
|
|
|
|
|
|
$self->team->rating( $$arena_team{ rating } ); |
449
|
|
|
|
|
|
|
$self->team->size( $$arena_team{ size } ); |
450
|
|
|
|
|
|
|
$self->team->battleGroup( $$arena_team{ battleGroup } ); |
451
|
|
|
|
|
|
|
$self->team->realm( $$arena_team{ realm } ); |
452
|
|
|
|
|
|
|
$self->team->lastSeasonRanking( $$arena_team{ lastSeasonRanking } ); |
453
|
|
|
|
|
|
|
$self->team->factionId( $$arena_team{ factionId } ); |
454
|
|
|
|
|
|
|
$self->team->ranking( $$arena_team{ ranking } ); |
455
|
|
|
|
|
|
|
$self->team->name( $$arena_team{ name } ); |
456
|
|
|
|
|
|
|
$self->team->relevance( $$arena_team{ relevance } ); |
457
|
|
|
|
|
|
|
$self->team->seasonGamesWon( $$arena_team{ seasonGamesWon } ); |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
my @members; |
460
|
|
|
|
|
|
|
foreach my $member ( keys %{ $members } ) { |
461
|
|
|
|
|
|
|
my $m = Games::WoW::Armory::Character->new; |
462
|
|
|
|
|
|
|
$m->name( $member ); |
463
|
|
|
|
|
|
|
$m->class( $$members{ $member }{ class } ); |
464
|
|
|
|
|
|
|
$m->realm( $$members{ $member }{ realm } ); |
465
|
|
|
|
|
|
|
$m->battleGroup( $$members{ $member }{ battleGroup } ); |
466
|
|
|
|
|
|
|
$m->race( $$members{ $member }{ race } ); |
467
|
|
|
|
|
|
|
$m->gender( $$members{ $member }{ gender } ); |
468
|
|
|
|
|
|
|
$m->guildName( $$members{ $member }{ guild } ); |
469
|
|
|
|
|
|
|
push @members, $m; |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
$self->team->members( \@members ); |
472
|
|
|
|
|
|
|
} |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
sub get_heroic_access { |
475
|
|
|
|
|
|
|
my $self = shift; |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
my @heroic_array; |
478
|
|
|
|
|
|
|
foreach my $rep ( keys %{ $self->character->reputation } ) { |
479
|
|
|
|
|
|
|
foreach my $fac ( keys %{ $self->character->reputation->{ $rep } } ) { |
480
|
|
|
|
|
|
|
foreach my $city ( |
481
|
|
|
|
|
|
|
keys %{ $self->character->reputation->{ $rep }{ $fac }{ 'faction' } } ) |
482
|
|
|
|
|
|
|
{ |
483
|
|
|
|
|
|
|
foreach my $r ( keys %{ $HEROIC_REPUTATIONS } ) { |
484
|
|
|
|
|
|
|
if ( $r eq $city |
485
|
|
|
|
|
|
|
&& $self->character->reputation->{ $rep }{ $fac }{ 'faction' } |
486
|
|
|
|
|
|
|
{ $city }{ 'reputation' } >= 21000 ) |
487
|
|
|
|
|
|
|
{ |
488
|
|
|
|
|
|
|
push @heroic_array, $$HEROIC_REPUTATIONS{ $r }; |
489
|
|
|
|
|
|
|
} |
490
|
|
|
|
|
|
|
} |
491
|
|
|
|
|
|
|
} |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
} |
494
|
|
|
|
|
|
|
$self->character->heroic_access( \@heroic_array ); |
495
|
|
|
|
|
|
|
} |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
500
|
|
|
|
|
|
|
C<bug-games-wow-armory@rt.cpan.org>, or through the web interface at |
501
|
|
|
|
|
|
|
L<http://rt.cpan.org>. |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
=head1 AUTHOR |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
franck cuny C<< <franck.cuny@gmail.com> >> |
506
|
|
|
|
|
|
|
Andrew Yochum C<< <andrewyochum@gmail.com> >> |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
Copyright (c) 2007, franck cuny C<< <franck.cuny@gmail.com> >>. All rights reserved. |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
513
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. See L<perlartistic>. |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
=cut |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
1; |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
package Games::WoW::Armory::Team; |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
use base qw(Class::Accessor::Fast); |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( |
524
|
|
|
|
|
|
|
qw(seasonGamesPlayed rating size battleGroup realm lastSeasonRanking factionId ranking name relevance seasonGamesWon members) |
525
|
|
|
|
|
|
|
); |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
1; |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
package Games::WoW::Armory::Guild; |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
use base qw(Class::Accessor::Fast); |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw(realm name battleGroup members) ); |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
1; |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
package Games::WoW::Armory::Character; |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
use base qw(Class::Accessor::Fast); |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( |
542
|
|
|
|
|
|
|
qw(name guildName arenaTeams battleGroup realm race gender faction level lastModified title class rank teamRank seasonGamesPlayed seasonGamesWon heroic_access characterinfo skill reputation) |
543
|
|
|
|
|
|
|
); |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
1; |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
__END__ |