line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
867
|
use 5.20.0; |
|
2
|
|
|
|
|
13
|
|
2
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
103
|
|
3
|
|
|
|
|
|
|
package Games::Nintendo::Mario::Hearts 0.208; |
4
|
|
|
|
|
|
|
# ABSTRACT: a superclass for Italian plubmers who can take a beating |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
446
|
use parent qw(Games::Nintendo::Mario); |
|
2
|
|
|
|
|
347
|
|
|
2
|
|
|
|
|
13
|
|
7
|
2
|
|
|
2
|
|
1211
|
use Hash::Util::FieldHash qw(fieldhash); |
|
2
|
|
|
|
|
1955
|
|
|
2
|
|
|
|
|
676
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
10
|
|
|
|
|
|
|
#pod |
11
|
|
|
|
|
|
|
#pod use Games::Nintendo::Mario::Hearts; |
12
|
|
|
|
|
|
|
#pod |
13
|
|
|
|
|
|
|
#pod my $noone = Games::Nintendo::Mario::Hearts->new; |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod print $hero->hearts . '/' . $hero->max_hearts; # at 1/3 health |
16
|
|
|
|
|
|
|
#pod $hero->powerup('heart'); # up to 2/3! |
17
|
|
|
|
|
|
|
#pod $hero->powerup('heart'); # full health! |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod print "It's-a me! ", $hero->name, "!\n"; # 'Mario' |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod $hero->powerup('heart'); # Nothing happens. |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod $hero->damage for (1 .. 3); # cue the Mario Death Music |
24
|
|
|
|
|
|
|
#pod |
25
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
26
|
|
|
|
|
|
|
#pod |
27
|
|
|
|
|
|
|
#pod This class subclasses Games::Nintendo::Mario, providing a class for further |
28
|
|
|
|
|
|
|
#pod subclassing. It adds the C and C methods, described below, |
29
|
|
|
|
|
|
|
#pod and it causes Mario to die when his hearts count reaches zero. This behavior |
30
|
|
|
|
|
|
|
#pod is found in SMB2 and the Wario games. |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod All of the methods described in the Mario interface exist as documented, but |
33
|
|
|
|
|
|
|
#pod the only powerup in this class is 'heart' and the only state is 'normal' |
34
|
|
|
|
|
|
|
#pod |
35
|
|
|
|
|
|
|
#pod =method hearts |
36
|
|
|
|
|
|
|
#pod |
37
|
|
|
|
|
|
|
#pod This method returns the number of hearts the plumber currently has. It |
38
|
|
|
|
|
|
|
#pod defaults to 1 at creation. |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod =method max_hearts |
41
|
|
|
|
|
|
|
#pod |
42
|
|
|
|
|
|
|
#pod This method returns the number of heart containers currently in the plumber's |
43
|
|
|
|
|
|
|
#pod heart meter. It defaults to 3 at creation. |
44
|
|
|
|
|
|
|
#pod |
45
|
|
|
|
|
|
|
#pod =method damage |
46
|
|
|
|
|
|
|
#pod |
47
|
|
|
|
|
|
|
#pod =method powerup |
48
|
|
|
|
|
|
|
#pod |
49
|
|
|
|
|
|
|
#pod These methods are defined in Games::Nintendo::Mario. |
50
|
|
|
|
|
|
|
#pod |
51
|
|
|
|
|
|
|
#pod =method games |
52
|
|
|
|
|
|
|
#pod |
53
|
|
|
|
|
|
|
#pod This is an abstract subclass for Mario classes, and does not represent any one |
54
|
|
|
|
|
|
|
#pod game. |
55
|
|
|
|
|
|
|
#pod |
56
|
|
|
|
|
|
|
#pod =cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
1
|
|
3
|
sub _states { qw[normal] } |
60
|
1
|
|
|
1
|
|
4
|
sub _items { qw[heart] } |
61
|
3
|
|
|
3
|
|
14
|
sub _other_defaults { ( max_hearts => 3 ) } |
62
|
3
|
|
|
3
|
|
12
|
sub __default_hearts { 1 }; |
63
|
|
|
|
|
|
|
|
64
|
3
|
|
|
3
|
|
7
|
sub _goto_hash { {} } # not used by base Hearts class |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub max_hearts { |
67
|
|
|
|
|
|
|
return $_[0]->{max_hearts} |
68
|
10
|
|
|
10
|
1
|
46
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
fieldhash my %hearts; |
71
|
|
|
|
|
|
|
sub hearts { |
72
|
41
|
|
|
41
|
1
|
71
|
my ($self) = @_; |
73
|
41
|
|
66
|
|
|
155
|
$hearts{ $self } //= $self->__default_hearts; |
74
|
41
|
|
|
|
|
153
|
return $hearts{ $self }; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub powerup { |
78
|
5
|
|
|
5
|
1
|
11
|
my $plumber = shift; |
79
|
5
|
|
|
|
|
10
|
my $item = shift; |
80
|
|
|
|
|
|
|
|
81
|
5
|
50
|
66
|
|
|
20
|
if (($item eq 'heart') and ($plumber->hearts) and ($plumber->hearts < $plumber->max_hearts)) { |
|
|
|
66
|
|
|
|
|
82
|
2
|
|
|
|
|
6
|
$hearts{ $plumber }++; |
83
|
|
|
|
|
|
|
} |
84
|
5
|
|
|
|
|
24
|
$plumber->SUPER::powerup($item); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub damage { |
88
|
4
|
|
|
4
|
1
|
9
|
my $self = shift; |
89
|
4
|
|
|
|
|
9
|
my $item = shift; |
90
|
|
|
|
|
|
|
|
91
|
4
|
50
|
|
|
|
11
|
if ($self->hearts) { |
92
|
4
|
100
|
|
|
|
15
|
$self->{state} = 'dead' unless --$hearts{ $self }; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
4
|
|
|
|
|
19
|
$self->SUPER::damage; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub games { |
99
|
0
|
|
|
0
|
1
|
|
return (); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
"It's-a me! Mario!"; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |