line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
837
|
use v5.24.0; |
|
4
|
|
|
|
|
16
|
|
2
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
187
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Games::Bowling::Scorecard::Frame::TenPinTenth 0.106; |
5
|
4
|
|
|
4
|
|
1799
|
use parent qw(Games::Bowling::Scorecard::Frame); |
|
4
|
|
|
|
|
1302
|
|
|
4
|
|
|
|
|
29
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: ten pin's weird 10th frame |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod The tenth frame of ten pin bowling is weird. If you bowl a strike or spare, |
11
|
|
|
|
|
|
|
#pod you're allowed to throw balls to complete the frame's scoring. The extra balls |
12
|
|
|
|
|
|
|
#pod are only counted for bonus points. In other words, if the first two balls in |
13
|
|
|
|
|
|
|
#pod the tenth frame are strikes, the second ball is not counted as a "pending" |
14
|
|
|
|
|
|
|
#pod strike. If this is confusing, don't worry! That's why you're using this |
15
|
|
|
|
|
|
|
#pod module. |
16
|
|
|
|
|
|
|
#pod |
17
|
|
|
|
|
|
|
#pod =method is_done |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod The tenth frame is done if: (a) three balls have been bowled or (b) two balls |
20
|
|
|
|
|
|
|
#pod have been bowled, totalling less than ten. |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod =cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub is_done { |
25
|
187
|
|
|
187
|
1
|
324
|
my ($self) = @_; |
26
|
|
|
|
|
|
|
|
27
|
187
|
|
|
|
|
392
|
my @balls = $self->balls; |
28
|
|
|
|
|
|
|
|
29
|
187
|
100
|
100
|
|
|
1200
|
return 1 if @balls == 3 or @balls == 2 and $balls[0] + $balls[1] < 10; |
|
|
|
100
|
|
|
|
|
30
|
158
|
|
|
|
|
529
|
return; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#pod =method is_pending |
34
|
|
|
|
|
|
|
#pod |
35
|
|
|
|
|
|
|
#pod The tenth frame is never pending. Once it's done, its score is final. |
36
|
|
|
|
|
|
|
#pod |
37
|
|
|
|
|
|
|
#pod =cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub is_pending { |
40
|
36
|
|
|
36
|
1
|
142
|
return 0; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#pod =method roll_ok |
44
|
|
|
|
|
|
|
#pod |
45
|
|
|
|
|
|
|
#pod The tenth frame's C is identical to the standard C, but |
46
|
|
|
|
|
|
|
#pod replaces the "can't total more than 10" rule with a more complex rule. |
47
|
|
|
|
|
|
|
#pod |
48
|
|
|
|
|
|
|
#pod =cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub roll_ok { |
51
|
37
|
|
|
37
|
1
|
605
|
my ($self, $ball) = @_; |
52
|
|
|
|
|
|
|
|
53
|
37
|
|
|
|
|
67
|
eval { $self->SUPER::roll_ok($ball) }; |
|
37
|
|
|
|
|
116
|
|
54
|
|
|
|
|
|
|
|
55
|
37
|
100
|
|
|
|
612
|
if (my $error = $@) { |
56
|
14
|
100
|
|
|
|
69
|
return if $error =~ /would bring the frame above 10/; |
57
|
1
|
|
|
|
|
4
|
die $error; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _assert_split_ok { |
62
|
0
|
|
|
0
|
|
|
my ($self, $ball) = @_; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ($self->{balls}->@* > 2) { |
65
|
0
|
|
|
|
|
|
Carp::croak "can't record a split on third ball in tenth frame"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
if ($ball >= 9) { |
69
|
0
|
|
|
|
|
|
Carp::croak "you can't split if you knocked down $ball pins!"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
300; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |