Score/Low27.pm

filter: Statementstmt 100% 25 / 25 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 28 / 28 CC 2 SCAR 4.1
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
_build_straights
1.0
CRAP 1.5
« Game/Courcheval.pm ↑ Summary Hand.pm »
1 package Poker::Score::Low27;
2 3 our $VERSION = '0.12';
3  
4  
5 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 Poker::Score::Low27 - Identify and score lowball 2-7 poker hand.
10  
11 =head1 VERSION
12  
13 Version 0.12
14  
15 =cut
16  
17  
18 =head1 INTRODUCTION
19  
20 Straights and flushes count against your low hand and Aces always play high.
21  
22 =head1 SYNOPSIS
23  
24 See Poker::Score for code example.
25  
26 =cut
27  
28 3 extends 'Poker::Score::High';
29  
30 2 ▶after _build_hands => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
31 2 my $self = shift;
32 2 my %map;
33 2 $self->hands( [ reverse @{ $self->hands } ] );
34  
35 my @names =
36 20 map { $self->_hand_map->{$_} }
37 2 sort { $a <=> $b } keys %{ $self->_hand_map };
38 2 my @keys = sort { $a <=> $b } keys %{ $self->_hand_map };
39 2 my $lowest = shift @keys;
40 2 for my $key (@keys) {
41 18 $map{ $#{ $self->hands } - $key } = shift @names;
42 }
43 2 $map{ $lowest } = pop @names;
44 2 $self->_hand_map( \%map );
45 #print Dumper(\%map);
46 3 };
47  
48 # straights
49 # Aces always play high in the 27 scoring system
50 # e.g., A2345 is NOT a straight
51 2 ▶sub _build_straights {
Subroutine _build_straights: called CC=1 SCAR=0.0
52 return [
53 2 '0605040302', '0706050403', '0807060504', '0908070605', '1009080706',
54 '1110090807', '1211100908', '1312111009', '1413121110',
55 ];
56 }
57  
58 =head1 AUTHOR
59  
60 Nathaniel Graham, C<< <ngraham at cpan.org> >>
61  
62 =head1 LICENSE AND COPYRIGHT
63  
64 Copyright 2016 Nathaniel Graham.
65  
66 This program is free software; you can redistribute it and/or modify it
67 under the terms of the the Artistic License (2.0). You may obtain a
68 copy of the full license at:
69  
70 L<http://www.perlfoundation.org/artistic_license_2_0>
71  
72 =cut
73  
74 3 1;
« Game/Courcheval.pm ↑ Summary Hand.pm »