Hand.pm

filter: Statementstmt 90.6% 29 / 32 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 66.6% 2 / 3 totaltotal 84.6% 44 / 52 CC 3 SCAR 3.6
CC
3
Cov
86%
__ANON__
2.1
__ANON__
2.1
_build_cards
2.0
CRAP 1.4
« Score/Low27.pm ↑ Summary Score/Chinese.pm »
1 package Poker::Hand;
2 12 our $VERSION = '0.12';
3  
4  
5 12 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 Poker::Hand - Simple class to represent a poker hand.
10  
11 =head1 VERSION
12  
13 Version 0.12
14  
15 =cut
16  
17  
18 =head1 SYNOPSIS
19  
20 This class is used internally by Poker::Eval and Poker::Game.
21 You probably don't want to use it directly.
22  
23 =cut
24  
25 =head1 ATTRIBUTES
26  
27 =head2 cards
28  
29 Array ref of Poker::Card objects.
30  
31 =cut
32  
33 has 'cards' => (
34 is => 'rw',
35 29638 ▶ isa => sub { die "Not an array ref" unless ref( $_[0] ) eq 'ARRAY' },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[0] eq "ARRAY" 0 29638 29638
36 12 builder => '_build_cards',
37 );
38  
39 0 ▶sub _build_cards {
Subroutine _build_cards: not called CC=1 SCAR=6.9
40 0 return [];
41 }
42  
43 =head2 best_combo
44  
45 Best combination of cards (hole + community) according to rules of game.
46  
47 =cut
48  
49 has 'best_combo' => (
50 is => 'rw',
51 124139 ▶ isa => sub { die "Not an array ref" unless ref( $_[0] ) eq 'ARRAY' },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[0] eq "ARRAY" 0 124139 124139
52 12 builder => '_build_best_combo',
53 );
54  
55 29634 ▶sub _build_best_combo {
Subroutine _build_best_combo: called CC=1 SCAR=0.0
56 29634 return [];
57 }
58  
59 has 'wins' => (
60 is => 'rw',
61 29634 ▶ default => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
62 12 );
63  
64 =head2 score
65  
66 Numerical score of best combination (high direction)
67  
68 =cut
69  
70 has 'score' => (
71 is => 'rw',
72 29634 ▶ default => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
73 12 );
74  
75 has 'temp_score' => (
76 is => 'rw',
77 29634 ▶ default => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
78 12 );
79  
80 =head2 name
81  
82 English name of best high combination
83  
84 =cut
85  
86 12 has 'name' => ( is => 'rw', );
87  
88 =head2 low_score / low_name / low_combo
89  
90 Optional low-direction result for split-pot games (e.g. Omaha Hi-Lo).
91 Undefined when the hand does not qualify for low.
92  
93 =cut
94  
95 12 has 'low_score' => ( is => 'rw' );
96 12 has 'low_name' => ( is => 'rw' );
97 has 'low_combo' => (
98 is => 'rw',
99 29634 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
100 12 );
101  
102 =head2 ev
103  
104 Expected win rate of hand in given situation
105  
106 =cut
107  
108 has 'ev' => (
109 is => 'rw',
110 29634 ▶ default => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
111 12 );
112  
113 2 ▶sub flatten {
Subroutine flatten: called CC=1 SCAR=0.0
Pod undocumented
114 2 my ( $self, $cards ) = @_;
115 2 return join( '', map { $_->rank . $_->suit } @{$cards} );
116 }
117  
118 =head2 cards_flat
119  
120 hole cards in human-readable form
121  
122 =cut
123  
124 2 ▶sub cards_flat {
Subroutine cards_flat: called CC=1 SCAR=0.0
Pod documented
125 2 my $self = shift;
126 2 return $self->flatten( $self->cards );
127 }
128  
129 =head2 best_combo_flat
130  
131 best combination of cards in human-readable form
132  
133 =cut
134  
135 0 ▶sub best_combo_flat {
Subroutine best_combo_flat: not called CC=1 SCAR=6.9
Pod documented
136 0 my $self = shift;
137 0 return $self->flatten( $self->best_combo );
138 }
139  
140 =head1 AUTHOR
141  
142 Nathaniel Graham, C<< <ngraham at cpan.org> >>
143  
144 =head1 LICENSE AND COPYRIGHT
145  
146 Copyright 2016 Nathaniel Graham.
147  
148 This program is free software; you can redistribute it and/or modify it
149 under the terms of the the Artistic License (2.0). You may obtain a
150 copy of the full license at:
151  
152 L<http://www.perlfoundation.org/artistic_license_2_0>
153  
154 =cut
155  
156 12 1;
« Score/Low27.pm ↑ Summary Score/Chinese.pm »