| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Game::Battleship::Craft; |
|
2
|
|
|
|
|
|
|
$Game::Battleship::Craft::VERSION = '0.0601'; |
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GENE'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
109
|
|
|
6
|
2
|
|
|
2
|
|
1676
|
use Moo; |
|
|
2
|
|
|
|
|
37699
|
|
|
|
2
|
|
|
|
|
12
|
|
|
7
|
2
|
|
|
2
|
|
5191
|
use Types::Standard qw( ArrayRef Int Num Str ); |
|
|
2
|
|
|
|
|
149136
|
|
|
|
2
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has id => ( |
|
10
|
|
|
|
|
|
|
is => 'ro', |
|
11
|
|
|
|
|
|
|
isa => Str, |
|
12
|
|
|
|
|
|
|
); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has name => ( |
|
15
|
|
|
|
|
|
|
is => 'ro', |
|
16
|
|
|
|
|
|
|
isa => Str, |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has position => ( |
|
20
|
|
|
|
|
|
|
is => 'ro', |
|
21
|
|
|
|
|
|
|
isa => ArrayRef[Num], |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has points => ( |
|
25
|
|
|
|
|
|
|
is => 'ro', |
|
26
|
|
|
|
|
|
|
isa => Int, |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has hits => ( |
|
30
|
|
|
|
|
|
|
is => 'ro', |
|
31
|
|
|
|
|
|
|
isa => Int, |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub BUILD { |
|
35
|
15
|
|
|
15
|
1
|
3992
|
my $self = shift; |
|
36
|
|
|
|
|
|
|
# Default the id to the upper-cased first char of name. |
|
37
|
15
|
50
|
|
|
|
46
|
unless ( $self->id ) { |
|
38
|
15
|
|
|
|
|
317
|
$self->{id} = ucfirst substr( $self->{name}, 0, 1 ); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub hit { |
|
43
|
14
|
|
|
14
|
1
|
24
|
my $self = shift; |
|
44
|
|
|
|
|
|
|
# Tally the hit. |
|
45
|
14
|
|
|
|
|
25
|
$self->{hits}++; |
|
46
|
|
|
|
|
|
|
# Hand back the remainder of the craft's value. |
|
47
|
14
|
|
|
|
|
60
|
return $self->points - $self->hits; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |