line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Tournament; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Last Edit: 2010 11月 26, 10時14分22秒 |
4
|
|
|
|
|
|
|
# $Id: $ |
5
|
|
|
|
|
|
|
|
6
|
30
|
|
|
30
|
|
4269
|
use warnings; |
|
30
|
|
|
|
|
41
|
|
|
30
|
|
|
|
|
817
|
|
7
|
30
|
|
|
30
|
|
192
|
use strict; |
|
30
|
|
|
|
|
44
|
|
|
30
|
|
|
|
|
579
|
|
8
|
30
|
|
|
30
|
|
135
|
use Carp; |
|
30
|
|
|
|
|
40
|
|
|
30
|
|
|
|
|
1870
|
|
9
|
|
|
|
|
|
|
|
10
|
30
|
|
|
30
|
|
145
|
use List::Util qw/first/; |
|
30
|
|
|
|
|
45
|
|
|
30
|
|
|
|
|
2929
|
|
11
|
30
|
|
|
30
|
|
1909
|
use List::MoreUtils qw/any all/; |
|
30
|
|
|
|
|
24428
|
|
|
30
|
|
|
|
|
202
|
|
12
|
30
|
|
|
30
|
|
14442
|
use Scalar::Util qw/looks_like_number/; |
|
30
|
|
|
|
|
50
|
|
|
30
|
|
|
|
|
2553
|
|
13
|
30
|
|
|
30
|
|
152
|
use Scalar::Util qw/looks_like_number/; |
|
30
|
|
|
|
|
58
|
|
|
30
|
|
|
|
|
1218
|
|
14
|
|
|
|
|
|
|
|
15
|
30
|
|
|
30
|
|
759
|
use Games::Tournament::Swiss::Config; |
|
30
|
|
|
|
|
57
|
|
|
30
|
|
|
|
|
1450
|
|
16
|
30
|
100
|
|
|
|
1596
|
use constant ROLES => @Games::Tournament::Swiss::Config::roles? |
17
|
|
|
|
|
|
|
@Games::Tournament::Swiss::Config::roles: |
18
|
30
|
|
|
30
|
|
137
|
Games::Tournament::Swiss::Config->roles; |
|
30
|
|
|
|
|
47
|
|
19
|
30
|
|
|
30
|
|
143
|
use constant FIRSTROUND => $Games::Tournament::Swiss::Config::firstround; |
|
30
|
|
|
|
|
49
|
|
|
30
|
|
|
|
|
116977
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Games::Tournament - Contestant Pairing |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 VERSION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Version 0.02 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$tourney = Games::Tournament->new(\@entrants); |
36
|
|
|
|
|
|
|
next if $capablanca->met($alekhine) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$round = $tourney->meeting($member1, [$member2, $member3]); |
39
|
|
|
|
|
|
|
... |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
In a tournament, there are contestants, and matches over rounds between the contestants, in which they are differentiated by role. TODO firstround and roles. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 METHODS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 new |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Games::Tournament->new( rounds => 2, entrants => [ $a, $b, $c ] ) |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Creates a competition for entrants, over a number of rounds. entrants is a list of player objects. Enters (see enter method) each of the entrants in the tournament. (But why is the entrants arg being deleted?) |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub new { |
56
|
96
|
|
|
96
|
1
|
680
|
my $self = shift; |
57
|
96
|
|
|
|
|
288
|
my %args = @_; |
58
|
96
|
|
|
|
|
189
|
my $entrants = $args{entrants}; |
59
|
96
|
|
|
|
|
179
|
delete $args{entrants}; |
60
|
96
|
|
|
|
|
194
|
my $object = bless \%args, $self; |
61
|
96
|
|
|
|
|
222
|
for my $entrant ( @$entrants ) { $object->enter( $entrant ); } |
|
1758
|
|
|
|
|
3551
|
|
62
|
96
|
|
|
|
|
318
|
return $object; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 enter |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$tourney->enter($player) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Enters a Games::Tournament::Contestant player object with a rating, title id, and name in the entrants of the tournament. Die if no name or id. We are authoritarians. Warn if no rating defined. No check for duplicate ids. Set this round as their first round, unless they already entered in an earlier round (But did they play in that round?) Set their absent accessor if they are in absentees. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub enter { |
75
|
1762
|
|
|
1762
|
1
|
15537
|
my $self = shift; |
76
|
1762
|
|
|
|
|
1945
|
my $player = shift; |
77
|
1762
|
|
|
|
|
3179
|
my $round = $self->round; |
78
|
1762
|
50
|
|
|
|
4664
|
die "Player " . $player->id . " entering in Round $round + 1?" unless |
79
|
|
|
|
|
|
|
looks_like_number($round); |
80
|
1762
|
100
|
|
|
|
4241
|
$player->firstround($round+1) unless $player->firstround; |
81
|
1762
|
|
|
|
|
4403
|
my $absent = $self->absentees; |
82
|
1762
|
|
|
|
|
2256
|
my @absentids; |
83
|
1762
|
50
|
33
|
|
|
3759
|
@absentids = map { $_->id } @$absent if $absent and ref $absent eq 'ARRAY'; |
|
0
|
|
|
|
|
0
|
|
84
|
1762
|
50
|
|
0
|
|
7561
|
$player->absent(1) if any { $_ eq $player->id } @absentids; |
|
0
|
|
|
|
|
0
|
|
85
|
1762
|
|
|
|
|
5507
|
my $entrants = $self->entrants; |
86
|
1762
|
|
|
|
|
2783
|
for my $required ( qw/id name/ ) { |
87
|
3524
|
50
|
|
|
|
8573
|
unless ( $player->$required ) { |
88
|
0
|
|
|
|
|
0
|
croak "No $required for player " . $player->id; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
1762
|
|
|
|
|
2349
|
for my $recommended ( qw/rating/ ) { |
92
|
1762
|
50
|
|
|
|
4227
|
unless ( defined $player->$recommended ) { |
93
|
0
|
|
|
|
|
0
|
carp "No $recommended for player " . $player->id; |
94
|
0
|
|
|
|
|
0
|
$player->$recommended( 'None' ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
1762
|
|
|
|
|
2687
|
push @$entrants, $player; |
98
|
1762
|
|
|
|
|
3478
|
$self->entrants( $entrants ); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 rank |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
@rankings = $tourney->rank(@players) |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Ranks a list of Games::Tournament::Contestant player objects by score, rating, title and name if they all have a score, otherwise ranks them by rating, title and name. This is the same ordering that is used to determine pairing numbers in a swiss tournament. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub rank { |
110
|
5365
|
|
|
5365
|
1
|
7360
|
my $self = shift; |
111
|
5365
|
|
|
|
|
10756
|
my @players = @_; |
112
|
5365
|
100
|
|
16562
|
|
21768
|
if ( all { defined $_->score } @players ) { |
|
16562
|
|
|
|
|
51169
|
|
113
|
|
|
|
|
|
|
sort { |
114
|
4770
|
50
|
100
|
|
|
13014
|
$b->score <=> $a->score |
|
17680
|
|
66
|
|
|
62476
|
|
115
|
|
|
|
|
|
|
|| $b->rating <=> $a->rating |
116
|
|
|
|
|
|
|
|| $a->title cmp $b->title |
117
|
|
|
|
|
|
|
|| $a->name cmp $b->name |
118
|
|
|
|
|
|
|
} @players; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
else { |
121
|
|
|
|
|
|
|
sort { |
122
|
595
|
50
|
66
|
|
|
1592
|
$b->rating <=> $a->rating |
|
9696
|
|
|
|
|
22557
|
|
123
|
|
|
|
|
|
|
|| $a->title cmp $b->title |
124
|
|
|
|
|
|
|
|| $a->name cmp $b->name |
125
|
|
|
|
|
|
|
} @players; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 reverseRank |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
@reverseRankings = $tourney->reverseRank(@players) |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Ranks in reverse order a list of Games::Tournament::Contestant player objects by score, rating, title and name if they all have a score, otherwise reverseRanks them by rating, title and name. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub reverseRank { |
138
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
139
|
0
|
|
|
|
|
0
|
my @players = @_; |
140
|
0
|
|
|
|
|
0
|
my @rankers = $self->rank(@players); |
141
|
0
|
|
|
|
|
0
|
return reverse @rankers; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
#=head2 firstRound |
146
|
|
|
|
|
|
|
# |
147
|
|
|
|
|
|
|
# $tourney->firstRound(7) |
148
|
|
|
|
|
|
|
# |
149
|
|
|
|
|
|
|
#Gets/sets the first round in the competition in which the swiss system is used to pair opponents, when this might not be the first round of the competition. |
150
|
|
|
|
|
|
|
# |
151
|
|
|
|
|
|
|
#=cut |
152
|
|
|
|
|
|
|
# |
153
|
|
|
|
|
|
|
#field 'firstRound' => 1; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 named |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
$tourney->named($name) |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Returns a contestant whose name is $name, the first entrant with a name with stringwise equality. So beware same-named contestants. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub named { |
165
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
166
|
0
|
|
|
|
|
0
|
my $name = shift; |
167
|
0
|
|
|
|
|
0
|
my $contestants = $self->entrants; |
168
|
0
|
|
|
0
|
|
0
|
return ( first { $_->name eq $name } @$contestants ); |
|
0
|
|
|
|
|
0
|
|
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 ided |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
$tourney->ided($id) |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Returns the contestant whose id is $id. Ids are grepped for stringwise equality. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub ided { |
181
|
7747
|
|
|
7747
|
1
|
11050
|
my $self = shift; |
182
|
7747
|
|
|
|
|
10733
|
my $id = shift; |
183
|
7747
|
|
|
|
|
8335
|
my @contestants = @{ $self->entrants }; |
|
7747
|
|
|
|
|
14374
|
|
184
|
7747
|
|
|
96932
|
|
31364
|
return first { $_->id eq $id } @contestants; |
|
96932
|
|
|
|
|
218930
|
|
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 roleCheck |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
roleCheck(@games) |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Returns the roles of the contestants in the individual $games in @games, eg qw/Black White/, qw/Home Away/, these being all the same (ie no typos), or dies. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub roleCheck { |
197
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
198
|
0
|
|
|
|
|
0
|
my @games = @_; |
199
|
0
|
|
|
|
|
0
|
my @roles; |
200
|
0
|
|
|
|
|
0
|
for my $game (@games) { |
201
|
0
|
|
|
|
|
0
|
my $contestants = $game->contestants; |
202
|
0
|
|
|
|
|
0
|
my $result = $game->result; |
203
|
0
|
|
|
|
|
0
|
my @otherroles = sort keys %$contestants; |
204
|
0
|
|
|
|
|
0
|
for my $key ( keys %$result ) { |
205
|
|
|
|
|
|
|
die "$key: $result->{$key}, but no $key player in $game." |
206
|
0
|
0
|
|
|
|
0
|
unless grep { $key eq $_ } @otherroles; |
|
0
|
|
|
|
|
0
|
|
207
|
|
|
|
|
|
|
} |
208
|
0
|
0
|
|
|
|
0
|
unless (@roles) { |
209
|
0
|
|
|
|
|
0
|
@roles = @otherroles; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
else { |
212
|
0
|
|
|
|
|
0
|
my $test = 0; |
213
|
0
|
0
|
|
|
|
0
|
$test++ unless @roles == @otherroles; |
214
|
0
|
|
|
|
|
0
|
for my $i ( 0 .. $#roles ) { |
215
|
0
|
0
|
|
|
|
0
|
$test++ unless $roles[$i] eq $otherroles[$i]; |
216
|
|
|
|
|
|
|
} |
217
|
0
|
0
|
|
|
|
0
|
die "@roles in game 1, but @otherroles in $game." |
218
|
|
|
|
|
|
|
if $test; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
} |
221
|
0
|
|
|
|
|
0
|
return @roles; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head2 met |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
@rounds = $tourney->met($deepblue, @grandmasters) |
228
|
|
|
|
|
|
|
next if $tourney->met($deepblue, $capablanca) |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
In list context, returns an array of the rounds in which $deepblue met the corresponding member of @grandmasters (and of the empty string '' if they haven't met.) In scalar context, returns the number of grandmasters met. Don't forget to collect scorecards in the appropriate games first! (Assumes players do not meet more than once!) This is NOT the same as Games::Tournament::Contestant::met! See also Games;:Tournament::Swiss::whoPlayedWho. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=cut |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub met { |
235
|
41
|
|
|
41
|
1
|
146750
|
my $self = shift; |
236
|
41
|
|
|
|
|
57
|
my $player = shift; |
237
|
41
|
|
|
|
|
84
|
my @opponents = @_; |
238
|
41
|
|
|
|
|
65
|
my @ids = map { $_->id } @opponents; |
|
233
|
|
|
|
|
542
|
|
239
|
41
|
|
|
|
|
104
|
my $games = $self->play; |
240
|
41
|
|
|
|
|
104
|
my $rounds = $self->round; |
241
|
41
|
|
|
|
|
79
|
my %roundGames = map { $_ => $games->{$_} } FIRSTROUND .. $rounds; |
|
123
|
|
|
|
|
382
|
|
242
|
41
|
50
|
|
|
|
151
|
carp "No games to round $rounds. Where are the cards?" unless %roundGames; |
243
|
41
|
|
|
|
|
44
|
my @meetings; |
244
|
41
|
|
|
|
|
159
|
@meetings[ 0 .. $#opponents ] = ('') x @opponents; |
245
|
41
|
|
|
|
|
70
|
my $n = 0; |
246
|
41
|
|
|
|
|
67
|
for my $other (@opponents) { |
247
|
233
|
|
|
|
|
379
|
for my $round ( FIRSTROUND .. $rounds ) { |
248
|
699
|
|
|
|
|
2022
|
my $game = $roundGames{$round}{ $other->id }; |
249
|
699
|
100
|
66
|
|
|
3640
|
next unless $game and $game->can('contestants'); |
250
|
573
|
100
|
|
|
|
1430
|
$meetings[$n] = $round if $other->myOpponent($game) == $player; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
} |
253
|
233
|
|
|
|
|
418
|
continue { $n++; } |
254
|
41
|
50
|
|
|
|
332
|
return @meetings if wantarray; |
255
|
0
|
|
|
|
|
0
|
return scalar grep { $_ } @meetings; |
|
0
|
|
|
|
|
0
|
|
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head2 unmarkedCards |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
@unfinished = $tourney->unmarkedCards(@games) |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Returns an array of the games which have no or a wrong result. The result accessor should be an anonymous hash with roles, or 'Bye' as keys and either 'Win' & 'Loss', 'Loss' & 'Win' or 'Draw' & 'Draw', or 'Bye', as values. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=cut |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub unmarkedCards { |
268
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
269
|
0
|
|
|
|
|
0
|
my @games = @_; |
270
|
0
|
|
|
|
|
0
|
my @unfinished; |
271
|
0
|
|
|
|
|
0
|
for my $game (@games) { |
272
|
0
|
|
|
|
|
0
|
my $contestants = $game->contestants; |
273
|
0
|
|
|
|
|
0
|
my $result = $game->result; |
274
|
|
|
|
|
|
|
push @unfinished, $game |
275
|
|
|
|
|
|
|
unless ( |
276
|
|
|
|
|
|
|
( keys %$contestants == 1 and $result->{Bye} =~ m/Bye/i ) |
277
|
|
|
|
|
|
|
or $result->{ (ROLES)[0] } and $result->{ (ROLES)[1] } |
278
|
|
|
|
|
|
|
and ( |
279
|
|
|
|
|
|
|
( |
280
|
|
|
|
|
|
|
$result->{ (ROLES)[0] } eq 'Win' |
281
|
|
|
|
|
|
|
and $result->{ (ROLES)[1] } eq 'Loss' |
282
|
|
|
|
|
|
|
) |
283
|
|
|
|
|
|
|
or ( $result->{ (ROLES)[0] } eq 'Loss' |
284
|
|
|
|
|
|
|
and $result->{ (ROLES)[1] } eq 'Win' ) |
285
|
|
|
|
|
|
|
or ( $result->{ (ROLES)[0] } eq 'Draw' |
286
|
0
|
0
|
0
|
|
|
0
|
and $result->{ (ROLES)[1] } eq 'Draw' ) |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
287
|
|
|
|
|
|
|
) |
288
|
|
|
|
|
|
|
); |
289
|
|
|
|
|
|
|
} |
290
|
0
|
|
|
|
|
0
|
return @unfinished; |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=head2 dupes |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
$games = $tourney->dupes(@grandmasters) |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Returns an anonymous array, of the games in which @grandmasters have met. Don't forget to collect scorecards in the appropriate games first! (Assumes players do not meet more than once!) |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=cut |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub dupes { |
303
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
304
|
0
|
|
|
|
|
0
|
my @players = @_; |
305
|
0
|
|
|
|
|
0
|
my @ids = map { $_->id } @players; |
|
0
|
|
|
|
|
0
|
|
306
|
0
|
|
|
|
|
0
|
my $games = $self->play; |
307
|
0
|
|
|
|
|
0
|
my @dupes; |
308
|
|
|
|
|
|
|
map { |
309
|
0
|
|
|
|
|
0
|
my $id = $_; |
|
0
|
|
|
|
|
0
|
|
310
|
0
|
0
|
|
|
|
0
|
map { push @dupes, $games->{$id}->{$_} if exists $games->{$id}->{$_}; } |
|
0
|
|
|
|
|
0
|
|
311
|
|
|
|
|
|
|
@ids; |
312
|
|
|
|
|
|
|
} @ids; |
313
|
0
|
|
|
|
|
0
|
return \@dupes; |
314
|
|
|
|
|
|
|
} |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=head2 updateScores |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
@scores = $tourney->updateScores; |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
Updates entrants' scores for the present (previous) round, using $tourney's play (ie games played) field. Returns an array of the scores in order of the player ids (not at the moment, it doesn't), dying on those entrants who don't have a result for the round. Be careful. Garbage in, garbage out. What is the present round? |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=cut |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub updateScores { |
326
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
327
|
0
|
|
|
|
|
0
|
my $players = $self->entrants; |
328
|
0
|
|
|
|
|
0
|
my $round = $self->round; |
329
|
0
|
|
|
|
|
0
|
my $games = $self->play; |
330
|
0
|
|
|
|
|
0
|
my @scores; |
331
|
0
|
|
|
|
|
0
|
for my $player (@$players) { |
332
|
0
|
|
|
|
|
0
|
my $id = $player->id; |
333
|
0
|
|
|
|
|
0
|
my $oldId = $player->oldId; |
334
|
0
|
|
|
|
|
0
|
my $scores = $player->scores; |
335
|
0
|
|
|
|
|
0
|
my $card = $games->{$round}->{$id}; |
336
|
0
|
0
|
0
|
|
|
0
|
die "Game in round $round for player $id? Is $round the right round?" |
337
|
|
|
|
|
|
|
unless $card |
338
|
|
|
|
|
|
|
and $card->isa('Games::Tournament::Card'); |
339
|
0
|
|
|
|
|
0
|
my $results = $card->{result}; |
340
|
0
|
|
|
|
|
0
|
die @{ [ keys %$results ] } . " roles in player ${id}'s game?" |
341
|
0
|
0
|
0
|
|
|
0
|
unless grep { $_ eq (ROLES)[0] or $_ eq (ROLES)[1] or $_ eq 'Bye' } |
|
0
|
0
|
|
|
|
0
|
|
342
|
|
|
|
|
|
|
keys %$results; |
343
|
0
|
|
|
|
|
0
|
eval { $card->myResult($player) }; |
|
0
|
|
|
|
|
0
|
|
344
|
0
|
0
|
0
|
|
|
0
|
die "$@: Result in player ${id}'s $card game in round $round?" |
345
|
|
|
|
|
|
|
if not $card or $@; |
346
|
0
|
|
|
|
|
0
|
my $result = $card->myResult($player); |
347
|
0
|
0
|
|
|
|
0
|
die "$result result in $card game for player $id in round $round?" |
348
|
|
|
|
|
|
|
unless $result =~ m/^(?:Win|Loss|Draw|Bye|Forfeit)/i; |
349
|
0
|
|
|
|
|
0
|
$$scores{$round} = $result; |
350
|
0
|
0
|
|
|
|
0
|
$player->scores($scores) if defined $scores; |
351
|
0
|
|
|
|
|
0
|
push @scores, $$scores{$round}; |
352
|
|
|
|
|
|
|
} |
353
|
0
|
|
|
|
|
0
|
$self->entrants($players); |
354
|
|
|
|
|
|
|
# return @scores; |
355
|
|
|
|
|
|
|
} |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
=head2 randomRole |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
( $myrole, $yourrole ) = randomRole; |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
This returns the 2 roles, @Games::Tournament::roles in a random order. |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
=cut |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
sub randomRole { |
367
|
125
|
|
|
125
|
1
|
177
|
my $self = shift; |
368
|
125
|
100
|
|
|
|
1866
|
my $evenRole = int rand(2) ? (ROLES)[0] : (ROLES)[1]; |
369
|
125
|
100
|
|
|
|
346
|
my $oddRole = $evenRole eq (ROLES)[0] ? (ROLES)[1] : (ROLES)[0]; |
370
|
125
|
|
|
|
|
354
|
return ( $evenRole, $oddRole ); |
371
|
|
|
|
|
|
|
} |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
=head2 play |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
$tourney->play |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
Gets the games played, keyed on round and id of player. Also sets, but you don't want to do that. |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
=cut |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
sub play { |
383
|
312
|
|
|
312
|
1
|
447
|
my $self = shift; |
384
|
312
|
|
|
|
|
526
|
my $play = shift; |
385
|
312
|
100
|
|
|
|
1168
|
if ( defined $play ) { $self->{play} = $play; } |
|
71
|
100
|
|
|
|
536
|
|
386
|
191
|
|
|
|
|
528
|
elsif ( $self->{play} ) { return $self->{play}; } |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
=head2 entrants |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
$tourney->entrants |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
Gets/sets the entrants as an anonymous array of player objects. Users may rely on the original order being maintained in web app cookies. |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
=cut |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
sub entrants { |
398
|
12056
|
|
|
12056
|
1
|
107221
|
my $self = shift; |
399
|
12056
|
|
|
|
|
13862
|
my $entrants = shift; |
400
|
12056
|
100
|
|
|
|
33404
|
if ( defined $entrants ) { $self->{entrants} = $entrants; } |
|
1964
|
100
|
|
|
|
10230
|
|
401
|
9996
|
|
|
|
|
36319
|
elsif ( $self->{entrants} ) { return $self->{entrants}; } |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
=head2 absentees |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
$tourney->absentees |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
Gets/sets the absentees as an anonymous array of player objects. These players won't be included in the brackets of players who are to be paired. |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=cut |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
sub absentees { |
414
|
1956
|
|
|
1956
|
1
|
2333
|
my $self = shift; |
415
|
1956
|
|
|
|
|
2322
|
my $absentees = shift; |
416
|
1956
|
50
|
|
|
|
6433
|
if ( defined $absentees ) { $self->{absentees} = $absentees; } |
|
0
|
50
|
|
|
|
0
|
|
417
|
0
|
|
|
|
|
0
|
elsif ( $self->{absentees} ) { return $self->{absentees}; } |
418
|
|
|
|
|
|
|
} |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=head2 round |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
$tourney->round |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
Gets/sets the round number of a round near you. The default round number is 0. That is, the 'round' before round 1. The question is when one round becomes the next round. |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
=cut |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
sub round { |
430
|
2125
|
|
|
2125
|
1
|
2923
|
my $self = shift; |
431
|
2125
|
|
|
|
|
2409
|
my $round = shift; |
432
|
2125
|
100
|
|
|
|
5022
|
if ( defined $round ) { $self->{round} = $round; } |
|
134
|
100
|
|
|
|
1043
|
|
433
|
187
|
|
|
|
|
513
|
elsif ( $self->{round} ) { return $self->{round}; } |
434
|
1804
|
|
|
|
|
2890
|
else { return 0 } |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
=head2 rounds |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
$tourney->rounds |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
Gets/sets the number of rounds in the tournament. |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
=cut |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
sub rounds { |
447
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
448
|
0
|
|
|
|
|
0
|
my $rounds = shift; |
449
|
0
|
0
|
|
|
|
0
|
if ( defined $rounds ) { $self->{rounds} = $rounds; } |
|
0
|
0
|
|
|
|
0
|
|
450
|
0
|
|
|
|
|
0
|
elsif ( $self->{rounds} ) { return $self->{rounds}; } |
451
|
|
|
|
|
|
|
} |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
=head2 size |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
$size = 'Maxi' if $tourney->size > 2**$tourney->rounds |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
Gets the number of entrants |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
=cut |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
sub size { |
463
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
464
|
0
|
|
|
|
|
0
|
return scalar @{ $self->entrants }; |
|
0
|
|
|
|
|
0
|
|
465
|
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
=head2 idNameCheck |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
$tourney->idNameCheck # WARNING: 13301616 and 13300849 both, Petrosian, Tigran |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
Dies if 2 entrants have the same id, warns if they have the same name. |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
=cut |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
sub idNameCheck { |
477
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
478
|
0
|
|
|
|
|
0
|
my $lineup = $self->entrants; |
479
|
0
|
|
|
|
|
0
|
my (%idcheck, %namecheck); |
480
|
0
|
|
|
|
|
0
|
for my $player ( @$lineup ) { |
481
|
0
|
|
|
|
|
0
|
my $id = $player->id; |
482
|
0
|
|
|
|
|
0
|
my $name = $player->name; |
483
|
0
|
0
|
|
|
|
0
|
if ( defined $idcheck{$id} ) { |
484
|
0
|
|
|
|
|
0
|
croak $name . " and $idcheck{$id} have the same id: $id"; |
485
|
|
|
|
|
|
|
} |
486
|
0
|
0
|
|
|
|
0
|
if ( defined $namecheck{$name} ) { |
487
|
0
|
|
|
|
|
0
|
carp "WARNING: $id and $namecheck{$name} have the same name: " . |
488
|
|
|
|
|
|
|
$name . ". Proceeding, but BEWARE there may be problems later,"; |
489
|
|
|
|
|
|
|
} |
490
|
0
|
|
|
|
|
0
|
$idcheck{$id} = $name; |
491
|
0
|
|
|
|
|
0
|
$namecheck{$name} = $id; |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
} |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
=head2 idCheck |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
$tourney->idCheck # Petrosian, Tigran, and Tigran Petrosian both 13301616 |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
Dies if 2 entrants have the same id |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
=cut |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
sub idCheck { |
505
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
506
|
0
|
|
|
|
|
0
|
my $lineup = $self->entrants; |
507
|
0
|
|
|
|
|
0
|
my %idcheck; |
508
|
0
|
|
|
|
|
0
|
for my $player ( @$lineup ) { |
509
|
0
|
|
|
|
|
0
|
my $id = $player->id; |
510
|
0
|
|
|
|
|
0
|
my $name = $player->name; |
511
|
0
|
0
|
|
|
|
0
|
if ( defined $idcheck{$id} ) { |
512
|
0
|
|
|
|
|
0
|
croak $name . " and $idcheck{$id} have the same id: $id"; |
513
|
|
|
|
|
|
|
} |
514
|
0
|
|
|
|
|
0
|
$idcheck{$id} = $name; |
515
|
|
|
|
|
|
|
} |
516
|
|
|
|
|
|
|
} |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
=head2 nameCheck |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
$tourney->idNameCheck # WARNING: 13301616 and 13300849 both, Petrosian, Tigran |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
Warn if 2 entrants have the same name |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=cut |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
sub nameCheck { |
527
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
528
|
0
|
|
|
|
|
0
|
my $lineup = $self->entrants; |
529
|
0
|
|
|
|
|
0
|
my %namecheck; |
530
|
0
|
|
|
|
|
0
|
for my $player ( @$lineup ) { |
531
|
0
|
|
|
|
|
0
|
my $id = $player->id; |
532
|
0
|
|
|
|
|
0
|
my $name = $player->name; |
533
|
0
|
0
|
|
|
|
0
|
if ( defined $namecheck{$name} ) { |
534
|
0
|
|
|
|
|
0
|
carp "WARNING: $id and $namecheck{$name} have the same name: " . |
535
|
|
|
|
|
|
|
$name . ". Proceeding, but BEWARE there may be problems later,"; |
536
|
|
|
|
|
|
|
} |
537
|
0
|
|
|
|
|
0
|
$namecheck{$name} = $id; |
538
|
|
|
|
|
|
|
} |
539
|
|
|
|
|
|
|
} |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
=head2 odd |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
float($lowest) if $self->odd(@group) |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
Tests whether the number of players in @group is odd or not. |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=cut |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
sub odd { |
550
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
551
|
0
|
|
|
|
|
0
|
my @n = @_; |
552
|
0
|
|
|
|
|
0
|
return @n % 2; |
553
|
|
|
|
|
|
|
} |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
=head2 clearLog |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
$pairing->clearLog(qw/C10 C11/) |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
Discards the logged messages for the passed procedures. |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
=cut |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
sub clearLog { |
565
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
566
|
0
|
|
|
|
|
0
|
my @states = @_; |
567
|
0
|
|
|
|
|
0
|
my $log = $self->{log}; |
568
|
0
|
|
|
|
|
0
|
delete $log->{$_} for @states; |
569
|
0
|
|
|
|
|
0
|
return; |
570
|
|
|
|
|
|
|
} |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
=head2 catLog |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
$pairing->catLog(qw/C10 C11/) |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
Returns the messages logged for the passed procedures, or all logged procedures if no procedures are passed, as a hash keyed on the procedures. If no messages were logged, because the procedures were not loggedProcedures, no messages will be returned. |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=cut |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
sub catLog { |
582
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
583
|
0
|
|
|
|
|
0
|
my @states = @_; |
584
|
0
|
0
|
|
|
|
0
|
@states = $self->loggedProcedures unless @states; |
585
|
0
|
|
|
|
|
0
|
my $log = $self->{log}; |
586
|
0
|
|
|
|
|
0
|
my %report; |
587
|
0
|
|
|
|
|
0
|
for my $state ( @states ) { |
588
|
0
|
|
|
|
|
0
|
my $strings = $log->{$state}->{strings}; |
589
|
0
|
0
|
0
|
|
|
0
|
unless ( $strings and ref $strings eq 'ARRAY' ) { |
590
|
0
|
|
|
|
|
0
|
$report{$state} = undef; |
591
|
0
|
|
|
|
|
0
|
next; |
592
|
|
|
|
|
|
|
} |
593
|
0
|
|
|
|
|
0
|
$report{$state} = join '', @$strings; |
594
|
|
|
|
|
|
|
} |
595
|
0
|
|
|
|
|
0
|
return %report; |
596
|
|
|
|
|
|
|
} |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=head2 tailLog |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
$pairing->tailLog(qw/C10 C11/) |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
Returns the new messages logged for the passed procedures since they were last tailed, as a hash keyed on the procedures. If no messages were logged, because the procedures were not loggedProcedures, no messages will be returned. |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
=cut |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
sub tailLog { |
608
|
133
|
|
|
133
|
1
|
179
|
my $self = shift; |
609
|
133
|
|
|
|
|
266
|
my @states = @_; |
610
|
133
|
50
|
|
|
|
270
|
@states = $self->loggedProcedures unless @states; |
611
|
133
|
|
|
|
|
206
|
my $log = $self->{log}; |
612
|
133
|
|
|
|
|
197
|
my %report = map { $_ => $log->{$_}->{strings} } @states; |
|
133
|
|
|
|
|
483
|
|
613
|
133
|
|
|
|
|
214
|
my %tailpos = map { $_ => $log->{$_}->{tailpos} } @states; |
|
133
|
|
|
|
|
387
|
|
614
|
133
|
|
|
|
|
182
|
my (%newpos, %lastpos, %tailedReport); |
615
|
133
|
|
|
|
|
253
|
for my $state ( @states ) |
616
|
|
|
|
|
|
|
{ |
617
|
133
|
100
|
|
|
|
334
|
if ( defined $tailpos{$state} ) |
|
|
50
|
|
|
|
|
|
618
|
|
|
|
|
|
|
{ |
619
|
108
|
|
|
|
|
210
|
$newpos{$state} = $tailpos{$state} + 1; |
620
|
108
|
|
|
|
|
120
|
$lastpos{$state} = $#{ $report{$state} }; |
|
108
|
|
|
|
|
258
|
|
621
|
|
|
|
|
|
|
$tailedReport{$state} = join '', |
622
|
108
|
|
|
|
|
219
|
@{$report{$state}}[ $newpos{$state}..$lastpos{$state} ]; |
|
108
|
|
|
|
|
330
|
|
623
|
108
|
|
|
|
|
414
|
$log->{$_}->{tailpos} = $lastpos{$_} for @states; |
624
|
|
|
|
|
|
|
} |
625
|
|
|
|
|
|
|
elsif ( $report{$state} ) { |
626
|
25
|
|
|
|
|
45
|
$newpos{$state} = 0; |
627
|
25
|
|
|
|
|
30
|
$lastpos{$state} = $#{ $report{$state} }; |
|
25
|
|
|
|
|
53
|
|
628
|
|
|
|
|
|
|
$tailedReport{$state} = join '', |
629
|
25
|
|
|
|
|
57
|
@{$report{$state}}[ $newpos{$state}..$lastpos{$state} ]; |
|
25
|
|
|
|
|
80
|
|
630
|
25
|
|
|
|
|
167
|
$log->{$_}->{tailpos} = $lastpos{$_} for @states; |
631
|
|
|
|
|
|
|
} |
632
|
|
|
|
|
|
|
} |
633
|
133
|
|
|
|
|
707
|
return %tailedReport; |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
=head2 log |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
$pairing->log('x=p=1, no more x increases in Bracket 4 (2).') |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
Saves the message in a log iff this procedure is logged. |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
=cut |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
sub log { |
646
|
6855
|
|
|
6855
|
1
|
9567
|
my $self = shift; |
647
|
6855
|
|
|
|
|
9266
|
my $message = shift; |
648
|
6855
|
50
|
|
|
|
13760
|
return unless $message; |
649
|
6855
|
|
|
|
|
71792
|
(my $method = uc((caller 1)[3])) =~ s/^.*::(\w+)$/$1/; |
650
|
6855
|
|
|
|
|
21234
|
my @loggable = $self->loggedProcedures; |
651
|
180
|
|
|
|
|
730
|
push @{ $self->{log}->{$method}->{strings} }, "\t$message\n" if |
652
|
6855
|
100
|
|
2098
|
|
33022
|
any { $_ eq $method } @loggable; |
|
2098
|
|
|
|
|
2528
|
|
653
|
6855
|
|
|
|
|
25115
|
return; |
654
|
|
|
|
|
|
|
} |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
=head2 loggedProcedures |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
$group->loggedProcedures(qw/C10 C11 C12/) |
660
|
|
|
|
|
|
|
$group->loggedProcedures(qw/C5 C6PAIRS C7 C8/) |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
Adds messages generated in the procedures named in the argument list to a reportable log. Without an argument returns the logged procedures as an array. |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
=cut |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
sub loggedProcedures { |
667
|
12460
|
|
|
12460
|
1
|
16872
|
my $self = shift; |
668
|
12460
|
|
|
|
|
19333
|
my @states = @_; |
669
|
12460
|
50
|
|
|
|
27461
|
unless ( @states ) { return keys %{ $self->{logged} }; } |
|
12460
|
|
|
|
|
14261
|
|
|
12460
|
|
|
|
|
46523
|
|
670
|
0
|
|
|
|
|
0
|
my %logged; |
671
|
0
|
|
|
|
|
0
|
@logged{qw/START NEXT PREV C1 C2 C3 C4 C5 C6PAIRS C6OTHERS C7 C8 C9 C10 C11 C12 C13 C14 BYE MATCHPLAYERS ASSIGNPAIRINGNUMBERS/} = (1) x 21; |
672
|
0
|
|
|
|
|
0
|
for my $state (@states) |
673
|
|
|
|
|
|
|
{ |
674
|
0
|
0
|
|
|
|
0
|
carp "$state is unloggable procedure" if not exists $logged{$state}; |
675
|
0
|
|
|
|
|
0
|
$self->{logged}->{$state} = 1; |
676
|
|
|
|
|
|
|
# push @{ $self->{log}->{$state}->{strings} }, $state . ","; |
677
|
|
|
|
|
|
|
} |
678
|
0
|
|
|
|
|
0
|
return; |
679
|
|
|
|
|
|
|
} |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
=head2 loggingAll |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
$group->loggingAll |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
Adds messages generated in all the procedures to a reportable log |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
=cut |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
sub loggingAll { |
691
|
2
|
|
|
2
|
1
|
31
|
my $self = shift; |
692
|
2
|
|
|
|
|
4
|
my %logged; |
693
|
2
|
|
|
|
|
30
|
@logged{qw/START NEXT PREV C1 C2 C3 C4 C5 C6PAIRS C6OTHERS C7 C8 C9 C10 C11 C12 C13 C14 BYE MATCHPLAYERS ASSIGNPAIRINGNUMBERS/} = (1) x 21; |
694
|
2
|
|
|
|
|
13
|
for my $state ( keys %logged ) |
695
|
|
|
|
|
|
|
{ |
696
|
|
|
|
|
|
|
# carp "$state is unloggable procedure" if not exists $logged{$state}; |
697
|
42
|
|
|
|
|
77
|
$self->{logged}->{$state} = 1; |
698
|
|
|
|
|
|
|
} |
699
|
2
|
|
|
|
|
12
|
return; |
700
|
|
|
|
|
|
|
} |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
=head2 disloggedProcedures |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
$group->disloggedProcedures |
706
|
|
|
|
|
|
|
$group->disloggedProcedures(qw/C6PAIRS C7 C8/) |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
Stops messages generated in the procedures named in the argument list being added to a reportable log. Without an argument stops logging of all procedures. |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
=cut |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
sub disloggedProcedures { |
713
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
714
|
0
|
|
|
|
|
|
my @states = @_; |
715
|
0
|
0
|
|
|
|
|
unless ( @states ) |
716
|
|
|
|
|
|
|
{ |
717
|
0
|
|
|
|
|
|
my @methods = keys %{ $self->{logged} }; |
|
0
|
|
|
|
|
|
|
718
|
0
|
|
|
|
|
|
@{$self->{logged}}{@methods} = (0) x @methods; |
|
0
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
} |
720
|
0
|
|
|
|
|
|
my %logged; |
721
|
0
|
|
|
|
|
|
@logged{qw/START NEXT PREV C1 C2 C3 C4 C5 C6PAIRS C6OTHERS C7 C8 C9 C10 C11 C12 C13 C14 BYE MATCHPLAYERS ASSIGNPAIRINGNUMBERS/} = (1) x 21; |
722
|
0
|
|
|
|
|
|
for my $state (@states) |
723
|
|
|
|
|
|
|
{ |
724
|
0
|
0
|
|
|
|
|
carp "$state is unloggable procedure" if not defined $logged{$state}; |
725
|
0
|
|
|
|
|
|
$self->{logged}->{$state} = 0; |
726
|
|
|
|
|
|
|
} |
727
|
0
|
|
|
|
|
|
return; |
728
|
|
|
|
|
|
|
} |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
=head1 AUTHOR |
732
|
|
|
|
|
|
|
|
733
|
|
|
|
|
|
|
Dr Bean, C<< >> |
734
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
=head1 BUGS |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
738
|
|
|
|
|
|
|
C, or through the web interface at |
739
|
|
|
|
|
|
|
L. |
740
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
741
|
|
|
|
|
|
|
your bug as I make changes. |
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
=head1 SUPPORT |
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
perldoc Games::Tournament |
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
You can also look for information at: |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
=over 4 |
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
754
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
L |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
=item * CPAN Ratings |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
L |
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
L |
764
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
=item * Search CPAN |
766
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
L |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
=back |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
Copyright 2006 Dr Bean, all rights reserved. |
776
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
778
|
|
|
|
|
|
|
under the same terms as Perl itself. |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
=cut |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
1; # End of Games::Tournament |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
# vim: set ts=8 sts=4 sw=4 noet: |