| 1 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # FILE: Games::Go::AGA::DataObjects::Player.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # PODNAME: Games::Go::AGA::DataObjects::Player | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: model an AGA player | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # AUTHOR: Reid Augustin (REID), <reid@lucidport.com> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # COMPANY: LucidPort Technology, Inc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # CREATED: 11/19/2010 03:13:05 PM PST | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | package Games::Go::AGA::DataObjects::Player; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use Carp qw{ cluck carp croak }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use Scalar::Util qw( refaddr looks_like_number ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use Games::Go::AGA::Parse::Util qw( normalize_ID Rank_to_Rating ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use Games::Go::AGA::DataObjects::Types qw( is_Rating ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | our $VERSION = '0.107'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | has id => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | isa => 'ID', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | trigger => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # TODO: make this a coercion? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 29 | ▶ | my ($self, $new) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 29 | $self->{id} = normalize_ID($new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 29 | $self->changed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | has last_name => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 25 | ▶ | trigger => sub { shift->changed; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | has first_name => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 25 | ▶ | trigger => sub { shift->changed; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | has rank => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | isa => 'Rank_or_Rating', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | trigger => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 26 | ▶ | my ($self, $new) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 26 | ▶ | if (is_Rating($new)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 16 | $self->{rank} += 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 26 | shift->changed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | has date => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | default => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | trigger => sub { shift->changed; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | has membership => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | default => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | trigger => sub { shift->changed; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | has state => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | default => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | trigger => sub { shift->changed; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | has club => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | default => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | trigger => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 18 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 18 | $self->{club} = uc $self->{club}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 18 | $self->changed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 4 | has flags => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | isa => 'ArrayRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | has comment => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | default => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 21 | ▶ | trigger => sub { shift->changed; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | has sigma => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | isa => 'Num', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | trigger => sub { shift->changed; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | has games => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | isa => 'ArrayRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 25 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # trigger => sub { shift->changed; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | has change_callback => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | isa => 'Maybe[CodeRef]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 25 | ▶ | default => sub { sub { } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 25 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 25 | ▶ | $self->{flags} ||= []; # empty array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"flags"} ||= []
MC/DC100%1/1
$self->{"flags"} ||= []
$self->{"flags"}
Truth table100%2/2
A
A= $self->{"flags"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | sub changed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 144 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
changed: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 144 | ▶ | &{$self->change_callback}($self) if ($self->{change_callback}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | sub full_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
full_name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if (my $name = $self->first_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return join(', ', $self->last_name, $name), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # some players don't have first name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return $self->last_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # sub comment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # if (defined $_[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # $self->{comment} = join '', @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # delete $self->{comment}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # return $self->{comment}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | sub add_game { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 11 | ▶ | my ($self, $game, $idx) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_game: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 11 | my $add_refaddr = refaddr $game; # ID of game to add | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 11 | ▶ | if(not grep { (refaddr $_) == $add_refaddr } @{$self->{games}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | #print STDERR "add_game $game to " . $self->full_name . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 7 | ▶ | if (@_ < 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 7 | push @{$self->{games}}, $game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | splice @{$self->{games}}, $idx, 0, $game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | #$self->changed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | sub delete_game { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | ▶ | my ($self, $idx, $id1) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_game: called CC=15 SCAR=42.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | my $games = $self->{games}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | ▶ | if (not looks_like_number($idx)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | ▶ | if (ref $idx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # $idx is actually a Game object, find its idx in our games | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | my $game = $idx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | my $refaddr = refaddr($game); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | for my $ii (0 .. $#{$games}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | ▶ | if (refaddr($games->[$ii]) == $refaddr) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | $idx = $ii; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | elsif ($id1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $id0 = $idx; # idx is actually ID_0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | for my $ii (0 .. $#{$games}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if (($games->[$ii]->black->id eq $id0 and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$games->[$ii]->black->id eq $id0 and $games->[$ii]->white->id eq $id1 or $games->[$ii]->black->id eq $id1 and $games->[$ii]->white->id eq $id0
$games->[$ii]->black->id eq $id0 and $games->[$ii]->white->id eq $id1
$games->[$ii]->black->id eq $id1 and $games->[$ii]->white->id eq $id0
MC/DC0%0/4
$games->[$ii]->black->id eq $id0 and $games->[$ii]->white->id eq $id1 or $games->[$ii]->black->id eq $id1 and $games->[$ii]->white->id eq $id0
$games->[$ii]->black->id eq $id0
$games->[$ii]->white->id eq $id1
$games->[$ii]->black->id eq $id1
$games->[$ii]->white->id eq $id0
Truth table0%0/7
A and B or C and D
A= $games->[$ii]->black->id eq $id0B= $games->[$ii]->white->id eq $id1C= $games->[$ii]->black->id eq $id1D= $games->[$ii]->white->id eq $id0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | $games->[$ii]->white->id eq $id1) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ($games->[$ii]->black->id eq $id1 and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | $games->[$ii]->white->id eq $id0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $idx = $ii; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | ▶ | if (not looks_like_number($idx)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if (ref $idx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | croak(sprintf "Can't find game %s vs %s in games list for %s\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | $idx->white->last_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | $idx->black->last_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | $self->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | $idx ||= '<>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$idx ||= "<>"
MC/DC0%0/1
$idx ||= "<>"
$idx
Truth table0%0/2
A
A= $idx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | $id1 ||= '<>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$id1 ||= "<>"
MC/DC0%0/1
$id1 ||= "<>"
$id1
Truth table0%0/2
A
A= $id1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $id = $self->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | croak("Can't find game $idx vs $id1 in games list for $id\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | splice(@{$games}, $idx, 1); # remove from list | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | #$self->changed; # not recorded in any file, so ignore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | return $idx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | sub adj_rating { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | my ($self, $round_num, $new) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
adj_rating: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | $self->{adj_rating} = [] if (not $self->{adj_rating}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if (defined $new) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | croak "round number not defined" if (not defined $round_num); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->{adj_rating}[$round_num] = $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if (defined $round_num) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return $self->{adj_rating}[$round_num]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | return $self->{adj_rating}[-1] || $self->rating; # rating if no adjusted rating has been set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'adj_rating'}[-1] || $self->rating
MC/DC0%0/2
$self->{'adj_rating'}[-1] || $self->rating
$self->{'adj_rating'}[-1]
$self->rating
Truth table0%0/3
A || B
A= $self->{'adj_rating'}[-1]B= $self->rating
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | sub handicap_rating { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | my ($self, $new) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handicap_rating: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if ($new) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $self->{handicap_rating} = $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | return defined $self->{handicap_rating} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | ? $self->{handicap_rating} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | : $self->rating; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | sub opponents { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
opponents: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my @opps = map { $_->opponent($self) } @{$self->{games}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | return wantarray ? @opps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | : scalar @opps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | sub defeated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defeated: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $me = refaddr $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my @defeated = map { $_->loser } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | grep { defined $_->winner and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | (refaddr($_->winner) == $me) } @{$self->{games}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | return wantarray ? @defeated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | : scalar @defeated; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | sub defeated_by { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defeated_by: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my $me = refaddr $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my @defeated_by = map { $_->winner } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | grep { defined $_->loser and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | (refaddr($_->loser) == $me) } @{$self->{games}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | return wantarray ? @defeated_by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | : scalar @defeated_by; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # games with no result (usually means still playing) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | sub no_result { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
no_result: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my $me = refaddr $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | my @no_result = map { (refaddr($_->black) == $me) ? $_->white : $_->black } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | grep { not defined $_->loser and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $_->loser || defined $_->winner
MC/DC0%0/2
defined $_->loser || defined $_->winner
defined $_->loser
defined $_->winner
Truth table0%0/3
A || B
A= defined $_->loserB= defined $_->winner
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | not defined $_->winner } @{$self->{games}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | return wantarray ? @no_result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | : scalar @no_result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | sub wins { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wins: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 6 | my $me = refaddr $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 6 | ▶ | my @wins = grep { (refaddr($_->winner) || -1) == $me} @{$self->{games}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
builtin::refaddr($_->winner) || -1
MC/DC0%0/1
builtin::refaddr($_->winner) || -1
builtin::refaddr($_->winner)
Truth table50%1/2
A
A= builtin::refaddr($_->winner)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | return wantarray ? @wins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 6 | ▶ | : scalar @wins; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | sub losses { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
losses: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | my $me = refaddr $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | my @losses = grep {defined $_->winner and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | refaddr $_->winner != $me} @{$self->{games}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | return wantarray ? @losses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | ▶ | : scalar @losses; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | sub completed_games { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
completed_games: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my @games = grep { $_->winner } @{$self->{games}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | return wantarray ? @games | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | : scalar @games; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | sub drop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | my ($self, $round_num) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
drop: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | return 1 if ($self->get_flag('drop')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if (defined $round_num) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | return 1 if ($self->get_flag("drop$round_num")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | sub bye { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bye: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | return $self->get_flag('bye'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | sub get_flag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | my ($self, $key) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_flag: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my $flags = $self->{flags}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $ii = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | for (@{$flags}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | last if (uc $key eq uc $flags->[$ii]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $ii++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | return $flags->[$ii]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | sub set_flag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | my ($self, $key) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_flag: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $flags = $self->{flags}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $ii = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | for (@{$flags}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | last if (uc $key eq uc $flags->[$ii]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $ii++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $flags->[$ii] = $key; # add if not there, overwrite if it is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $self->changed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | return $flags->[$ii]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | sub clear_flag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | my ($self, $key) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_flag: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $flags = $self->{flags}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my $ii = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | for (@{$flags}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | last if (uc $key eq uc $flags->[$ii]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $ii++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if ($ii < @{$flags}) { # if element was found | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | splice @{$flags}, $ii, 1; # remove it | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | $self->changed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | sub rating { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 36 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rating: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 36 | return Rank_to_Rating($self->rank); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # in register.tde format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | sub fprint_register { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | my ($self, $fh) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fprint_register: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my @flags = @{$self->{flags}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | push(@flags, "Club=" . $self->club) if ($self->club); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $fh->printf("%s %s, %s %s", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | $self->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | $self->last_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | $self->first_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | $self->rank, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | $fh->printf(" %s", join(' ', @flags)) if (@flags); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my $comment = $self->comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if ($comment) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $comment =~ s/\n/\\n/g; # prevent newlines which would mess things up | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $comment =~ s/^\s*(.*?)\s*$/$1/; # remove preceding and trailing whitespace | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $fh->print(" # $comment"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $fh->print("\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # in tdlist format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | sub fprint_tdlist { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | my ($self, $fh) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fprint_tdlist: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $fh->printf("%s, %s %s %s %s %s %s %s\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | $self->last_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | $self->first_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | $self->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | $self->membership, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | $self->rank, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | $self->date, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | $self->club, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | $self->state, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 4 | ▶ | no Mouse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||