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