| 1 | package Game::Gin::Hand; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use Game::Gin::Deadwood (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 10 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 10 | has cards => (is => 'rw', isa => ArrayRef); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 35858 | ▶ | sub count { return scalar @{ $_[0]->cards } } | ||||||||||||||||||||||||||
|
Subroutine
count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 12 | ▶ | sub full { return $_[0]->count > 10 ? 1 : 0 } | ||||||||||||||||||||||||||
|
Subroutine
full: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 29579 | ▶ | sub has_card { | ||||||||||||||||||||||||||
|
Subroutine
has_card: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | 29579 | my ($self, $card) = @_; | |||||||||||||||||||||||||||
| 19 | 29579 | ▶ | return 0 unless defined $card; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 29579 | ▶ | return scalar(grep { $_ == $card } @{ $self->cards }) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 29596 | ▶ | sub add { | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 29596 | my ($self, $card) = @_; | |||||||||||||||||||||||||||
| 25 | 29596 | $self->cards([ @{ $self->cards }, $card ]); | |||||||||||||||||||||||||||
| 26 | 29596 | return $self; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 29575 | ▶ | sub remove { | ||||||||||||||||||||||||||
|
Subroutine
remove: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 29575 | my ($self, $card) = @_; | |||||||||||||||||||||||||||
| 31 | 29575 | my $seen = 0; | |||||||||||||||||||||||||||
| 32 | 29575 | ▶ | $self->cards([ grep { $_ == $card && !$seen++ ? 0 : 1 } @{ $self->cards } ]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_ == $card and not $seen++
MC/DC50%1/2
$_ == $card and not $seen++
$_ == $card
not $seen++
Truth table66%2/3
A and not(B)
A= $_ == $cardB= not $seen++
| |||||||||||||||||||||||||||||
| 33 | 29575 | return $self; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 2021 | ▶ | sub best { return Game::Gin::Deadwood::best($_[0]->cards) } | ||||||||||||||||||||||||||
|
Subroutine
best: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 57197 | ▶ | sub deadwood { return Game::Gin::Deadwood::deadwood($_[0]->cards) } | ||||||||||||||||||||||||||
|
Subroutine
deadwood: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 2 | ▶ | sub sorted { return [ sort { $a <=> $b } @{ $_[0]->cards } ] } | ||||||||||||||||||||||||||
|
Subroutine
sorted: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 10 | 1; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||