Eval/Community.pm

filter: Statementstmt 100% 27 / 27 Branchbran 83.3% 5 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 5 / 5 Podpod 50.0% 1 / 2 totaltotal 95.5% 43 / 45 CC 5 SCAR 11.7
CC
5
Cov
97%
best_hand
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« Game/Stud.pm ↑ Summary Dealer.pm »
1 package Poker::Eval::Community;
2 10 our $VERSION = '0.12';
3  
4  
5 10 ▶use Algorithm::Combinatorics qw(combinations);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Poker::Eval::Community - Evaluate and score hand using any combination of hole and community cards.
11  
12 =head1 VERSION
13  
14 Version 0.12
15  
16 =cut
17  
18  
19  
20 =head1 SYNOPSIS
21  
22 See Poker::Eval for example code.
23  
24 =cut
25  
26 10 extends 'Poker::Eval';
27  
28 10 has 'card_count' => (
29 is => 'rw',
30 builder => '_build_card_count',
31 );
32  
33 29 ▶sub _build_card_count {
Subroutine _build_card_count: called CC=1 SCAR=0.0
34 29 return 5;
35 }
36  
37 29565 ▶sub best_hand {
Subroutine best_hand: called CC=5 SCAR=16.1
Pod documented
38 29565 my ( $self, $hole ) = @_;
39 29565 my $hand = Poker::Hand->new(cards => $hole);
40 return $hand
41 if $self->card_count >
42 29565 ▶ ( scalar @$hole + scalar @{ $self->community_cards } );
Branch: 1 branch
BranchTrueFalseTotal
if $self->card_count > scalar @$hole + scalar(@{$self->community_cards;}) 0 29565 29565
43 29565 my $iter = $self->make_iter($hole);
44 29565 ▶ while ( my $combo = $iter->next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $combo = $iter->next) 620800 29565 650365
45 620800 my $score = $self->scorer->score($combo);
46 620800 ▶ if ( defined $score && $score >= $hand->score ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $score and $score >= $hand->score) 94425 526375 620800
Condition100%3/3
defined $score and $score >= $hand->score
!ll&&!rl&&r
2052635594425
MC/DC100%2/2
defined $score and $score >= $hand->score
defined $score $score >= $hand->score
Truth table100%3/3
A and B
A= defined $scoreB= $score >= $hand->score
ABresult
0X0
100
111
47 94425 $hand->score($score);
48 94425 $hand->best_combo($combo);
49 }
50 }
51 29565 $hand->name($self->scorer->hand_name( $hand->score ));
52 29565 return $hand;
53 }
54  
55 29565 ▶sub make_iter {
Subroutine make_iter: called CC=1 SCAR=0.0
Pod undocumented
56 29565 my ( $self, $hole ) = @_;
57 my $iter =
58 29565 combinations( [ @$hole, @{ $self->community_cards } ], $self->card_count );
59 29565 return $iter;
60 }
61  
62 =head1 AUTHOR
63  
64 Nathaniel Graham, C<< <ngraham at cpan.org> >>
65  
66 =head1 LICENSE AND COPYRIGHT
67  
68 Copyright 2016 Nathaniel Graham.
69  
70 This program is free software; you can redistribute it and/or modify it
71 under the terms of the the Artistic License (2.0). You may obtain a
72 copy of the full license at:
73  
74 L<http://www.perlfoundation.org/artistic_license_2_0>
75  
76 =cut
77  
78 10 1;
« Game/Stud.pm ↑ Summary Dealer.pm »