BlackJack/Player/HumanPlayer.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 25 CC 2 SCAR 13.9
CC
2
Cov
0%
decide_simple
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 4.0
1 package Games::Tournament::BlackJack::Player::HumanPlayer;
2 # example interactive human player module for blackjack
3  
4 use Games::Tournament::BlackJack::Player;
5 use Games::Tournament::BlackJack::Utilities;
6 @ISA = qw(Games::Tournament::BlackJack::Player);
7  
8 # decide_simple returns true for hit, false for stand.
9 sub decide_simple {
10 my $self = shift;
11 my @hand = @{$self->{'hand'}};
12 my $hval = handValue(\@hand);
13 my $hand_str = handStr(\@hand);
14 $output = "dealer shows $self->{'dealerUpcard'}, you have [ $hand_str ] for a total of $hval.\n";
15  
16 print $output;
17 print "[h]it or stay>";
18  
19 my $input = <>;
20 if ($input =~ m/h/i)
21 { return 1; } # hit if the user says to.
22 else
23 { return 0; }
24 }
25  
26  
27 1;
28