File Coverage

blib/lib/Games/Tournament/BlackJack/Player/DealerPlayer.pm
Criterion Covered Total %
statement 9 15 60.0
branch 0 4 0.0
condition 0 3 0.0
subroutine 3 4 75.0
pod 0 1 0.0
total 12 27 44.4


line stmt bran cond sub pod time code
1             package Games::Tournament::BlackJack::Player::DealerPlayer;
2             # dealer player for blackjack
3             # -- follows standard vegas casino rules on dealer behavior:
4             # -- hit on soft 17 or less, stand on hard 17 or more
5              
6 1     1   6 use Games::Tournament::BlackJack::Player;
  1         2  
  1         26  
7 1     1   5 use Games::Tournament::BlackJack::Utilities;
  1         2  
  1         65  
8 1     1   5 use Exporter;
  1         2  
  1         5856  
9             @ISA = qw(Games::Tournament::BlackJack::Player);
10              
11              
12             # decide_simple returns true for hit, false for stand.
13            
14             sub decide_simple {
15 0     0 0   my $self = shift;
16 0           my $hit_threshold = 16; # hit on hard 16 or less
17 0           my $handValue = $self->myHandValue();
18            
19 0 0 0       if ($handValue == 17 and $self->isHandSoft()) {
20 0           return 'hit'; # on a soft 17
21             }
22            
23             # otherwise, hit on hard 16 or less as usual.
24 0 0         return ($handValue <= $hit_threshold) ? 'hit' : 'stand';
25             }
26              
27             1;