| 1 | package Game::Schnapsen::Hand; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 21 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 21 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 21 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 21 | ▶ | use Game::Schnapsen::Card (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 21 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 21 | has cards => (is => 'rw', isa => ArrayRef); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 458153 | ▶ | sub count { return scalar @{ $_[0]->cards } } | ||||||||||||||||||||||||||
|
Subroutine
count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 74544 | ▶ | sub has_card { | ||||||||||||||||||||||||||
|
Subroutine
has_card: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 74544 | my ($self, $card) = @_; | |||||||||||||||||||||||||||
| 18 | 74544 | ▶ | return 0 unless defined $card; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 74544 | ▶ | return scalar(grep { $_ == $card } @{ $self->cards }) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 42645 | ▶ | sub add { | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 42645 | my ($self, $card) = @_; | |||||||||||||||||||||||||||
| 24 | 42645 | $self->cards([ @{ $self->cards }, $card ]); | |||||||||||||||||||||||||||
| 25 | 42645 | return $self; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 76263 | ▶ | sub remove { | ||||||||||||||||||||||||||
|
Subroutine
remove: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 76263 | my ($self, $card) = @_; | |||||||||||||||||||||||||||
| 30 | 76263 | my $seen = 0; | |||||||||||||||||||||||||||
| 31 | 76263 | ▶ | $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++
| |||||||||||||||||||||||||||||
| 32 | 76263 | return $self; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub points { | ||||||||||||||||||||||||||
|
Subroutine
points: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 37 | 0 | my $total = 0; | |||||||||||||||||||||||||||
| 38 | 0 | $total += Game::Schnapsen::Card::points_of($_) for @{ $self->cards }; | |||||||||||||||||||||||||||
| 39 | 0 | return $total; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub of_suit { | ||||||||||||||||||||||||||
|
Subroutine
of_suit: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 0 | my ($self, $suit) = @_; | |||||||||||||||||||||||||||
| 44 | 0 | return [ grep { Game::Schnapsen::Card::suit_of($_) eq $suit } @{ $self->cards } ]; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1012 | ▶ | sub sorted { return [ sort { $a <=> $b } @{ $_[0]->cards } ] } | ||||||||||||||||||||||||||
|
Subroutine
sorted: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 21 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||