line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Player Object |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Player; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
596
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
################################################## |
11
|
|
|
|
|
|
|
# object constructor |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
sub new { |
14
|
0
|
|
|
0
|
|
|
my $invocant = shift; |
15
|
0
|
|
0
|
|
|
|
my $class = ref($invocant) || $invocant; |
16
|
0
|
|
|
|
|
|
my $self = { |
17
|
|
|
|
|
|
|
_name => undef, |
18
|
|
|
|
|
|
|
_stats => {}, |
19
|
|
|
|
|
|
|
_times_fragged => 0, |
20
|
|
|
|
|
|
|
_total_frags => 0, |
21
|
|
|
|
|
|
|
_skill => 0, |
22
|
|
|
|
|
|
|
@_, # Override previous attributes |
23
|
|
|
|
|
|
|
}; |
24
|
0
|
|
|
|
|
|
return bless $self, $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
############################################### |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
# accessor methods |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
############################################### |
33
|
|
|
|
|
|
|
sub name { |
34
|
0
|
|
|
0
|
|
|
my $self = shift; |
35
|
0
|
0
|
|
|
|
|
if (@_) { $self->{_name} = shift } |
|
0
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
return $self->{_name}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub stats { |
41
|
0
|
|
|
0
|
|
|
my $self = shift; |
42
|
0
|
0
|
|
|
|
|
if (@_) { $self->{_stats} = shift } |
|
0
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return $self->{_stats}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub times_fragged { |
48
|
0
|
|
|
0
|
|
|
my $self = shift; |
49
|
0
|
0
|
|
|
|
|
if (@_) { $self->{_times_fragged} = shift } |
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $self->{_times_fragged}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub total_frags { |
54
|
0
|
|
|
0
|
|
|
my $self = shift; |
55
|
0
|
0
|
|
|
|
|
if (@_) { $self->{_total_frags} = shift } |
|
0
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $self->{_total_frags}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub inc_times_fragged { |
61
|
0
|
|
|
0
|
|
|
my $self = shift; |
62
|
0
|
|
|
|
|
|
$self->{_times_fragged} = $self->{_times_fragged} + 1; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
############################################### |
68
|
|
|
|
|
|
|
# |
69
|
|
|
|
|
|
|
# update_stats |
70
|
|
|
|
|
|
|
# |
71
|
|
|
|
|
|
|
sub update_stats { |
72
|
0
|
|
|
0
|
|
|
my ($self, $fraggee_name) = @_; |
73
|
0
|
|
|
|
|
|
my $stats = $self->{_stats}; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $fraggee = Player->new( |
76
|
|
|
|
|
|
|
_name => $fraggee_name, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $found_player = $stats->{$fraggee_name}; |
80
|
0
|
|
|
|
|
|
my $fragged_player; |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
if(!$found_player){ |
83
|
0
|
|
|
|
|
|
$fragged_player = $fraggee; |
84
|
0
|
|
|
|
|
|
$fraggee->inc_times_fragged(); |
85
|
0
|
|
|
|
|
|
$stats->{$fraggee_name} = $fraggee; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else{ |
88
|
0
|
|
|
|
|
|
$fragged_player = $found_player; |
89
|
0
|
|
|
|
|
|
$found_player->inc_times_fragged(); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
if( !($fragged_player->{_name} eq $self->{_name})){ |
93
|
0
|
|
|
|
|
|
$self->{_total_frags} = $self->{_total_frags} + 1; |
94
|
|
|
|
|
|
|
} |
95
|
0
|
|
|
|
|
|
return; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub times_fragged_player |
101
|
|
|
|
|
|
|
{ |
102
|
0
|
|
|
0
|
|
|
my ($self, $playername) = @_; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my $fraggee = Player->new( |
105
|
|
|
|
|
|
|
_name => $playername, |
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
my $stats = $self->{_stats}; |
109
|
0
|
|
|
|
|
|
my $found_player = $stats->{$playername}; |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
if(!$found_player){ |
112
|
0
|
|
|
|
|
|
return 0; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
else{ |
115
|
0
|
|
|
|
|
|
return $found_player->times_fragged(); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; # load successful |
124
|
|
|
|
|
|
|
|