File Coverage

blib/lib/Poker/Score/Low27.pm
Criterion Covered Total %
statement 3 4 75.0
branch n/a
condition n/a
subroutine 1 2 50.0
pod n/a
total 4 6 66.6


line stmt bran cond sub pod time code
1             package Poker::Score::Low27;
2 1     1   623 use Moo;
  1         1  
  1         4  
3              
4             =head1 NAME
5              
6             Poker::Score::Low27 - Identify and score lowball 2-7 poker hand.
7              
8             =head1 VERSION
9              
10             Version 0.01
11              
12             =cut
13              
14             our $VERSION = '0.01';
15              
16             =head1 INTRODUCTION
17              
18             Straights and flushes count against your low hand and Aces always play high.
19              
20             =head1 SYNOPSIS
21              
22             See Poker::Score for code example.
23              
24             =cut
25              
26             extends 'Poker::Score::High';
27              
28             after _build_hands => sub {
29             my $self = shift;
30             my %map;
31             $self->hands( [ reverse @{ $self->hands } ] );
32              
33             my @names =
34             map { $self->_hand_map->{$_} }
35             sort { $a <=> $b } keys %{ $self->_hand_map };
36             my @keys = sort { $a <=> $b } keys %{ $self->_hand_map };
37             my $lowest = shift @keys;
38             for my $key (@keys) {
39             $map{ $#{ $self->hands } - $key } = shift @names;
40             }
41             $map{ $lowest } = pop @names;
42             $self->_hand_map( \%map );
43             #print Dumper(\%map);
44             };
45              
46             # straights
47             # Aces always play high in the 27 scoring system
48             # e.g., A2345 is NOT a straight
49             sub _build_straights {
50             return [
51 0     0     '0605040302', '0706050403', '0807060504', '0908070605', '1009080706',
52             '1110090807', '1211100908', '1312111009', '1413121110',
53             ];
54             }
55              
56             =head1 AUTHOR
57              
58             Nathaniel Graham, C<< >>
59              
60             =head1 LICENSE AND COPYRIGHT
61              
62             Copyright 2016 Nathaniel Graham.
63              
64             This program is free software; you can redistribute it and/or modify it
65             under the terms of the the Artistic License (2.0). You may obtain a
66             copy of the full license at:
67              
68             L
69              
70             =cut
71              
72             1;