| 1 | package Game::Cribbage::Round; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 12 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 12 | ▶ | use Game::Cribbage::Round::Score; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 12 | ▶ | use Game::Cribbage::Hands; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | has id => ( | ||||||||||||||||||||||||||||
| 12 | is => 'rw', | ||||||||||||||||||||||||||||
| 13 | isa => Int | ||||||||||||||||||||||||||||
| 14 | 12 | ); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | has number => ( | ||||||||||||||||||||||||||||
| 17 | is => 'ro', | ||||||||||||||||||||||||||||
| 18 | isa => Int | ||||||||||||||||||||||||||||
| 19 | 12 | ); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | has [qw/score current_hands/] => ( | ||||||||||||||||||||||||||||
| 22 | is => 'rw', | ||||||||||||||||||||||||||||
| 23 | isa => Object | ||||||||||||||||||||||||||||
| 24 | 12 | ); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | has complete => ( | ||||||||||||||||||||||||||||
| 27 | is => 'rw', | ||||||||||||||||||||||||||||
| 28 | isa => Bool, | ||||||||||||||||||||||||||||
| 29 | default => 0 | ||||||||||||||||||||||||||||
| 30 | 12 | ); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | has history => ( | ||||||||||||||||||||||||||||
| 33 | is => 'rw', | ||||||||||||||||||||||||||||
| 34 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 35 | default => [] | ||||||||||||||||||||||||||||
| 36 | 12 | ); | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 64 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 64 | my ($self, $game) = @_; | |||||||||||||||||||||||||||
| 40 | 64 | my %score = (); | |||||||||||||||||||||||||||
| 41 | 64 | for (@{$game->players}) { | |||||||||||||||||||||||||||
| 42 | 128 | $score{$_->player} = { | |||||||||||||||||||||||||||
| 43 | current => 0, | ||||||||||||||||||||||||||||
| 44 | last => 0 | ||||||||||||||||||||||||||||
| 45 | }; | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 64 | $self->score(Game::Cribbage::Round::Score->new(%score)); | |||||||||||||||||||||||||||
| 48 | 64 | $self->next_hands($game); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub reset_hands { | ||||||||||||||||||||||||||
|
Subroutine
reset_hands: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 1 | my ($self, $game) = @_; | |||||||||||||||||||||||||||
| 53 | 1 | $self->history([]); | |||||||||||||||||||||||||||
| 54 | 1 | my %score = (); | |||||||||||||||||||||||||||
| 55 | 1 | for (@{$game->players}) { | |||||||||||||||||||||||||||
| 56 | 2 | $score{$_->player} = { | |||||||||||||||||||||||||||
| 57 | current => 0, | ||||||||||||||||||||||||||||
| 58 | last => 0 | ||||||||||||||||||||||||||||
| 59 | }; | ||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 1 | $self->score(Game::Cribbage::Round::Score->new(%score)); | |||||||||||||||||||||||||||
| 62 | 1 | $self->next_hands($game); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 68 | ▶ | sub next_hands { | ||||||||||||||||||||||||||
|
Subroutine
next_hands: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 68 | my ($self, $game, %args) = @_; | |||||||||||||||||||||||||||
| 67 | 68 | $game->shuffle(); | |||||||||||||||||||||||||||
| 68 | 68 | my $hands = Game::Cribbage::Hands->new(%args)->init($game); | |||||||||||||||||||||||||||
| 69 | 68 | $self->current_hands($hands); | |||||||||||||||||||||||||||
| 70 | 68 | push @{$self->history}, $hands; | |||||||||||||||||||||||||||
| 71 | 68 | return $self; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 3 | ▶ | sub end_hands { | ||||||||||||||||||||||||||
|
Subroutine
end_hands: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 75 | 3 | my ($self, $game) = @_; | |||||||||||||||||||||||||||
| 76 | 3 | my $scored = $self->current_hands->score_hands(); | |||||||||||||||||||||||||||
| 77 | 3 | for my $hand (keys %{$scored}) { | |||||||||||||||||||||||||||
| 78 | 6 | $self->score->$hand->{last} = $self->score->$hand->{current}; | |||||||||||||||||||||||||||
| 79 | 6 | $self->score->$hand->{current} += $scored->{$hand}; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | 3 | $self->next_hands($game, crib_player => $self->next_crib_player($game)); | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 1 | ▶ | sub add_player_card_by_index { | ||||||||||||||||||||||||||
|
Subroutine
add_player_card_by_index: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | 1 | my ($self, $index, $player, $card) = @_; | |||||||||||||||||||||||||||
| 86 | 1 | ▶ | my $hand = ref $player ? $player->player : $player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 1 | $self->current_hands->$hand->add_by_index($index, $card); | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 508 | ▶ | sub add_player_card { | ||||||||||||||||||||||||||
|
Subroutine
add_player_card: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 91 | 508 | my ($self, $player, $card) = @_; | |||||||||||||||||||||||||||
| 92 | 508 | ▶ | my $hand = ref $player ? $player->player : $player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 508 | $self->current_hands->$hand->add($card); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 32 | ▶ | sub add_starter_card { | ||||||||||||||||||||||||||
|
Subroutine
add_starter_card: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | 32 | my ($self, $player, $card) = @_; | |||||||||||||||||||||||||||
| 98 | 32 | my $score = $self->current_hands->add_starter_card($player, $card); | |||||||||||||||||||||||||||
| 99 | 32 | ▶ | if (ref $score && $score->score) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $score and $score->score
MC/DC50%1/2
ref $score and $score->score
ref $score
$score->score
Truth table66%2/3
A and B
A= ref $scoreB= $score->score
| |||||||||||||||||||||||||||||
| 100 | 1 | ▶ | my $hand = ref $player ? $player->player : $player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 1 | $self->score->$hand->{last} = $self->score->$hand->{current}; | |||||||||||||||||||||||||||
| 102 | 1 | $self->score->$hand->{current} += $score->score; | |||||||||||||||||||||||||||
| 103 | 1 | push @{$self->current_hands->$hand->play_scored}, $score; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | 32 | return $score; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 1 | ▶ | sub validate_crib_cards { | ||||||||||||||||||||||||||
|
Subroutine
validate_crib_cards: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 109 | 1 | my ($self, $cards) = @_; | |||||||||||||||||||||||||||
| 110 | 1 | my $crib = $self->current_hands->crib_player; | |||||||||||||||||||||||||||
| 111 | 1 | $self->current_hands->$crib->validate_crib_cards($cards); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 2 | ▶ | sub next_to_play { | ||||||||||||||||||||||||||
|
Subroutine
next_to_play: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 115 | 2 | my ($self, $game) = @_; | |||||||||||||||||||||||||||
| 116 | 2 | my $next = $self->current_hands->play->next_to_play; | |||||||||||||||||||||||||||
| 117 | 2 | my $player; | |||||||||||||||||||||||||||
| 118 | 2 | for (@{$game->players}) { | |||||||||||||||||||||||||||
| 119 | 2 | ▶ | if ($next eq $_->player) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 2 | $player = $_; | |||||||||||||||||||||||||||
| 121 | 2 | last; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | 2 | return $player; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 1 | ▶ | sub next_to_play_id { | ||||||||||||||||||||||||||
|
Subroutine
next_to_play_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 128 | 1 | my ($self, $game) = @_; | |||||||||||||||||||||||||||
| 129 | 1 | my $next = $self->next_to_play($game); | |||||||||||||||||||||||||||
| 130 | 1 | return $next->id; | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 11 | ▶ | sub get_crib_player { | ||||||||||||||||||||||||||
|
Subroutine
get_crib_player: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 134 | 11 | my ($self, $game) = @_; | |||||||||||||||||||||||||||
| 135 | 11 | my $player; | |||||||||||||||||||||||||||
| 136 | 11 | for (@{$game->players}) { | |||||||||||||||||||||||||||
| 137 | 13 | ▶ | if ($self->current_hands->crib_player eq $_->player) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 11 | $player = $_; | |||||||||||||||||||||||||||
| 139 | 11 | last; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | 11 | return $player; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 5 | ▶ | sub next_crib_player { | ||||||||||||||||||||||||||
|
Subroutine
next_crib_player: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 146 | 5 | my ($self, $game) = @_; | |||||||||||||||||||||||||||
| 147 | 5 | my $current = $self->get_crib_player($game); | |||||||||||||||||||||||||||
| 148 | 5 | my $next; | |||||||||||||||||||||||||||
| 149 | 5 | ▶ | if (scalar @{$game->players} == $current->number) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 2 | $next = 'player1'; | |||||||||||||||||||||||||||
| 151 | } else { | ||||||||||||||||||||||||||||
| 152 | 3 | $next = 'player' . ($current->number + 1); | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | 5 | return $next; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 2 | ▶ | sub crib_player_id { | ||||||||||||||||||||||||||
|
Subroutine
crib_player_id: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 158 | 2 | my ($self, $game) = @_; | |||||||||||||||||||||||||||
| 159 | 2 | my $player = $self->get_crib_player($game); | |||||||||||||||||||||||||||
| 160 | 2 | ▶ | return $player ? $player->id : $player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 2 | ▶ | sub crib_player_name { | ||||||||||||||||||||||||||
|
Subroutine
crib_player_name: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 164 | 2 | my ($self, $game) = @_; | |||||||||||||||||||||||||||
| 165 | 2 | my $player = $self->get_crib_player($game); | |||||||||||||||||||||||||||
| 166 | 2 | ▶ | return $player ? $player->name : $player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 2 | ▶ | sub crib_player_number { | ||||||||||||||||||||||||||
|
Subroutine
crib_player_number: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 170 | 2 | my ($self, $game) = @_; | |||||||||||||||||||||||||||
| 171 | 2 | my $player = $self->get_crib_player($game); | |||||||||||||||||||||||||||
| 172 | 2 | ▶ | return $player ? $player->number : $player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub crib_player_cards { | ||||||||||||||||||||||||||
|
Subroutine
crib_player_cards: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 176 | 0 | my ($self, $player, $cards) = @_; | |||||||||||||||||||||||||||
| 177 | 0 | ▶ | my $hand = ref $player ? $player->player : $player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 0 | my $crib = $self->current_hands->crib_player; | |||||||||||||||||||||||||||
| 179 | 0 | return $self->current_hands->$hand->discard_cards($cards, $self->current_hands->$crib); | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 121 | ▶ | sub crib_player_card { | ||||||||||||||||||||||||||
|
Subroutine
crib_player_card: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 183 | 121 | my ($self, $player, $card_index) = @_; | |||||||||||||||||||||||||||
| 184 | 121 | my $hand = $player->player; | |||||||||||||||||||||||||||
| 185 | 121 | my $crib = $self->current_hands->crib_player; | |||||||||||||||||||||||||||
| 186 | 121 | $self->current_hands->$hand->discard($card_index, $self->current_hands->$crib); | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 1 | ▶ | sub force_play_card { | ||||||||||||||||||||||||||
|
Subroutine
force_play_card: called CC=4 SCAR=20.7
Pod
documented
| |||||||||||||||||||||||||||||
| 190 | 1 | my ($self, $card) = @_; | |||||||||||||||||||||||||||
| 191 | 1 | my ($score, $player) = $self->current_hands->force_play_card($card); | |||||||||||||||||||||||||||
| 192 | 1 | ▶ | if (ref $score && $score->score) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $score and $score->score
MC/DC0%0/2
ref $score and $score->score
ref $score
$score->score
Truth table33%1/3
A and B
A= ref $scoreB= $score->score
| |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | my $hand = ref $player ? $player->player : $player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | 0 | $self->score->$hand->{last} = $self->score->$hand->{current}; | |||||||||||||||||||||||||||
| 195 | 0 | $self->score->$hand->{current} += $score->score; | |||||||||||||||||||||||||||
| 196 | 0 | push @{$self->current_hands->$hand->play_scored}, $score; | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | 1 | return $score; | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 37 | ▶ | sub play_player_card { | ||||||||||||||||||||||||||
|
Subroutine
play_player_card: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 202 | 37 | my ($self, $player, $card_index) = @_; | |||||||||||||||||||||||||||
| 203 | 37 | my $score = $self->current_hands->play_card($player, $card_index); | |||||||||||||||||||||||||||
| 204 | 37 | ▶ | if (ref $score && $score->score) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $score and $score->score
MC/DC50%1/2
ref $score and $score->score
ref $score
$score->score
Truth table66%2/3
A and B
A= ref $scoreB= $score->score
| |||||||||||||||||||||||||||||
| 205 | 2 | ▶ | my $hand = ref $player ? $player->player : $player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 2 | $self->score->$hand->{last} = $self->score->$hand->{current}; | |||||||||||||||||||||||||||
| 207 | 2 | $self->score->$hand->{current} += $score->score; | |||||||||||||||||||||||||||
| 208 | 2 | push @{$self->current_hands->$hand->play_scored}, $score; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | 37 | return $score; | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 0 | ▶ | sub card_exists { | ||||||||||||||||||||||||||
|
Subroutine
card_exists: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 214 | 0 | my ($self, $player, $card) = @_; | |||||||||||||||||||||||||||
| 215 | 0 | return $self->current_hands->card_exists($player, $card); | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 8 | ▶ | sub get_player_card { | ||||||||||||||||||||||||||
|
Subroutine
get_player_card: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 219 | 8 | my ($self, $player, $card_index) = @_; | |||||||||||||||||||||||||||
| 220 | 8 | $self->current_hands->get_card($player, $card_index); | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 52 | ▶ | sub current_play_score { | ||||||||||||||||||||||||||
|
Subroutine
current_play_score: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 224 | 52 | my ($self) = @_; | |||||||||||||||||||||||||||
| 225 | 52 | $self->current_hands->play_score(); | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 3 | ▶ | sub last_play_score { | ||||||||||||||||||||||||||
|
Subroutine
last_play_score: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 229 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||
| 230 | 3 | $self->current_hands->last_play_score(); | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 11 | ▶ | sub cannot_play_a_card { | ||||||||||||||||||||||||||
|
Subroutine
cannot_play_a_card: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 234 | 11 | my ($self, $player) = @_; | |||||||||||||||||||||||||||
| 235 | 11 | $self->current_hands->cannot_play_a_card($player); | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 7 | ▶ | sub next_play { | ||||||||||||||||||||||||||
|
Subroutine
next_play: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 239 | 7 | my ($self, $game) = @_; | |||||||||||||||||||||||||||
| 240 | 7 | my $score = $self->current_hands->next_play($game); | |||||||||||||||||||||||||||
| 241 | 7 | ▶ | if (ref $score && $score->score) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $score and $score->score
MC/DC100%2/2
ref $score and $score->score
ref $score
$score->score
Truth table100%3/3
A and B
A= ref $scoreB= $score->score
| |||||||||||||||||||||||||||||
| 242 | 4 | ▶ | my $hand = ref $score->player ? $score->player->player : $score->player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 4 | $self->score->$hand->{last} = $self->score->$hand->{current}; | |||||||||||||||||||||||||||
| 244 | 4 | $self->score->$hand->{current} += $score->score; | |||||||||||||||||||||||||||
| 245 | 4 | push @{$self->current_hands->$hand->play_scored}, $score; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | 7 | return $self->current_hands->play; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 2 | ▶ | sub end_play { | ||||||||||||||||||||||||||
|
Subroutine
end_play: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||
| 251 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 252 | 2 | my $score = $self->current_hands->end_play(); | |||||||||||||||||||||||||||
| 253 | 2 | ▶ | if (ref $score && $score->score) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $score and $score->score
MC/DC0%0/2
ref $score and $score->score
ref $score
$score->score
Truth table33%1/3
A and B
A= ref $scoreB= $score->score
| |||||||||||||||||||||||||||||
| 254 | 2 | ▶ | my $hand = ref $score->player ? $score->player->player : $score->player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 2 | $self->score->$hand->{last} = $self->score->$hand->{current}; | |||||||||||||||||||||||||||
| 256 | 2 | $self->score->$hand->{current} += $score->score; | |||||||||||||||||||||||||||
| 257 | 2 | push @{$self->current_hands->$hand->play_scored}, $score; | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | 2 | return 1; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub identify_worst_cards { | ||||||||||||||||||||||||||
|
Subroutine
identify_worst_cards: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 263 | 0 | my ($self, $player) = @_; | |||||||||||||||||||||||||||
| 264 | 0 | ▶ | my $hand = ref $player ? $player->player : $player; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | 0 | $self->current_hands->$hand->identify_worst_cards(); | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 2 | ▶ | sub best_run_play { | ||||||||||||||||||||||||||
|
Subroutine
best_run_play: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 269 | 2 | my ($self, $player) = @_; | |||||||||||||||||||||||||||
| 270 | 2 | $self->current_hands->best_run_play($player); | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 2 | ▶ | sub hand_play_history { | ||||||||||||||||||||||||||
|
Subroutine
hand_play_history: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 274 | 2 | my ($self, $player) = @_; | |||||||||||||||||||||||||||
| 275 | 2 | my @history = @{$self->current_hands->play_history}; | |||||||||||||||||||||||||||
| 276 | 2 | my $current = pop @history; | |||||||||||||||||||||||||||
| 277 | 2 | my $count_cards = 0; | |||||||||||||||||||||||||||
| 278 | 2 | for (@history) { | |||||||||||||||||||||||||||
| 279 | 0 | $count_cards += scalar @{$_->cards}; | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | return { | ||||||||||||||||||||||||||||
| 282 | 2 | used_count => $count_cards, | |||||||||||||||||||||||||||
| 283 | current_play => $current | ||||||||||||||||||||||||||||
| 284 | }; | ||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 12 | 1; | |||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | __END__ | ||||||||||||||||||||||||||||