DataObjects/Round.pm

filter: Statementstmt 32.6% 83 / 254 Branchbran 5.6% 6 / 106 Conditioncond 30.7% 12 / 39 MC/DCmcdc 4.3% 1 / 23 Subroutinesub 58.3% 21 / 36 Podpod 56.2% 9 / 16 totaltotal 27.8% 132 / 474 CC 76 SCAR 54.1
CC
76
Cov
25%
swap
812.0
_find_bye_idx
110.0
measure_field_lengths
42.0
CRAP 224.3
↑ Summary DataObjects/Tournament.pm »
1 #===============================================================================
2 #
3 # FILE: Games::Go::AGA::DataObjects::Round.pm
4 #
5 # USAGE: use Games::Go::AGA::DataObjects::Round;
6 #
7 # PODNAME: Games::Go::AGA::DataObjects::Round
8 # ABSTRACT: model a round of an AGA tournament
9 #
10 # AUTHOR: Reid Augustin (REID), <reid@hellosix.com>
11 # CREATED: 11/19/2010 03:13:05 PM PST
12 #===============================================================================
13  
14 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 package Games::Go::AGA::DataObjects::Round;
18 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use Scalar::Util qw( refaddr looks_like_number );
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use Games::Go::AGA::DataObjects::Game;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use Games::Go::AGA::DataObjects::Player;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use Games::Go::AGA::DataObjects::Types qw( is_Int isa_Int isa_CodeRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 ▶use Games::Go::AGA::Parse::Util qw( normalize_ID Rank_to_Rating );
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 2 our $VERSION = '0.152'; # VERSION
29  
30 2 our $deprecate = 0;
31 # has 'games' => (
32 # isa => 'ArrayRef[Games::Go::AGA::DataObjects::Game]',
33 # is => 'rw',
34 # default => sub { [] },
35 # );
36 # has 'byes' => (
37 # isa => 'ArrayRef[Games::Go::AGA::DataObjects::Player]',
38 # is => 'rw',
39 # default => sub { [] },
40 # );
41 2 has filename => ( # store a filename here
42 is => 'rw',
43 );
44 has table_number => ( # assign table numbers from how many tables used so far
45 isa => \&isa_Int,
46 is => 'rw',
47 lazy => 1,
48 2 ▶ default => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
49 2 );
50 has change_callback => (
51 isa => \&isa_CodeRef,
52 is => 'rw',
53 lazy => 1,
54 2 ▶ default => sub { sub {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
55 2 );
56 has suppress_changes => ( # don't call change_callback if set
57 is => 'rw',
58 lazy => 1,
59 2 ▶ default => sub { 0 }
Subroutine __ANON__: called CC=1 SCAR=0.0
60 2 );
61 has fprint_pending => ( # set when changed called, cleared after fprint done
62 is => 'rw',
63 lazy => 1,
64 0 ▶ default => sub { 0 }
Subroutine __ANON__: not called CC=1 SCAR=6.9
65 2 );
66 has round_num => ( # which round is this?
67 2 ▶ isa => sub {
Subroutine __ANON__: called CC=4 SCAR=20.7
68 2 ▶ die defined $_[0] ? "Invalid round index $_[0]" : "round index not defined" if (not is_Int($_[0]) or $_[0] < 1);
Branch: 2 branches
BranchTrueFalseTotal
if not is_Int($_[0]) or $_[0] < 1 0 2 2
defined $_[0] ? : 0 0 0
Condition33%1/3
not is_Int($_[0]) or $_[0] < 1
l!l&&r!l&&!r
002
MC/DC0%0/2
not is_Int($_[0]) or $_[0] < 1
not is_Int($_[0]) $_[0] < 1
Truth table33%1/3
not(A) or B
A= not is_Int($_[0])B= $_[0] < 1
ABresult
1X1
011
000
69 },
70 is => 'rw',
71 lazy => 1,
72 0 ▶ default => sub { 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
73 2 );
74 has adj_ratings_change => ( # set when player->adj_ratings need recalculation
75 is => 'rw',
76 lazy => 1,
77 0 ▶ default => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
78 2 );
79 2 has id => (
80 is => 'rw',
81 );
82 2 has id_len => (
83 is => 'rw',
84 );
85 2 has handi_len => (
86 is => 'rw',
87 );
88 2 has komi_len => (
89 is => 'rw',
90 );
91 2 has name_len => (
92 is => 'rw',
93 );
94  
95 2 our $idxx = 0;
96  
97 2 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
98 2 my ($self) = @_;
99 2 $self->{games} = [];
100 2 $self->{byes} = [];
101 2 $self->id($idxx++);
102 }
103  
104 16 ▶sub changed {
Subroutine changed: called CC=2 SCAR=7.0
Pod undocumented
105 16 my ($self, @args) = @_;
106  
107 16 $self->fprint_pending(1);
108 16 $self->adj_ratings_change(1);
109 16 ▶ &{$self->change_callback}(@_) if (not $self->suppress_changes);
Branch: 1 branch
BranchTrueFalseTotal
if not $self->suppress_changes 16 0 16
110 }
111  
112 21 ▶sub games {
Subroutine games: called CC=2 SCAR=8.1
Pod documented
113 21 my ($self) = @_;
114  
115 return wantarray
116 0 ? @{$self->{games}}
117 21 ▶ : $self->{games};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 21 21
118 }
119  
120 # find game by index or by 1 or two IDs
121 3 ▶sub game {
Subroutine game: called CC=10 SCAR=25.5
Pod undocumented
122 3 my ($self, $which, $which2) = @_;
123  
124 3 ▶ if (@_ <= 2 and
Branch: 1 branch
BranchTrueFalseTotal
if (@_ <= 2 and &looks_like_number($which) and $which < @{$self->{"games"};}) 0 3 3
Condition50%3/6
@_ <= 2 and &looks_like_number($which) and $which < @{$self->{"games"};}
!ll&&!rl&&r
300
@_ <= 2 and &looks_like_number($which)
!ll&&!rl&&r
120
MC/DC0%0/3
@_ <= 2 and &looks_like_number($which) and $which < @{$self->{"games"};}
@_ <= 2 &looks_like_number($which) $which < @{$self->{"games"};}
Truth table50%2/4
A and B and C
A= @_ <= 2B= &looks_like_number($which)C= $which < @{$self->{"games"};}
ABCresult
0XX0
10X0
1100
1111
125 looks_like_number($which) and
126 0 $which < @{$self->{games}} ) {
127 0 return $self->{games}[$which]; # as index
128 }
129 3 $which = normalize_ID($which);
130 3 ▶ $which2 ||= $which;
Condition66%2/3
$which2 ||= $which
l!l&&r!l&&!r
120
MC/DC0%0/2
$which2 ||= $which
$which2 $which
Truth table66%2/3
A ||= B
A= $which2B= $which
ABresult
1X1
011
000
131 3 $which2 = normalize_ID($which2);
132 3 for my $game (@{$self->{games}}) {
133 4 my $wid = $game->white->id;
134 4 my $bid = $game->black->id;
135 4 ▶ if (($wid eq $which or $bid eq $which) and
Branch: 1 branch
BranchTrueFalseTotal
if ($wid eq $which || $bid eq $which and $wid eq $which2 || $bid eq $which2) 3 1 4
Condition66%6/9
$wid eq $which || $bid eq $which and $wid eq $which2 || $bid eq $which2
!ll&&!rl&&r
103
$wid eq $which or $bid eq $which
l!l&&r!l&&!r
031
$wid eq $which2 or $bid eq $which2
l!l&&r!l&&!r
120
MC/DC25%1/4
$wid eq $which || $bid eq $which and $wid eq $which2 || $bid eq $which2
$wid eq $which $bid eq $which $wid eq $which2 $bid eq $which2
Truth table42%3/7
A or B and C or D
A= $wid eq $whichB= $bid eq $whichC= $wid eq $which2D= $bid eq $which2
ABCDresult
00XX0
1X000
01000
1X1X1
1X011
011X1
01011
136 ($wid eq $which2 or $bid eq $which2)) {
137 3 return $game;
138 }
139 }
140 0 return; # not found
141 }
142  
143 0 ▶sub byes {
Subroutine byes: not called CC=3 SCAR=24.8
Pod documented
144 0 ▶ croak("Rounds->byes is deprecated") if ($deprecate > 0);
Branch: 1 branch
BranchTrueFalseTotal
if $Games::Go::AGA::DataObjects::Round::deprecate > 0 0 0 0
145 0 my ($self) = @_;
146  
147 return wantarray
148 0 ? @{$self->{byes}}
149 0 ▶ : $self->{byes};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
150 }
151  
152 5 ▶sub add_game {
Subroutine add_game: called CC=1 SCAR=0.0
Pod documented
153 5 my ($self, $game) = @_;
154  
155 5 my $prev_callback = $game->change_callback;
156 $game->change_callback( # add to game callback
157 11 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
158 11 $prev_callback->(@_); # whatever happened before, and
159 11 $self->changed; # our status changes
160 }
161 5 );
162 5 push (@{$self->{games}}, $game);
163 5 $game->table_number($self->table_number);
164 5 $self->table_number($self->table_number + 1);
165 5 $self->changed;
166 5 return $self;
167 }
168  
169 0 ▶sub clear_table_number {
Subroutine clear_table_number: not called CC=1 SCAR=6.9
Pod documented
170 0 my ($self) = @_;
171  
172 0 $self->table_number(1);
173 }
174  
175 0 ▶sub remove_game {
Subroutine remove_game: not called CC=5 SCAR=34.0
Pod documented
176 0 my ($self, $game) = @_;
177  
178 0 my $games = $self->{games};
179 0 ▶ if (ref $game) { # if game is a ref, find index of that ref
Branch: 1 branch
BranchTrueFalseTotal
if (ref $game) 0 0 0
180 0 my $raddr = refaddr($game);
181 0 ▶ for (my $idx = 0; $idx < @{$games}; $idx++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx < @{$games;}) 0 0 0
182 0 ▶ if (refaddr($games->[$idx]) == $raddr) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::refaddr($games->[$idx]) == $raddr) 0 0 0
183 0 $game = $idx;
184 0 last;
185 }
186 }
187 0 ▶ if (ref $game) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $game) 0 0 0
188 0 croak "Game not found";
189 }
190 }
191 0 $game = splice @{$games}, $game, 1; # remove from our list
192 # $self->add_bye($game->white);
193 # $self->add_bye($game->black);
194 0 $self->changed; # add_bye already calls this
195 0 return $game;
196 }
197  
198 0 ▶sub add_bye {
Subroutine add_bye: not called CC=3 SCAR=24.8
Pod documented
199 0 ▶ croak("Rounds->add_bye is deprecated") if ($deprecate > 0);
Branch: 1 branch
BranchTrueFalseTotal
if $Games::Go::AGA::DataObjects::Round::deprecate > 0 0 0 0
200 0 my ($self, $player) = @_;
201  
202 # check for duplicate IDs
203 0 ▶ return $self if (grep { $_->id eq $player->id } @{$self->{byes}});
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_->id eq $player->id;} @{$$self{"byes"};} 0 0 0
204 0 push (@{$self->{byes}}, $player);
205 0 $self->changed;
206 0 return $self;
207 }
208  
209 0 ▶sub remove_bye {
Subroutine remove_bye: not called CC=2 SCAR=17.9
Pod documented
210 0 ▶ croak("Rounds->remove_bye is deprecated") if ($deprecate > 0);
Branch: 1 branch
BranchTrueFalseTotal
if $Games::Go::AGA::DataObjects::Round::deprecate > 0 0 0 0
211 0 my ($self, $player) = @_;
212  
213 0 my $idx = $self->_find_bye_idx($player); # convert to index
214 0 my $removed = splice @{$self->{byes}}, $idx, 1;
215 0 $self->changed;
216 0 return $removed;
217 }
218  
219 0 ▶sub replace_bye {
Subroutine replace_bye: not called CC=2 SCAR=17.9
Pod documented
220 0 ▶ croak("Rounds->replace_bye is deprecated") if ($deprecate > 0);
Branch: 1 branch
BranchTrueFalseTotal
if $Games::Go::AGA::DataObjects::Round::deprecate > 0 0 0 0
221 0 my ($self, $old_bye, $new_bye) = @_;
222  
223 0 my $idx = $self->_find_bye_idx($old_bye); # convert to index
224 0 my $removed = $self->{byes}[$idx];
225 0 $self->{byes}[$idx] = $new_bye;
226 0 $self->changed;
227 0 return $removed;
228 }
229  
230 0 ▶sub swap {
Subroutine swap: not called CC=28 SCAR=67.0
Pod documented
231 0 ▶ croak("Rounds->swap is deprecated") if ($deprecate > 0);
Branch: 1 branch
BranchTrueFalseTotal
if $Games::Go::AGA::DataObjects::Round::deprecate > 0 0 0 0
232 0 my ($self, $id_0, $id_1) = @_;
233  
234 0 my ($p0, $p1, $opp0, $opp1, $item0, $item1);
235  
236 0 for my $player (@{$self->{byes}}) {
237 0 ▶ if ($player->id eq $id_0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($player->id eq $id_0) 0 0 0
238 0 $item0 = $player;
239 0 $p0 = $player;
240 }
241 0 ▶ if ($player->id eq $id_1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($player->id eq $id_1) 0 0 0
242 0 $item1 = $player;
243 0 $p1 = $player;
244 }
245 }
246  
247 0 for my $game (@{$self->{games}}) {
248 0 ▶ if ($game->white->id eq $id_0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($game->white->id eq $id_0) { } 0 0 0
elsif ($game->black->id eq $id_0) { } 0 0 0
249 0 $item0 = $game;
250 0 $p0 = $game->white;
251 0 $opp0 = $game->black;
252 }
253 elsif ($game->black->id eq $id_0) {
254 0 $item0 = $game;
255 0 $p0 = $game->black;
256 0 $opp0 = $game->white;
257 }
258 0 ▶ if ($game->white->id eq $id_1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($game->white->id eq $id_1) { } 0 0 0
elsif ($game->black->id eq $id_1) { } 0 0 0
259 0 $item1 = $game;
260 0 $p1 = $game->white;
261 0 $opp1 = $game->black;
262 }
263 elsif ($game->black->id eq $id_1) {
264 0 $item1 = $game;
265 0 $p1 = $game->black;
266 0 $opp1 = $game->white;
267 }
268 0 ▶ last if (defined $item0 and defined $item1);
Branch: 1 branch
BranchTrueFalseTotal
if defined $item0 and defined $item1 0 0 0
Condition0%0/3
defined $item0 and defined $item1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $item0 and defined $item1
defined $item0 defined $item1
Truth table0%0/3
A and B
A= defined $item0B= defined $item1
ABresult
0X0
100
111
269 };
270 0 ▶ if (not defined $item0) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $item0) 0 0 0
271 0 croak "ID $id_0 not found in games or Byes lists\n";
272 }
273 0 ▶ if (not defined $item1) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $item1) 0 0 0
274 0 croak "ID $id_1 not found in games or Byes lists\n";
275 }
276 # no-op if both are Player IDs from Byes list
277 0 ▶ return if ($item0->can('id') and $item1->can('id'));
Branch: 1 branch
BranchTrueFalseTotal
if $item0->can("id") and $item1->can("id") 0 0 0
Condition0%0/3
$item0->can("id") and $item1->can("id")
!ll&&!rl&&r
000
MC/DC0%0/2
$item0->can("id") and $item1->can("id")
$item0->can("id") $item1->can("id")
Truth table0%0/3
A and B
A= $item0->can("id")B= $item1->can("id")
ABresult
0X0
100
111
278 0 ▶ if ($item0->can('white') and $item1->can('white')) {
Branch: 3 branches
BranchTrueFalseTotal
if ($item0->can('white') and $item1->can('white')) { } 0 0 0
elsif ($item0->can('id')) { } 0 0 0
elsif ($item1->can('id')) { } 0 0 0
Condition0%0/3
$item0->can("white") and $item1->can("white")
!ll&&!rl&&r
000
MC/DC0%0/2
$item0->can("white") and $item1->can("white")
$item0->can("white") $item1->can("white")
Truth table0%0/3
A and B
A= $item0->can("white")B= $item1->can("white")
ABresult
0X0
100
111
279 # both items are Games.
280 0 ▶ if ($item0->white->id eq $item1->white->id and
Branch: 1 branch
BranchTrueFalseTotal
if ($item0->white->id eq $item1->white->id and $item0->black->id eq $item1->black->id) { } 0 0 0
Condition0%0/3
$item0->white->id eq $item1->white->id and $item0->black->id eq $item1->black->id
!ll&&!rl&&r
000
MC/DC0%0/2
$item0->white->id eq $item1->white->id and $item0->black->id eq $item1->black->id
$item0->white->id eq $item1->white->id $item0->black->id eq $item1->black->id
Truth table0%0/3
A and B
A= $item0->white->id eq $item1->white->idB= $item0->black->id eq $item1->black->id
ABresult
0X0
100
111
281 $item0->black->id eq $item1->black->id) { # same game?
282 0 $item0->swap; # just swap black and white players
283 }
284 else {
285 # swap players between two games
286 0 ▶ if ($p0->id eq $item0->white->id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p0->id eq $item0->white->id) { } 0 0 0
287 0 $item0->white($p1);
288 }
289 else {
290 0 $item0->black($p1);
291 }
292 0 ▶ if ($p1->id eq $item1->white->id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p1->id eq $item1->white->id) { } 0 0 0
293 0 $item1->white($p0);
294 }
295 else {
296 0 $item1->black($p0);
297 }
298 }
299 }
300 elsif ($item0->can('id')) {
301 # first item is a Bye Player, second is a Game
302 0 ▶ if ($p1->id eq $item1->white->id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p1->id eq $item1->white->id) { } 0 0 0
303 0 $item1->white($p0);
304 }
305 else {
306 0 $item1->black($p0);
307 }
308 0 $self->replace_bye($p0, $p1);
309 }
310 elsif ($item1->can('id')) {
311 # swap players between game and Byes list
312 0 ▶ if ($p0->id eq $item0->white->id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p0->id eq $item0->white->id) { } 0 0 0
313 0 $item0->white($p1);
314 }
315 else {
316 0 $item0->black($p1);
317 }
318 0 $self->replace_bye($p1, $p0);
319 }
320 0 ▶ $item0->handicap if ($item0->can('handicap'));
Branch: 1 branch
BranchTrueFalseTotal
if $item0->can("handicap") 0 0 0
321 0 ▶ $item1->handicap if ($item1->can('handicap'));
Branch: 1 branch
BranchTrueFalseTotal
if $item1->can("handicap") 0 0 0
322 }
323  
324 # find player in BYEs list
325 0 ▶sub _find_bye_idx {
Subroutine _find_bye_idx: not called CC=10 SCAR=47.0
326 0 ▶ croak("Rounds->_find_bye_idx is deprecated") if ($deprecate > 0);
Branch: 1 branch
BranchTrueFalseTotal
if $Games::Go::AGA::DataObjects::Round::deprecate > 0 0 0 0
327 0 my ($self, $idx) = @_;
328  
329 0 my $players = $self->{byes};
330 0 ▶ if (looks_like_number($idx)) {
Branch: 2 branches
BranchTrueFalseTotal
if (&looks_like_number($idx)) { } 0 0 0
elsif (ref $idx) { } 0 0 0
331 # already what we need
332 }
333 elsif (ref $idx) { # must be a Player dataobject
334 # find Player object with matching ID
335 FIND_REFADDR : {
336 0 my $player = $idx;
337 0 my $id = $player->id;
338 0 for my $ii (0 .. $#{$players}) {
339 0 ▶ if ($players->[$ii]->id eq $id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($players->[$ii]->id eq $id) 0 0 0
340 0 $idx = $ii;
341 0 last FIND_REFADDR;
342 }
343 }
344 0 croak "can't find BYE player with ID $id\n";
345 }
346 }
347 else {
348 # find Player with matching ID
349 FIND_ID : {
350 0 my $id = $idx;
351 0 for my $ii (0 .. $#{$players}) {
352 0 ▶ if ($players->[$ii]->id eq $id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($players->[$ii]->id eq $id) 0 0 0
353 0 $idx = $ii;
354 0 last FIND_ID;
355 }
356 }
357 0 croak "can't find player matching ID $id\n";
358 }
359 }
360 0 ▶ if ($idx < 0 or
Branch: 1 branch
BranchTrueFalseTotal
if ($idx < 0 or $idx > $#{$players;}) 0 0 0
Condition0%0/3
$idx < 0 or $idx > $#{$players;}
l!l&&r!l&&!r
000
MC/DC0%0/2
$idx < 0 or $idx > $#{$players;}
$idx < 0 $idx > $#{$players;}
Truth table0%0/3
A or B
A= $idx < 0B= $idx > $#{$players;}
ABresult
1X1
011
000
361 0 $idx > $#{$players}) {
362 0 croak "index=$idx is out of bounds\n";
363 }
364 0 return $idx;
365 }
366  
367 # format a string representing the player's rating adjustment this round
368 0 ▶sub rating_adjustment {
Subroutine rating_adjustment: not called CC=4 SCAR=30.0
Pod undocumented
369 0 my ($self, $player, $round_num) = @_;
370  
371 0 my $rating = sprintf '% 7.3f', Rank_to_Rating($player->rank);
372 0 my $adj_rating = $player->adj_rating($round_num);
373 0 ▶ $adj_rating = sprintf '% 7.3f', $adj_rating if ($adj_rating);
Branch: 1 branch
BranchTrueFalseTotal
if $adj_rating 0 0 0
374 0 ▶ if ($adj_rating and $adj_rating ne $rating) {
Branch: 1 branch
BranchTrueFalseTotal
if ($adj_rating and $adj_rating ne $rating) 0 0 0
Condition0%0/3
$adj_rating and $adj_rating ne $rating
!ll&&!rl&&r
000
MC/DC0%0/2
$adj_rating and $adj_rating ne $rating
$adj_rating $adj_rating ne $rating
Truth table0%0/3
A and B
A= $adj_ratingB= $adj_rating ne $rating
ABresult
0X0
100
111
375 0 return "$rating->$adj_rating";
376 }
377 0 return $rating;
378 }
379  
380 0 ▶sub measure_player_field_lengths {
Subroutine measure_player_field_lengths: not called CC=3 SCAR=24.8
Pod undocumented
381 0 my ($self, $player) = @_;
382  
383 0 ▶ $self->id_len (length $player->id) if (length $player->id > $self->id_len);
Branch: 1 branch
BranchTrueFalseTotal
if length $player->id > $self->id_len 0 0 0
384 0 ▶ $self->name_len(length $player->full_name) if (length $player->full_name > $self->name_len);
Branch: 1 branch
BranchTrueFalseTotal
if length $player->full_name > $self->name_len 0 0 0
385 }
386  
387 0 ▶sub measure_field_lengths {
Subroutine measure_field_lengths: not called CC=6 SCAR=37.4
Pod undocumented
388 0 my ($self) = @_;
389  
390 0 $self->id_len(0);
391 0 $self->handi_len(0);
392 0 $self->komi_len(0);
393 0 $self->name_len(0);
394 0 for my $game (@{$self->{games}}) {
395 0 $self->measure_player_field_lengths($game->white);
396 0 $self->measure_player_field_lengths($game->black);
397 0 ▶ $self->handi_len(length $game->handi) if (length $game->handi > $self->handi_len);
Branch: 1 branch
BranchTrueFalseTotal
if length $game->handi > $self->handi_len 0 0 0
398 0 ▶ $self->komi_len (length $game->komi) if (length $game->komi > $self->komi_len);
Branch: 1 branch
BranchTrueFalseTotal
if length $game->komi > $self->komi_len 0 0 0
399 }
400 0 ▶if ($deprecate == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Games::Go::AGA::DataObjects::Round::deprecate == 0) 0 0 0
401 0 for my $bye (@{$self->{byes}}) {
402 0 $self->measure_player_field_lengths($bye);
403 }
404 }
405 }
406  
407 0 ▶sub fprint {
Subroutine fprint: not called CC=6 SCAR=37.4
Pod undocumented
408 0 my ($self, $fh) = @_;
409  
410 0 my $round_num = $self->round_num;
411 0 $fh->print("# Round $round_num\n\n");
412  
413 0 $self->measure_field_lengths;
414 0 for my $game (@{$self->{games}}) {
415 0 my $w = $game->white;
416 0 my $b = $game->black;
417 0 my $result = '?';
418 0 my $winner = $game->winner;
419 0 ▶ if ($winner) {
Branch: 1 branch
BranchTrueFalseTotal
if ($winner) 0 0 0
420 0 ▶ $result = 'w' if ($winner->id eq $w->id);
Branch: 1 branch
BranchTrueFalseTotal
if $winner->id eq $w->id 0 0 0
421 0 ▶ $result = 'b' if ($winner->id eq $b->id);
Branch: 1 branch
BranchTrueFalseTotal
if $winner->id eq $b->id 0 0 0
422 }
423  
424 0 $fh->printf("%*s %*s %s %*s %*s # %*s (%s) vs (%s) %*s\n",
425 $self->id_len, $w->id,
426 $self->id_len, $b->id,
427 $result,
428 $self->handi_len, $game->handi,
429 $self->komi_len, $game->komi,
430 $self->name_len, $w->full_name,
431 $self->rating_adjustment($w, $round_num),
432 $self->rating_adjustment($b, $round_num),
433 $self->name_len, $b->full_name,
434 );
435 }
436 0 for my $bye (@{$self->{byes}}) {
437 0 $fh->printf("# BYE: %s %s, %s\n",
438 $bye->id,
439 $bye->last_name,
440 $bye->first_name,
441 );
442 }
443 0 $self->fprint_pending(0);
444 }
445  
446 2 1;
447  
448 __END__
↑ Summary DataObjects/Tournament.pm »