Mario/NSMB.pm

filter: Statementstmt 93.5% 29 / 31 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 81.8% 9 / 11 Podpod 100% 3 / 3 totaltotal 88.2% 45 / 51 SCAR 13.9
CC
4
Cov
89%
powerup
3.1
_items
2.0
games
2.0
CRAP 4.0
« Mario/SMB2.pm ↑ Summary Mario/NSMB/Wii.pm »
1 4 ▶use 5.16.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Games::Nintendo::Mario::NSMB 0.208;
4  
5 4 ▶use parent qw(Games::Nintendo::Mario);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 10 ▶sub _names { qw[Mario Luigi] }
Subroutine _names: called CC=1 SCAR=0.0
10 10 ▶sub _states { qw[normal super fire shell mini mega] }
Subroutine _states: called CC=1 SCAR=0.0
11 0 ▶sub _items { qw[mushroom flower shell mega_mushroom mini_mushroom] }
Subroutine _items: not called CC=1 SCAR=6.9
12  
13 4 my %__default_behavior = (
14 damage => 'dead',
15 mushroom => 'super',
16 flower => 'fire',
17 shell => 'shell',
18 mega_mushroom => 'mega',
19 mini_mushroom => 'mini',
20 );
21  
22 my %state = (
23 normal => { %__default_behavior },
24 super => {
25 %__default_behavior,
26 damage => 'normal',
27 mushroom => 'save',
28 },
29 fire => {
30 %__default_behavior,
31 damage => 'normal',
32 flower => 'save',
33 mushroom => 'save',
34 },
35 shell => {
36 %__default_behavior,
37 damage => 'super',
38 mushroom => 'save',
39 flower => 'save',
40 },
41 4 mega => { map { $_ => 'ignore' } keys %__default_behavior },
42 mini => { %__default_behavior, mini => 'save' },
43 );
44  
45 sub games {
46 0 ▶ return ('New Super Mario Bros.');
Subroutine games: not called CC=1 SCAR=6.9
Pod documented
47 }
48  
49 sub _set_state {
50 20 ▶ my ($self, $state, $item) = @_;
Subroutine _set_state: called CC=2 SCAR=6.9
51  
52 20 ▶ if ($state eq 'save') {
Branch: 1 branch
BranchTrueFalseTotal
if ($state eq 'save') { } 6 14 20
53 6 $self->{saved_item} = $item;
54 } else {
55 14 $self->{state} = $state;
56 }
57 20 return $self;
58 }
59  
60 sub powerup {
61 20 ▶ my ($self, $item) = @_;
Subroutine powerup: called CC=3 SCAR=11.3
Pod documented
62  
63 20 my $state = $self->state;
64 Carp::confess "current state unknown"
65 20 ▶ unless my $state_info = $state{ $state };
Branch: 1 branch
BranchTrueFalseTotal
unless my $state_info = $state{$state} 0 20 20
66  
67 Carp::confess "behavior for $item in $state unknown"
68 20 ▶ unless my $new_state = $state_info->{$item};
Branch: 1 branch
BranchTrueFalseTotal
unless my $new_state = $state_info->{$item} 0 20 20
69 20 $self->_set_state($new_state, $item);
70 }
71  
72 sub damage {
73 6 ▶ my ($self) = @_;
Subroutine damage: called CC=1 SCAR=0.0
Pod documented
74 6 $self->powerup('damage');
75 }
76  
77 4 "Go Wigi!";
78  
79 __END__
« Mario/SMB2.pm ↑ Summary Mario/NSMB/Wii.pm »