line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2007 Jonathan Rockway |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Weewar::User; |
4
|
1
|
|
|
1
|
|
4942
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
81
|
|
8
|
|
|
|
|
|
|
require Weewar; |
9
|
1
|
|
|
1
|
|
6
|
use base 'Weewar::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
545
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# my own mini WSDL, i guess |
12
|
|
|
|
|
|
|
sub _ATTRIBUTES { |
13
|
|
|
|
|
|
|
qw/name id/ |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
sub _ELEMENTS { |
16
|
|
|
|
|
|
|
qw/points profile |
17
|
|
|
|
|
|
|
draws victories losses |
18
|
|
|
|
|
|
|
accountType readyToPlay gamesRunning lastLogin |
19
|
|
|
|
|
|
|
basesCaptured creditsSpent/; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
sub _LISTS { |
22
|
|
|
|
|
|
|
( favoriteUnits => ['unit', 'Weewar::Unit' => 'code', ], |
23
|
|
|
|
|
|
|
preferredPlayers => ['player', 'Weewar::User' => 'name', ], |
24
|
|
|
|
|
|
|
preferredBy => ['player', 'Weewar::User' => 'name', ], |
25
|
|
|
|
|
|
|
games => ['game', 'Weewar::Game' => '' , 'id' ], |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub get { |
30
|
|
|
|
|
|
|
my ($self, $what) = @_; |
31
|
|
|
|
|
|
|
return $self->{rating} if($self->{rating} && $what eq 'points'); |
32
|
|
|
|
|
|
|
return $self->{points} if($self->{points} && $what eq 'rating'); |
33
|
|
|
|
|
|
|
return $self->SUPER::get($what); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _TRANSFORMS { |
37
|
|
|
|
|
|
|
( lastLogin => __PACKAGE__->_TRANSFORM_DATE(), |
38
|
|
|
|
|
|
|
readyToPlay => __PACKAGE__->_TRANSFORM_BOOLEAN(), |
39
|
|
|
|
|
|
|
) |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _get_xml { |
43
|
|
|
|
|
|
|
my $self = shift; |
44
|
|
|
|
|
|
|
my $name = $self->{name}; |
45
|
|
|
|
|
|
|
croak "This user ($self) has no name" unless $name; |
46
|
|
|
|
|
|
|
return Weewar->_request("user/$name"); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _root_tag { 'user' } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__PACKAGE__->mk_weewar_accessors; |
52
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors('rating', 'result'); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
package Weewar::Unit; # no need to bless units |
55
|
|
|
|
|
|
|
sub new { return $_[1]->{code} } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |