blib/lib/Game/Durak/Result.pm

filter: Statementstmt 100% 31 / 31 Branchbran 100% 8 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 4 / 4 totaltotal 100% 55 / 55 CC 6 SCAR 7.7
CC
6
Cov
100%
places_for
3.0
result_for
3.0
out_seats
2.0
CRAP 2.2
« bin/durak ↑ Summary blib/lib/Game/Durak/Error.pm »
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.02';
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
BranchTrueFalseTotal
if $talon_left 10209 6229 16438
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
BranchTrueFalseTotal
defined $fool && $_ == $fool ? : 570 594 1164
Condition100%3/3
defined $fool and $_ == $fool
!ll&&!rl&&r
24570570
MC/DC100%2/2
defined $fool and $_ == $fool
defined $fool $_ == $fool
Truth table100%3/3
A and B
A= defined $foolB= $_ == $fool
ABresult
0X0
100
111
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
BranchTrueFalseTotal
unless @out 15281 579 15860
28  
29 579 my @holding = grep { $counts->{$_} } @seats;
30  
31 return {
32 579 ▶ outcome => 'draw',
Branch: 1 branch
BranchTrueFalseTotal
unless @holding 12 567 579
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__
« bin/durak ↑ Summary blib/lib/Game/Durak/Error.pm »