Game/OmahaHiLo.pm

filter: Statementstmt 91.6% 55 / 60 Branchbran 50.0% 6 / 12 Conditioncond 41.6% 5 / 12 MC/DCmcdc 12.5% 1 / 8 Subroutinesub 100% 13 / 13 Podpod n/a totaltotal 76.1% 80 / 105 CC 11 SCAR 16.4
CC
11
Cov
79%
__ANON__
11.0
__ANON__
4.7
BEGIN
1.0
CRAP 5.1
« Game.pm ↑ Summary Game/SevenCardStudHiLo.pm »
1 package Poker::Game::OmahaHiLo;
2 2 our $VERSION = '0.12';
3  
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Poker::Eval::Omaha;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Poker::Score::High;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Poker::Score::Low8;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =head1 NAME
13  
14 Poker::Game::OmahaHiLo - Omaha Hold'em high/low 8-or-better
15  
16 =head1 VERSION
17  
18 Version 0.12
19  
20 =cut
21  
22  
23 =head1 SYNOPSIS
24  
25 use Poker::Game::OmahaHiLo;
26  
27 my $game = Poker::Game::OmahaHiLo->new;
28 my $hero = $game->deal_hole(['As', '2d', '3c', 'Kd']);
29 $game->runout(['4h', '5c', '9s', 'Jh', 'Kc']);
30 $game->evaluate($hero);
31  
32 say $hero->name; # high hand name
33 say $hero->low_name; # low hand name (if qualifies), or undef
34  
35 =head1 DESCRIPTION
36  
37 Omaha Hi-Lo: four hole cards, five community cards. Exactly two hole
38 and three community cards for each direction. High uses standard
39 highball; low uses 8-or-better. A hand that does not qualify for low
40 leaves C<low_score> / C<low_name> undefined.
41  
42 =cut
43  
44 2 extends 'Poker::Game';
45  
46 2 ▶has '+hole_count' => ( default => sub { 4 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
47 3 ▶has '+board_size' => ( default => sub { 5 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
48  
49 has 'low_scorer' => (
50 is => 'ro',
51 lazy => 1,
52 3 ▶ builder => sub { Poker::Score::Low8->new },
Subroutine _build_low_scorer: called CC=1 SCAR=0.0
53 2 );
54  
55 has 'low_eval' => (
56 is => 'ro',
57 lazy => 1,
58 2 ▶ builder => sub {
Subroutine _build_low_eval: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
59 2 my $self = shift;
60 2 Poker::Eval::Omaha->new( scorer => $self->low_scorer );
61 },
62 2 );
63  
64 3 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=4 SCAR=15.5
65 3 my ( $orig, $class, @args ) = @_;
66 3 my $args = $class->$orig(@args);
67 3 ▶ $args = {} unless ref $args eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 3 3
68  
69 3 ▶ $args->{scorer} //= Poker::Score::High->new;
Condition33%1/3
$args->{"scorer"} //= "Poker::Score::High"->new
l!l&&r!l&&!r
030
MC/DC0%0/2
$args->{"scorer"} //= "Poker::Score::High"->new
$args->{"scorer"} "Poker::Score::High"->new
Truth table33%1/3
A //= B
A= $args->{"scorer"}B= "Poker::Score::High"->new
ABresult
1X1
011
000
70 $args->{eval_engine} //= Poker::Eval::Omaha->new(
71 scorer => $args->{scorer},
72 3 ▶ );
Condition33%1/3
$args->{"eval_engine"} //= "Poker::Eval::Omaha"->new("scorer", $args->{"scorer"})
l!l&&r!l&&!r
030
MC/DC0%0/2
$args->{"eval_engine"} //= "Poker::Eval::Omaha"->new("scorer", $args->{"scorer"})
$args->{"eval_engine"} "Poker::Eval::Omaha"->new("scorer", $args->{"scorer"})
Truth table33%1/3
A //= B
A= $args->{"eval_engine"}B= "Poker::Eval::Omaha"->new("scorer", $args->{"scorer"})
ABresult
1X1
011
000
73  
74 3 return $args;
75 2 };
76  
77 =head2 evaluate
78  
79 Sets high result on C<score>/C<name>/C<best_combo>, and low result on
80 C<low_score>/C<low_name>/C<low_combo> when the hand qualifies for low.
81  
82 =cut
83  
84 3 ▶around evaluate => sub {
Subroutine __ANON__: called CC=8 SCAR=24.0
85 3 my ( $orig, $self, $arg ) = @_;
86 3 my $hand = $self->$orig($arg);
87  
88 3 ▶ my $hole =
Branch: 2 branches
BranchTrueFalseTotal
ref $arg eq 'ARRAY' ? : 0 3 3
$arg->isa('Poker::Hand') ? : 3 0 3
89 ref $arg eq 'ARRAY' ? $arg
90 : $arg->isa('Poker::Hand') ? $arg->cards
91 : $hand->cards;
92  
93 3 $self->low_eval->community_cards( $self->board );
94 3 my $low = $self->low_eval->best_hand($hole);
95  
96 # Low8 returns undef/0 score when no qualifying low
97 3 ▶ my $qualified = defined $low->score && $low->score > 0;
Condition66%2/3
defined $low->score && $low->score > 0
!ll&&!rl&&r
012
MC/DC50%1/2
defined $low->score && $low->score > 0
defined $low->score $low->score > 0
Truth table66%2/3
A && B
A= defined $low->scoreB= $low->score > 0
ABresult
0X0
100
111
98  
99 3 ▶ if ( ref $arg && $arg->isa('Poker::Hand') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $arg and $arg->isa("Poker::Hand")) 3 0 3
Condition33%1/3
ref $arg and $arg->isa("Poker::Hand")
!ll&&!rl&&r
003
MC/DC0%0/2
ref $arg and $arg->isa("Poker::Hand")
ref $arg $arg->isa("Poker::Hand")
Truth table33%1/3
A and B
A= ref $argB= $arg->isa("Poker::Hand")
ABresult
0X0
100
111
100 3 ▶ if ($qualified) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qualified) { } 2 1 3
101 2 $arg->low_score( $low->score );
102 2 $arg->low_name( $low->name );
103 2 $arg->low_combo( $low->best_combo );
104 }
105 else {
106 1 $arg->low_score(undef);
107 1 $arg->low_name(undef);
108 1 $arg->low_combo([]);
109 }
110 3 return $arg;
111 }
112  
113 0 ▶ if ($qualified) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qualified) 0 0 0
114 0 $hand->low_score( $low->score );
115 0 $hand->low_name( $low->name );
116 0 $hand->low_combo( $low->best_combo );
117 }
118 0 return $hand;
119 2 };
120  
121 =head1 AUTHOR
122  
123 Nathaniel Graham, C<< <ngraham at cpan.org> >>
124  
125 =head1 LICENSE AND COPYRIGHT
126  
127 Copyright 2016-2026 Nathaniel Graham.
128  
129 =cut
130  
131 2 1;
« Game.pm ↑ Summary Game/SevenCardStudHiLo.pm »