Eval/Badugi.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 8 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 92.3% 48 / 52 CC 8 SCAR 18.1
CC
8
Cov
95%
best_hand
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.1
« Game/Low27SingleDraw.pm ↑ Summary Game.pm »
1 package Poker::Eval::Badugi;
2 2 our $VERSION = '0.12';
3  
4  
5 2 ▶use Algorithm::Combinatorics qw(combinations);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Poker::Score::Badugi;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 Poker::Eval::Badugi - Evaluate and score Badugi poker hands.
12  
13 =head1 VERSION
14  
15 Version 0.12
16  
17 =cut
18  
19  
20  
21 =head1 SYNOPSIS
22  
23 See Poker::Eval for code examples
24  
25 =cut
26  
27 2 extends 'Poker::Eval';
28  
29 4 ▶sub best_hand {
Subroutine best_hand: called CC=8 SCAR=20.8
Pod documented
30 4 my ( $self, $hole ) = @_;
31 4 my $best = Poker::Hand->new(cards => $hole);
32 4 ▶ my $iter = combinations( $hole, scalar @$hole > 4 ? 4 : scalar @$hole);
Branch: 1 branch
BranchTrueFalseTotal
scalar @$hole > 4 ? : 2 2 4
33 4 ▶ while (my $combo = $iter->next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $combo = $iter->next) 12 4 16
34 12 my (@list, %seen);
35 12 for my $c (sort { $self->scorer->_rank_map->{$a->rank} <=> $self->scorer->_rank_map->{$b->rank} } @$combo) {
36 48 ▶ if ( !$seen{ $c->suit } && !$seen{ $c->rank } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seen{$c->suit} or $seen{$c->rank}) 42 6 48
Condition66%2/3
$seen{$c->suit} or $seen{$c->rank}
l!l&&r!l&&!r
6042
MC/DC50%1/2
$seen{$c->suit} or $seen{$c->rank}
$seen{$c->suit} $seen{$c->rank}
Truth table66%2/3
A or B
A= $seen{$c->suit}B= $seen{$c->rank}
ABresult
1X1
011
000
37 42 push @list, $c;
38 42 $seen{ $c->suit }++;
39 42 $seen{ $c->rank }++;
40 }
41 }
42 12 my $score = $self->scorer->score( [@list] );
43 12 ▶ if ( defined $score && $score >= $best->score ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $score and $score >= $best->score) 4 8 12
Condition66%2/3
defined $score and $score >= $best->score
!ll&&!rl&&r
084
MC/DC50%1/2
defined $score and $score >= $best->score
defined $score $score >= $best->score
Truth table66%2/3
A and B
A= defined $scoreB= $score >= $best->score
ABresult
0X0
100
111
44 4 $best->score($score);
45 4 $best->best_combo(\@list);
46 }
47 }
48 4 $best->name($self->scorer->hand_name( $best->score ));
49 4 return $best;
50 }
51  
52 =head1 AUTHOR
53  
54 Nathaniel Graham, C<< <ngraham at cpan.org> >>
55  
56 =head1 LICENSE AND COPYRIGHT
57  
58 Copyright 2016 Nathaniel Graham.
59  
60 This program is free software; you can redistribute it and/or modify it
61 under the terms of the the Artistic License (2.0). You may obtain a
62 copy of the full license at:
63  
64 L<http://www.perlfoundation.org/artistic_license_2_0>
65  
66 =cut
67  
68 2 1;
« Game/Low27SingleDraw.pm ↑ Summary Game.pm »