Battleship/Craft.pm

filter: Statementstmt 100% 24 / 24 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 50.0% 1 / 2 totaltotal 93.9% 31 / 33 CC 2 SCAR 3.0
CC
2
Cov
96%
BUILD
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Battleship/Player.pm ↑ Summary
1 package Game::Battleship::Craft;
2 5 $Game::Battleship::Craft::VERSION = '0.0602';
3 5 our $AUTHORITY = 'cpan:GENE';
4  
5 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Types::Standard qw( ArrayRef Int Num Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 has id => (
10 is => 'ro',
11 isa => Str,
12 );
13  
14 5 has name => (
15 is => 'ro',
16 isa => Str,
17 );
18  
19 5 has position => (
20 is => 'ro',
21 isa => ArrayRef[Num],
22 );
23  
24 5 has orient => (
25 is => 'ro',
26 isa => Int,
27 );
28  
29 5 has points => (
30 is => 'ro',
31 isa => Int,
32 );
33  
34 5 has hits => (
35 is => 'ro',
36 isa => Int,
37 );
38  
39 15 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=7.1
Pod undocumented
40 15 my $self = shift;
41 # Default the id to the upper-cased first char of name.
42 # XXX This is brittle!
43 15 ▶ unless ( $self->id ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->id) 15 0 15
44 15 $self->{id} = ucfirst substr( $self->{name}, 0, 1 );
45 }
46 }
47  
48 19 ▶sub hit {
Subroutine hit: called CC=1 SCAR=0.0
Pod documented
49 19 my $self = shift;
50 # Tally the hit.
51 19 $self->{hits}++;
52 # Hand back the remainder of the craft's value.
53 19 return $self->points - $self->hits;
54 }
55  
56 5 1;
57  
58 __END__
« Battleship/Player.pm ↑ Summary