| 1 | package Game::Durak::Result; | ||||||||||||||||||||||||||||
| 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 Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 21 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 9 | 21 | our @EXPORT_OK = qw(out_seats places_for result_for resign_for); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 16438 | ▶ | sub out_seats { | ||||||||||||||||||||||||||
|
Subroutine
out_seats: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 12 | 16438 | my ($counts, $talon_left) = @_; | |||||||||||||||||||||||||||
| 13 | 16438 | ▶ | return () if $talon_left; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | 6229 | return grep { !$counts->{$_} } sort { $a <=> $b } keys %$counts; | |||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 582 | ▶ | sub places_for { | ||||||||||||||||||||||||||
|
Subroutine
places_for: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | 582 | my ($fool, $seats) = @_; | |||||||||||||||||||||||||||
| 19 | 582 | ▶ | return { map { $_ => (defined $fool && $_ == $fool) ? 2 : 1 } @$seats }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $fool and $_ == $fool
MC/DC100%2/2
defined $fool and $_ == $fool
defined $fool
$_ == $fool
Truth table100%3/3
A and B
A= defined $foolB= $_ == $fool
| |||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 15860 | ▶ | sub result_for { | ||||||||||||||||||||||||||
|
Subroutine
result_for: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 15860 | my ($counts, $talon_left) = @_; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 15860 | my @seats = sort { $a <=> $b } keys %$counts; | |||||||||||||||||||||||||||
| 26 | 15860 | my @out = out_seats($counts, $talon_left); | |||||||||||||||||||||||||||
| 27 | 15860 | ▶ | return undef unless @out; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 579 | my @holding = grep { $counts->{$_} } @seats; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | return { | ||||||||||||||||||||||||||||
| 32 | 579 | ▶ | outcome => 'draw', | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | fool => undef, | ||||||||||||||||||||||||||||
| 34 | places => places_for(undef, \@seats), | ||||||||||||||||||||||||||||
| 35 | } unless @holding; | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | return { | ||||||||||||||||||||||||||||
| 38 | 567 | outcome => 'fool', | |||||||||||||||||||||||||||
| 39 | fool => $holding[0], | ||||||||||||||||||||||||||||
| 40 | places => places_for($holding[0], \@seats), | ||||||||||||||||||||||||||||
| 41 | }; | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 3 | ▶ | sub resign_for { | ||||||||||||||||||||||||||
|
Subroutine
resign_for: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 3 | my ($seat, $seats) = @_; | |||||||||||||||||||||||||||
| 46 | return { | ||||||||||||||||||||||||||||
| 47 | 3 | outcome => 'resign', | |||||||||||||||||||||||||||
| 48 | fool => $seat, | ||||||||||||||||||||||||||||
| 49 | places => places_for($seat, $seats), | ||||||||||||||||||||||||||||
| 50 | }; | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 21 | 1; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||