Eval/Chinese.pm

filter: Statementstmt 15.3% 10 / 65 Branchbran 0.0% 0 / 74 Conditioncond 0.0% 0 / 63 MC/DCmcdc 0.0% 0 / 42 Subroutinesub 28.5% 2 / 7 Podpod 100% 1 / 1 totaltotal 5.1% 13 / 252 CC 59 SCAR 63.9
CC
59
Cov
5%
_royalty_front
1056.0
_royalty_middle
210.0
_royalty_back
156.0
CRAP 594.7
↑ Summary Score/Bring/Wild.pm »
1 package Poker::Eval::Chinese;
2 1 our $VERSION = '0.12';
3  
4  
5 1 ▶use Algorithm::Combinatorics qw(combinations);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Poker::Eval::Chinese - Evaluate and score Chinese poker hands.
11  
12 =head1 VERSION
13  
14 Version 0.12
15  
16 =cut
17  
18  
19  
20 =head1 INTRODUCTION
21  
22 Calculates score plus royalties for "front", "middle", and "back" Chinese poker hands.
23  
24 =cut
25  
26 1 extends 'Poker::Eval';
27  
28 has 'chinese_scorer' => (
29 is => 'rw',
30 0 ▶ isa => sub { die "Not a Score!\n" unless $_[0]->isa('Poker::Score') },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->isa("Poker::Score") 0 0 0
31 1 required => 1,
32 );
33  
34 0 ▶sub best_hand {
Subroutine best_hand: not called CC=3 SCAR=24.8
Pod documented
35 0 my ( $self, $front, $middle, $back ) = @_;
36 0 my $front_score = $self->chinese_scorer->score($front);
37 0 my $front_royalty = &_royalty_front($front_score);
38 0 my $middle_score = $self->scorer->score($middle);
39 0 my $middle_royalty = &_royalty_middle($middle_score);
40 0 my $back_score = $self->scorer->score($back);
41 0 my $back_royalty = &_royalty_back($back_score);
42 0 ▶ if ( $back_score >= $middle_score && $middle_score >= $front_score ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($back_score >= $middle_score and $middle_score >= $front_score) 0 0 0
Condition0%0/3
$back_score >= $middle_score and $middle_score >= $front_score
!ll&&!rl&&r
000
MC/DC0%0/2
$back_score >= $middle_score and $middle_score >= $front_score
$back_score >= $middle_score $middle_score >= $front_score
Truth table0%0/3
A and B
A= $back_score >= $middle_scoreB= $middle_score >= $front_score
ABresult
0X0
100
111
43 return {
44 0 front => { score => $front_score, royalty => $front_royalty },
45 middle => { score => $middle_score, royalty => $middle_royalty },
46 back => { score => $back_score, royalty => $back_royalty },
47 };
48 }
49 }
50  
51 0 ▶sub _royalty_back {
Subroutine _royalty_back: not called CC=12 SCAR=50.5
52 0 my $score = shift;
53 0 ▶ if ( $score >= 5853 && $score <= 5862 ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($score >= 5853 and $score <= 5862) { } 0 0 0
elsif ($score >= 5863 and $score <= 7139) { } 0 0 0
elsif ($score >= 7140 and $score <= 7295) { } 0 0 0
elsif ($score >= 7296 and $score <= 7451) { } 0 0 0
elsif ($score >= 7452 and $score <= 7460) { } 0 0 0
elsif ($score == 7461) { } 0 0 0
Condition0%0/3
$score >= 5853 and $score <= 5862
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 5853 and $score <= 5862
$score >= 5853 $score <= 5862
Truth table0%0/3
A and B
A= $score >= 5853B= $score <= 5862
ABresult
0X0
100
111
54 0 return 2;
55 }
56 ▶ elsif ( $score >= 5863 && $score <= 7139 ) {
Condition0%0/3
$score >= 5863 and $score <= 7139
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 5863 and $score <= 7139
$score >= 5863 $score <= 7139
Truth table0%0/3
A and B
A= $score >= 5863B= $score <= 7139
ABresult
0X0
100
111
57 0 return 4;
58 }
59 ▶ elsif ( $score >= 7140 && $score <= 7295 ) {
Condition0%0/3
$score >= 7140 and $score <= 7295
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 7140 and $score <= 7295
$score >= 7140 $score <= 7295
Truth table0%0/3
A and B
A= $score >= 7140B= $score <= 7295
ABresult
0X0
100
111
60 0 return 6;
61 }
62 ▶ elsif ( $score >= 7296 && $score <= 7451 ) {
Condition0%0/3
$score >= 7296 and $score <= 7451
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 7296 and $score <= 7451
$score >= 7296 $score <= 7451
Truth table0%0/3
A and B
A= $score >= 7296B= $score <= 7451
ABresult
0X0
100
111
63 0 return 10;
64 }
65 ▶ elsif ( $score >= 7452 && $score <= 7460 ) {
Condition0%0/3
$score >= 7452 and $score <= 7460
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 7452 and $score <= 7460
$score >= 7452 $score <= 7460
Truth table0%0/3
A and B
A= $score >= 7452B= $score <= 7460
ABresult
0X0
100
111
66 0 return 15;
67 }
68 elsif ( $score == 7461 ) {
69 0 return 25;
70 }
71 else {
72 0 return 0;
73 }
74 }
75  
76 0 ▶sub _royalty_middle {
Subroutine _royalty_middle: not called CC=14 SCAR=53.5
77 0 my $score = shift;
78 0 ▶ if ( $score >= 4995 && $score <= 5852 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($score >= 4995 and $score <= 5852) 0 0 0
Condition0%0/3
$score >= 4995 and $score <= 5852
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 4995 and $score <= 5852
$score >= 4995 $score <= 5852
Truth table0%0/3
A and B
A= $score >= 4995B= $score <= 5852
ABresult
0X0
100
111
79 0 return 2;
80 }
81 0 ▶ if ( $score >= 5853 && $score <= 5862 ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($score >= 5853 and $score <= 5862) { } 0 0 0
elsif ($score >= 5863 and $score <= 7139) { } 0 0 0
elsif ($score >= 7140 and $score <= 7295) { } 0 0 0
elsif ($score >= 7296 and $score <= 7451) { } 0 0 0
elsif ($score >= 7452 and $score <= 7460) { } 0 0 0
elsif ($score == 7461) { } 0 0 0
Condition0%0/3
$score >= 5853 and $score <= 5862
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 5853 and $score <= 5862
$score >= 5853 $score <= 5862
Truth table0%0/3
A and B
A= $score >= 5853B= $score <= 5862
ABresult
0X0
100
111
82 0 return 4;
83 }
84 ▶ elsif ( $score >= 5863 && $score <= 7139 ) {
Condition0%0/3
$score >= 5863 and $score <= 7139
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 5863 and $score <= 7139
$score >= 5863 $score <= 7139
Truth table0%0/3
A and B
A= $score >= 5863B= $score <= 7139
ABresult
0X0
100
111
85 0 return 8;
86 }
87 ▶ elsif ( $score >= 7140 && $score <= 7295 ) {
Condition0%0/3
$score >= 7140 and $score <= 7295
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 7140 and $score <= 7295
$score >= 7140 $score <= 7295
Truth table0%0/3
A and B
A= $score >= 7140B= $score <= 7295
ABresult
0X0
100
111
88 0 return 12;
89 }
90 ▶ elsif ( $score >= 7296 && $score <= 7451 ) {
Condition0%0/3
$score >= 7296 and $score <= 7451
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 7296 and $score <= 7451
$score >= 7296 $score <= 7451
Truth table0%0/3
A and B
A= $score >= 7296B= $score <= 7451
ABresult
0X0
100
111
91 0 return 20;
92 }
93 ▶ elsif ( $score >= 7452 && $score <= 7460 ) {
Condition0%0/3
$score >= 7452 and $score <= 7460
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 7452 and $score <= 7460
$score >= 7452 $score <= 7460
Truth table0%0/3
A and B
A= $score >= 7452B= $score <= 7460
ABresult
0X0
100
111
94 0 return 30;
95 }
96 elsif ( $score == 7461 ) {
97 0 return 50;
98 }
99 else {
100 0 return 0;
101 }
102 }
103  
104 0 ▶sub _royalty_front {
Subroutine _royalty_front: not called CC=32 SCAR=69.6
105 0 my $score = shift;
106 0 ▶ if ( $score >= 2156 && $score <= 2322 ) {
Branch: 22 branches
BranchTrueFalseTotal
if ($score >= 2156 and $score <= 2322) { } 0 0 0
elsif ($score >= 2376 and $score <= 2542) { } 0 0 0
elsif ($score >= 2596 and $score <= 2762) { } 0 0 0
elsif ($score >= 2816 and $score <= 2982) { } 0 0 0
elsif ($score >= 3036 and $score <= 3202) { } 0 0 0
elsif ($score >= 3256 and $score <= 3422) { } 0 0 0
elsif ($score >= 3476 and $score <= 3642) { } 0 0 0
elsif ($score >= 3696 and $score <= 3862) { } 0 0 0
elsif ($score >= 3916 and $score <= 4082) { } 0 0 0
elsif ($score == 4995) { } 0 0 0
elsif ($score == 5061) { } 0 0 0
elsif ($score == 5127) { } 0 0 0
elsif ($score == 5193) { } 0 0 0
elsif ($score == 5259) { } 0 0 0
elsif ($score == 5325) { } 0 0 0
elsif ($score == 5391) { } 0 0 0
elsif ($score == 5457) { } 0 0 0
elsif ($score == 5523) { } 0 0 0
elsif ($score == 5589) { } 0 0 0
elsif ($score == 5655) { } 0 0 0
elsif ($score == 5721) { } 0 0 0
elsif ($score == 5787) { } 0 0 0
Condition0%0/3
$score >= 2156 and $score <= 2322
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 2156 and $score <= 2322
$score >= 2156 $score <= 2322
Truth table0%0/3
A and B
A= $score >= 2156B= $score <= 2322
ABresult
0X0
100
111
107 0 return 1;
108 }
109 ▶ elsif ( $score >= 2376 && $score <= 2542 ) {
Condition0%0/3
$score >= 2376 and $score <= 2542
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 2376 and $score <= 2542
$score >= 2376 $score <= 2542
Truth table0%0/3
A and B
A= $score >= 2376B= $score <= 2542
ABresult
0X0
100
111
110 0 return 2;
111 }
112 ▶ elsif ( $score >= 2596 && $score <= 2762 ) {
Condition0%0/3
$score >= 2596 and $score <= 2762
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 2596 and $score <= 2762
$score >= 2596 $score <= 2762
Truth table0%0/3
A and B
A= $score >= 2596B= $score <= 2762
ABresult
0X0
100
111
113 0 return 3;
114 }
115 ▶ elsif ( $score >= 2816 && $score <= 2982 ) {
Condition0%0/3
$score >= 2816 and $score <= 2982
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 2816 and $score <= 2982
$score >= 2816 $score <= 2982
Truth table0%0/3
A and B
A= $score >= 2816B= $score <= 2982
ABresult
0X0
100
111
116 0 return 4;
117 }
118 ▶ elsif ( $score >= 3036 && $score <= 3202 ) {
Condition0%0/3
$score >= 3036 and $score <= 3202
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 3036 and $score <= 3202
$score >= 3036 $score <= 3202
Truth table0%0/3
A and B
A= $score >= 3036B= $score <= 3202
ABresult
0X0
100
111
119 0 return 5;
120 }
121 ▶ elsif ( $score >= 3256 && $score <= 3422 ) {
Condition0%0/3
$score >= 3256 and $score <= 3422
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 3256 and $score <= 3422
$score >= 3256 $score <= 3422
Truth table0%0/3
A and B
A= $score >= 3256B= $score <= 3422
ABresult
0X0
100
111
122 0 return 6;
123 }
124 ▶ elsif ( $score >= 3476 && $score <= 3642 ) {
Condition0%0/3
$score >= 3476 and $score <= 3642
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 3476 and $score <= 3642
$score >= 3476 $score <= 3642
Truth table0%0/3
A and B
A= $score >= 3476B= $score <= 3642
ABresult
0X0
100
111
125 0 return 7;
126 }
127 ▶ elsif ( $score >= 3696 && $score <= 3862 ) {
Condition0%0/3
$score >= 3696 and $score <= 3862
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 3696 and $score <= 3862
$score >= 3696 $score <= 3862
Truth table0%0/3
A and B
A= $score >= 3696B= $score <= 3862
ABresult
0X0
100
111
128 0 return 8;
129 }
130 ▶ elsif ( $score >= 3916 && $score <= 4082 ) {
Condition0%0/3
$score >= 3916 and $score <= 4082
!ll&&!rl&&r
000
MC/DC0%0/2
$score >= 3916 and $score <= 4082
$score >= 3916 $score <= 4082
Truth table0%0/3
A and B
A= $score >= 3916B= $score <= 4082
ABresult
0X0
100
111
131 0 return 9;
132 }
133 elsif ( $score == 4995 ) {
134 0 return 10;
135 }
136 elsif ( $score == 5061 ) {
137 0 return 11;
138 }
139 elsif ( $score == 5127 ) {
140 0 return 12;
141 }
142 elsif ( $score == 5193 ) {
143 0 return 13;
144 }
145 elsif ( $score == 5259 ) {
146 0 return 14;
147 }
148 elsif ( $score == 5325 ) {
149 0 return 15;
150 }
151 elsif ( $score == 5391 ) {
152 0 return 16;
153 }
154 elsif ( $score == 5457 ) {
155 0 return 17;
156 }
157 elsif ( $score == 5523 ) {
158 0 return 18;
159 }
160 elsif ( $score == 5589 ) {
161 0 return 19;
162 }
163 elsif ( $score == 5655 ) {
164 0 return 20;
165 }
166 elsif ( $score == 5721 ) {
167 0 return 21;
168 }
169 elsif ( $score == 5787 ) {
170 0 return 22;
171 }
172 else {
173 0 return 0;
174 }
175 }
176  
177 =head1 AUTHOR
178  
179 Nathaniel Graham, C<< <ngraham at cpan.org> >>
180  
181 =head1 LICENSE AND COPYRIGHT
182  
183 Copyright 2016 Nathaniel Graham.
184  
185 This program is free software; you can redistribute it and/or modify it
186 under the terms of the the Artistic License (2.0). You may obtain a
187 copy of the full license at:
188  
189 L<http://www.perlfoundation.org/artistic_license_2_0>
190  
191 =cut
192  
193 1 1;
↑ Summary Score/Bring/Wild.pm »