| 1 | package Game::Dominoes::Scoring; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 13 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 9 | 13 | our @EXPORT_OK = qw(count score_for bonus MAX_COUNT); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 13 | ▶ | use constant MAX_COUNT => 35; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 901683 | ▶ | sub count { | ||||||||||||||||||||||||||
|
Subroutine
count: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 901683 | my ($layout) = @_; | |||||||||||||||||||||||||||
| 15 | 901683 | ▶ | die 'Game::Dominoes::Scoring: count wants a layout' unless ref $layout; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 901683 | my $total = 0; | |||||||||||||||||||||||||||
| 17 | 901683 | for my $end ($layout->ends) { | |||||||||||||||||||||||||||
| 18 | $total += ($end->{sole} || $end->{tile}->is_double) | ||||||||||||||||||||||||||||
| 19 | ? $end->{tile}->pips | ||||||||||||||||||||||||||||
| 20 | 2167609 | ▶ | : $end->{face}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$end->{"sole"} or $end->{"tile"}->is_double
MC/DC100%2/2
$end->{"sole"} or $end->{"tile"}->is_double
$end->{"sole"}
$end->{"tile"}->is_double
Truth table100%3/3
A or B
A= $end->{"sole"}B= $end->{"tile"}->is_double
| |||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | 901683 | return $total; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 900875 | ▶ | sub score_for { | ||||||||||||||||||||||||||
|
Subroutine
score_for: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 900875 | my ($total, $scale) = @_; | |||||||||||||||||||||||||||
| 27 | 900875 | ▶ | return 0 unless defined $total && $total > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $total and $total > 0
MC/DC100%2/2
defined $total and $total > 0
defined $total
$total > 0
Truth table100%3/3
A and B
A= defined $totalB= $total > 0
| |||||||||||||||||||||||||||||
| 28 | 890097 | ▶ | return 0 if $total % 5; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 198019 | ▶ | $scale = 1 unless defined $scale && $scale > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $scale and $scale > 0
MC/DC50%1/2
defined $scale and $scale > 0
defined $scale
$scale > 0
Truth table66%2/3
A and B
A= defined $scaleB= $scale > 0
| |||||||||||||||||||||||||||||
| 30 | 198019 | return $total / $scale; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 3306 | ▶ | sub bonus { | ||||||||||||||||||||||||||
|
Subroutine
bonus: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 3306 | my ($pips, $scale) = @_; | |||||||||||||||||||||||||||
| 35 | 3306 | ▶ | return 0 unless defined $pips && $pips > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $pips and $pips > 0
MC/DC100%2/2
defined $pips and $pips > 0
defined $pips
$pips > 0
Truth table100%3/3
A and B
A= defined $pipsB= $pips > 0
| |||||||||||||||||||||||||||||
| 36 | 3253 | my $rounded = int(($pips + 2) / 5) * 5; | |||||||||||||||||||||||||||
| 37 | 3253 | ▶ | $scale = 1 unless defined $scale && $scale > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $scale and $scale > 0
MC/DC50%1/2
defined $scale and $scale > 0
defined $scale
$scale > 0
Truth table66%2/3
A and B
A= defined $scaleB= $scale > 0
| |||||||||||||||||||||||||||||
| 38 | 3253 | return $rounded / $scale; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 13 | 1; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||