| 1 | package Game::Backgammon::Turn; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 8 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | has player => ( | ||||||||||||||||||||||||||||
| 11 | is => 'ro', | ||||||||||||||||||||||||||||
| 12 | isa => Str | ||||||||||||||||||||||||||||
| 13 | 8 | ); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | has [qw/dice moves/] => ( | ||||||||||||||||||||||||||||
| 16 | is => 'ro', | ||||||||||||||||||||||||||||
| 17 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 18 | default => [] | ||||||||||||||||||||||||||||
| 19 | 8 | ); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub is_doubles { | ||||||||||||||||||||||||||
|
Subroutine
is_doubles: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | 0 | my $d = $_[0]->dice; | |||||||||||||||||||||||||||
| 23 | 0 | ▶ | return (@$d >= 2 && $d->[0] == $d->[1]) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$d >= 2 and $d->[0] == $d->[1]
MC/DC0%0/2
@$d >= 2 and $d->[0] == $d->[1]
@$d >= 2
$d->[0] == $d->[1]
Truth table0%0/3
A and B
A= @$d >= 2B= $d->[0] == $d->[1]
| |||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub with_move { | ||||||||||||||||||||||||||
|
Subroutine
with_move: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 0 | my ($self, $move) = @_; | |||||||||||||||||||||||||||
| 28 | return ref($self)->new( | ||||||||||||||||||||||||||||
| 29 | player => $self->player, | ||||||||||||||||||||||||||||
| 30 | 0 | dice => [ @{ $self->dice } ], | |||||||||||||||||||||||||||
| 31 | 0 | moves => [ @{ $self->moves }, $move ] | |||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub pips_used { | ||||||||||||||||||||||||||
|
Subroutine
pips_used: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 37 | 0 | my $n = 0; | |||||||||||||||||||||||||||
| 38 | 0 | $n += $_->die for @{ $self->moves }; | |||||||||||||||||||||||||||
| 39 | 0 | return $n; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 200 | ▶ | sub is_forfeit { return scalar @{ $_[0]->moves } ? 0 : 1 } | ||||||||||||||||||||||||||
|
Subroutine
is_forfeit: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 920 | ▶ | sub notation { | ||||||||||||||||||||||||||
|
Subroutine
notation: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 920 | my ($self) = @_; | |||||||||||||||||||||||||||
| 46 | 920 | ▶ | return '(no play)' unless @{ $self->moves }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 883 | my @out; | |||||||||||||||||||||||||||
| 48 | 883 | my ($run, $count) = (undef, 0); | |||||||||||||||||||||||||||
| 49 | 883 | for my $m (@{ $self->moves }, undef) { | |||||||||||||||||||||||||||
| 50 | 2897 | ▶ | if ($run && $run->same_as($m)) { $count++; next } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$run and $run->same_as($m)
MC/DC100%2/2
$run and $run->same_as($m)
$run
$run->same_as($m)
Truth table100%3/3
A and B
A= $runB= $run->same_as($m)
| |||||||||||||||||||||||||||||
| 51 | 2762 | ▶ | if ($run) { push @out, $run->notation . ($count > 1 ? "($count)" : '') } | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 52 | 2762 | ($run, $count) = ($m, 1); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 883 | return join ' ', @out; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 823556 | ▶ | sub key { | ||||||||||||||||||||||||||
|
Subroutine
key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 823556 | my ($self) = @_; | |||||||||||||||||||||||||||
| 59 | 823556 | return join ',', sort map { $_->notation } @{ $self->moves }; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub stringify { | ||||||||||||||||||||||||||
|
Subroutine
stringify: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | 0 | return $_[0]->notation; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 8 | 1; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | __END__ | ||||||||||||||||||||||||||||