| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
455
|
use 5.20.0; |
|
|
1
|
|
|
|
|
27
|
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
65
|
|
|
3
|
|
|
|
|
|
|
package Games::Nintendo::Mario::SMB2 0.209; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: a class for vegetable-throwing Italian plumbers (and friends) |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
444
|
use parent qw(Games::Nintendo::Mario::Hearts); |
|
|
1
|
|
|
|
|
347
|
|
|
|
1
|
|
|
|
|
6
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
9
|
|
|
|
|
|
|
#pod |
|
10
|
|
|
|
|
|
|
#pod use Games::Nintendo::Mario::SMB2; |
|
11
|
|
|
|
|
|
|
#pod |
|
12
|
|
|
|
|
|
|
#pod my $liege = Games::Nintendo::Mario::SMB2->new(name => 'Peach'); |
|
13
|
|
|
|
|
|
|
#pod |
|
14
|
|
|
|
|
|
|
#pod # below outputs "Peach: 1/3" |
|
15
|
|
|
|
|
|
|
#pod say $liege->name . ": " . $liege->hearts . "/" . $liege->max_hearts; |
|
16
|
|
|
|
|
|
|
#pod |
|
17
|
|
|
|
|
|
|
#pod $liege->powerup('heart'); # 2/3 |
|
18
|
|
|
|
|
|
|
#pod $liege->damage; # 1/3 |
|
19
|
|
|
|
|
|
|
#pod $liege->powerup('mushroom'); # 1/4 |
|
20
|
|
|
|
|
|
|
#pod $liege->powerup('heart'); # 2/4 |
|
21
|
|
|
|
|
|
|
#pod $liege->powerup('mushroom'); # 2/5 |
|
22
|
|
|
|
|
|
|
#pod $liege->powerup('heart'); # 3/5 |
|
23
|
|
|
|
|
|
|
#pod |
|
24
|
|
|
|
|
|
|
#pod say "I'm feeling ", $liege->state, "!"; # She's feeling super. |
|
25
|
|
|
|
|
|
|
#pod |
|
26
|
|
|
|
|
|
|
#pod $liege->powerup('mushroom'); # Nothing happens. |
|
27
|
|
|
|
|
|
|
#pod |
|
28
|
|
|
|
|
|
|
#pod $liege->damage for (1 .. 3); # cue the Mario Death Music |
|
29
|
|
|
|
|
|
|
#pod |
|
30
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
31
|
|
|
|
|
|
|
#pod |
|
32
|
|
|
|
|
|
|
#pod This class subclasses Games::Nintendo::Mario (and G::N::M::Hearts), providing a |
|
33
|
|
|
|
|
|
|
#pod model of the behavior of the Mario Brothers in Super Mario Brothers 2. All of |
|
34
|
|
|
|
|
|
|
#pod the methods described in the Mario interface exist as documented. |
|
35
|
|
|
|
|
|
|
#pod |
|
36
|
|
|
|
|
|
|
#pod =head2 NAMES |
|
37
|
|
|
|
|
|
|
#pod |
|
38
|
|
|
|
|
|
|
#pod The plumber may be named Mario or Luigi, or a non-plumbing character named |
|
39
|
|
|
|
|
|
|
#pod Peach or Toad may be created. |
|
40
|
|
|
|
|
|
|
#pod |
|
41
|
|
|
|
|
|
|
#pod =head2 STATES |
|
42
|
|
|
|
|
|
|
#pod |
|
43
|
|
|
|
|
|
|
#pod C<< $hero->state >> will return 'dead' if he has no hearts, 'normal' if he has |
|
44
|
|
|
|
|
|
|
#pod one heart, and 'super' if he has more than one heart. State may not be set |
|
45
|
|
|
|
|
|
|
#pod during construction; set hearts instead. |
|
46
|
|
|
|
|
|
|
#pod |
|
47
|
|
|
|
|
|
|
#pod =head2 POWERUPS |
|
48
|
|
|
|
|
|
|
#pod |
|
49
|
|
|
|
|
|
|
#pod Valid powerups are: C or C |
|
50
|
|
|
|
|
|
|
#pod |
|
51
|
|
|
|
|
|
|
#pod =method state |
|
52
|
|
|
|
|
|
|
#pod |
|
53
|
|
|
|
|
|
|
#pod =method name |
|
54
|
|
|
|
|
|
|
#pod |
|
55
|
|
|
|
|
|
|
#pod =method powerup |
|
56
|
|
|
|
|
|
|
#pod |
|
57
|
|
|
|
|
|
|
#pod These methods are implemented as per Games::Nintendo::Mario |
|
58
|
|
|
|
|
|
|
#pod |
|
59
|
|
|
|
|
|
|
#pod =method power |
|
60
|
|
|
|
|
|
|
#pod |
|
61
|
|
|
|
|
|
|
#pod =method speed |
|
62
|
|
|
|
|
|
|
#pod |
|
63
|
|
|
|
|
|
|
#pod =method jump |
|
64
|
|
|
|
|
|
|
#pod |
|
65
|
|
|
|
|
|
|
#pod These methods return the requested attribute for the current character. |
|
66
|
|
|
|
|
|
|
#pod |
|
67
|
|
|
|
|
|
|
#pod =method games |
|
68
|
|
|
|
|
|
|
#pod |
|
69
|
|
|
|
|
|
|
#pod The rules reflected in this module were only present in Super Mario Bros. 2 |
|
70
|
|
|
|
|
|
|
#pod (and its re-releases). |
|
71
|
|
|
|
|
|
|
#pod |
|
72
|
|
|
|
|
|
|
#pod =cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
2
|
|
|
2
|
|
20
|
sub _names { qw[Mario Luigi Peach Toad] } |
|
75
|
2
|
|
|
2
|
|
6
|
sub _states { qw[normal] } # super isn't listed to prevent creation-as-super |
|
76
|
4
|
|
|
4
|
|
10
|
sub _items { qw[mushroom heart] } |
|
77
|
|
|
|
|
|
|
|
|
78
|
6
|
|
|
6
|
|
13
|
sub _goto_hash { {} } |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _char_attr { |
|
81
|
|
|
|
|
|
|
{ |
|
82
|
0
|
|
|
0
|
|
0
|
Mario => { |
|
83
|
|
|
|
|
|
|
power => 4, |
|
84
|
|
|
|
|
|
|
speed => 4, |
|
85
|
|
|
|
|
|
|
jump => 4 |
|
86
|
|
|
|
|
|
|
}, |
|
87
|
|
|
|
|
|
|
Luigi => { |
|
88
|
|
|
|
|
|
|
power => 3, |
|
89
|
|
|
|
|
|
|
speed => 3, |
|
90
|
|
|
|
|
|
|
jump => 5 |
|
91
|
|
|
|
|
|
|
}, |
|
92
|
|
|
|
|
|
|
Peach => { |
|
93
|
|
|
|
|
|
|
power => 2, |
|
94
|
|
|
|
|
|
|
speed => 2, |
|
95
|
|
|
|
|
|
|
jump => 3 |
|
96
|
|
|
|
|
|
|
}, |
|
97
|
|
|
|
|
|
|
Toad => { |
|
98
|
|
|
|
|
|
|
power => 5, |
|
99
|
|
|
|
|
|
|
speed => 5, |
|
100
|
|
|
|
|
|
|
jump => 2 |
|
101
|
|
|
|
|
|
|
} } |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub state { ## no critic Homonym |
|
105
|
13
|
|
|
13
|
1
|
25
|
my $hero = shift; |
|
106
|
13
|
100
|
|
|
|
32
|
if ($hero->hearts < 1) { return "dead" } |
|
|
2
|
|
|
|
|
12
|
|
|
107
|
11
|
100
|
|
|
|
26
|
if ($hero->hearts > 1) { return "super" } |
|
|
3
|
|
|
|
|
19
|
|
|
108
|
8
|
|
|
|
|
25
|
else { return "normal" } |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
1
|
|
|
1
|
1
|
573
|
sub name { $_[0]->{name} } |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub powerup { |
|
114
|
4
|
|
|
4
|
1
|
18
|
my $hero = shift; |
|
115
|
4
|
|
|
|
|
8
|
my $item = shift; |
|
116
|
|
|
|
|
|
|
|
|
117
|
4
|
100
|
100
|
|
|
17
|
if (($item eq 'mushroom') and ($hero->max_hearts < 5)) { |
|
118
|
2
|
|
|
|
|
4
|
$hero->{max_hearts}++; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
4
|
|
|
|
|
15
|
$hero->SUPER::powerup($item); |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
0
|
|
|
0
|
1
|
|
sub power { $_[0]->_char_attr->{$_[0]->name}->{power} } |
|
124
|
0
|
|
|
0
|
1
|
|
sub speed { $_[0]->_char_attr->{$_[0]->name}->{speed} } |
|
125
|
0
|
|
|
0
|
1
|
|
sub jump { $_[0]->_char_attr->{$_[0]->name}->{jump} } |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub games { |
|
128
|
0
|
|
|
0
|
1
|
|
return ('Super Mario Bros. 2'); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
"It's-a me! Mario!"; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |