line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Poker::Score::Badugi; |
2
|
1
|
|
|
1
|
|
1718
|
use Moo; |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
6
|
|
3
|
1
|
|
|
1
|
|
648
|
use Algorithm::Combinatorics qw(combinations); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Poker::Score::Badugi - Identify and score specific Badugi poker hand. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Version 0.01 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
See Poker::Score for code example. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
extends 'Poker::Score'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _build_rank_map { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
$self->_rank_map( |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
'A' => '01', |
30
|
|
|
|
|
|
|
'2' => '02', |
31
|
|
|
|
|
|
|
'3' => '03', |
32
|
|
|
|
|
|
|
'4' => '04', |
33
|
|
|
|
|
|
|
'5' => '05', |
34
|
|
|
|
|
|
|
'6' => '06', |
35
|
|
|
|
|
|
|
'7' => '07', |
36
|
|
|
|
|
|
|
'8' => '08', |
37
|
|
|
|
|
|
|
'9' => '09', |
38
|
|
|
|
|
|
|
'T' => '10', |
39
|
|
|
|
|
|
|
'J' => '11', |
40
|
|
|
|
|
|
|
'Q' => '12', |
41
|
|
|
|
|
|
|
'K' => '13', |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub stringify_cards { |
47
|
|
|
|
|
|
|
my ( $self, $cards ) = @_; |
48
|
|
|
|
|
|
|
return join( '', |
49
|
|
|
|
|
|
|
sort { $b <=> $a } |
50
|
|
|
|
|
|
|
map { sprintf( "%02d", $self->rank_val( $_->rank ) ) } @$cards ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _build_hands { # generates all possible Badugi hands |
54
|
|
|
|
|
|
|
my $self = shift; |
55
|
|
|
|
|
|
|
my @all_scores = (); |
56
|
|
|
|
|
|
|
for my $count ( 1 .. 4 ) { |
57
|
|
|
|
|
|
|
my @scores; |
58
|
|
|
|
|
|
|
my $iter = combinations( [ 1 .. 13 ], $count ); |
59
|
|
|
|
|
|
|
while ( my $c = $iter->next ) { |
60
|
|
|
|
|
|
|
push( @scores, |
61
|
|
|
|
|
|
|
join( '', map { sprintf( "%02d", $_ ) } sort { $b <=> $a } @$c ) ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
$self->_hand_map->{scalar @all_scores} = $count . ' card Badugi'; |
64
|
|
|
|
|
|
|
push @all_scores, sort { $b <=> $a } @scores; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
$self->hands( [@all_scores] ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Nathaniel Graham, C<< >> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Copyright 2016 Nathaniel Graham. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
78
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
79
|
|
|
|
|
|
|
copy of the full license at: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
L |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |