File Coverage

blib/lib/Poker/Hand.pm
Criterion Covered Total %
statement 3 13 23.0
branch n/a
condition n/a
subroutine 1 6 16.6
pod 2 3 66.6
total 6 22 27.2


line stmt bran cond sub pod time code
1             package Poker::Hand;
2 1     1   7 use Moo;
  1         1  
  1         3  
3              
4             =head1 NAME
5              
6             Poker::Hand - Simple class to represent a poker hand.
7              
8             =head1 VERSION
9              
10             Version 0.01
11              
12             =cut
13              
14             our $VERSION = '0.01';
15              
16             =head1 SYNOPSIS
17              
18             This class is used internally by Poker::Eval. You probably don't want to use it directly.
19              
20             =cut
21              
22             =head1 ATTRIBUTES
23              
24             =head2 cards
25              
26             Array ref of Poker::Card objects.
27              
28             =cut
29              
30             has 'cards' => (
31             is => 'rw',
32             isa => sub { die "Not an array ref" unless ref( $_[0] ) eq 'ARRAY' },
33             builder => '_build_cards',
34             );
35              
36             sub _build_cards {
37 0     0     return [];
38             }
39              
40             =head2 best_combo
41              
42             Best combination of cards (hole + community) according to rules of game.
43              
44             =cut
45              
46             has 'best_combo' => (
47             is => 'rw',
48             isa => sub { die "Not an array ref" unless ref( $_[0] ) eq 'ARRAY' },
49             builder => '_build_best_combo',
50             );
51              
52             sub _build_best_combo {
53 0     0     return [];
54             }
55              
56             has 'wins' => (
57             is => 'rw',
58             default => sub { 0 },
59             );
60              
61             =head2 score
62              
63             Numerical score of best combination
64              
65             =cut
66              
67             has 'score' => (
68             is => 'rw',
69             default => sub { 0 },
70             );
71              
72             has 'temp_score' => (
73             is => 'rw',
74             default => sub { 0 },
75             );
76              
77             =head2 name
78              
79             english name of best combination
80              
81             =cut
82              
83             has 'name' => ( is => 'rw', );
84              
85             =head2 ev
86              
87             Expected win rate of hand in given situation
88              
89             =cut
90              
91             has 'ev' => (
92             is => 'rw',
93             default => sub { 0 },
94             );
95              
96             sub flatten {
97 0     0 0   my ( $self, $cards ) = @_;
98 0           return join( '', map { $_->rank . $_->suit } @{$cards} );
  0            
  0            
99             }
100              
101             =head2 cards_flat
102              
103             hole cards in human-readable form
104              
105             =cut
106              
107             sub cards_flat {
108 0     0 1   my $self = shift;
109 0           return $self->flatten( $self->cards );
110             }
111              
112             =head2 best_combo_flat
113              
114             best combination of cards in human-readable form
115              
116             =cut
117              
118             sub best_combo_flat {
119 0     0 1   my $self = shift;
120 0           return $self->flatten( $self->best_combo );
121             }
122              
123             =head1 AUTHOR
124              
125             Nathaniel Graham, C<< >>
126              
127             =head1 LICENSE AND COPYRIGHT
128              
129             Copyright 2016 Nathaniel Graham.
130              
131             This program is free software; you can redistribute it and/or modify it
132             under the terms of the the Artistic License (2.0). You may obtain a
133             copy of the full license at:
134              
135             L
136              
137             =cut
138              
139             1;