Score/Badugi27.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 30 / 30 CC 3 SCAR 6.9
CC
3
Cov
100%
_build_hands
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Game/LowA5TripleDraw.pm ↑ Summary Score.pm »
1 package Poker::Score::Badugi27;
2 2 our $VERSION = '0.12';
3  
4  
5 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Algorithm::Combinatorics qw(combinations);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Poker::Score::Badugi27 - Scoring system used in the game of Badeucy.
11  
12 =head1 VERSION
13  
14 Version 0.12
15  
16 =cut
17  
18  
19 =head1 INTRODUCTION
20  
21 Normally the lowest Badugi is A-2-3-4. However, in Badeucy aces are also high for the Badugi hand. This makes the best Badugi hand 2-3-4-5.
22  
23 =head1 SYNOPSIS
24  
25 See Poker::Score for code example.
26  
27 =cut
28  
29 2 extends 'Poker::Score::Badugi';
30  
31 1 ▶sub _build_rank_map {
Subroutine _build_rank_map: called CC=1 SCAR=0.0
32 1 my $self = shift;
33 1 $self->_rank_map(
34 {
35 '2' => '02',
36 '3' => '03',
37 '4' => '04',
38 '5' => '05',
39 '6' => '06',
40 '7' => '07',
41 '8' => '08',
42 '9' => '09',
43 'T' => '10',
44 'J' => '11',
45 'Q' => '12',
46 'K' => '13',
47 'A' => '14',
48 }
49 );
50 }
51  
52 1 ▶sub _build_hands { # generates all possible Badugi hands
Subroutine _build_hands: called CC=3 SCAR=11.0
53 1 my $self = shift;
54 1 my @all_scores = ();
55 1 for my $count ( 1 .. 4 ) {
56 4 my @scores;
57 4 my $iter = combinations( [ 2 .. 14 ], $count );
58 4 ▶ while ( my $c = $iter->next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $c = $iter->next) 1092 4 1096
59 push( @scores,
60 1092 join( '', map { sprintf( "%02d", $_ ) } sort { $b <=> $a } @$c ) );
61 }
62 4 $self->_hand_map->{scalar @all_scores} = $count . ' card Badugi';
63 4 push @all_scores, sort { $b <=> $a } @scores;
64 }
65 1 $self->hands( [@all_scores] );
66 }
67  
68 =head1 AUTHOR
69  
70 Nathaniel Graham, C<< <ngraham at cpan.org> >>
71  
72 =head1 LICENSE AND COPYRIGHT
73  
74 Copyright 2016 Nathaniel Graham.
75  
76 This program is free software; you can redistribute it and/or modify it
77 under the terms of the the Artistic License (2.0). You may obtain a
78 copy of the full license at:
79  
80 L<http://www.perlfoundation.org/artistic_license_2_0>
81  
82 =cut
83  
84 2 1;
« Game/LowA5TripleDraw.pm ↑ Summary Score.pm »