line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
812
|
use 5.20.0; |
|
2
|
|
|
|
|
13
|
|
2
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
100
|
|
3
|
|
|
|
|
|
|
package Games::Nintendo::Mario::NSMB 0.209; |
4
|
|
|
|
|
|
|
# ABSTRACT: a class for stylus-enabled Italian plumbers |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
454
|
use parent qw(Games::Nintendo::Mario); |
|
2
|
|
|
|
|
348
|
|
|
2
|
|
|
|
|
11
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
80
|
use Carp (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
857
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
11
|
|
|
|
|
|
|
#pod |
12
|
|
|
|
|
|
|
#pod use Games::Nintendo::Mario::NSMB; |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod my $hero = Games::Nintendo::Mario::SMB->new( |
15
|
|
|
|
|
|
|
#pod name => 'Luigi', |
16
|
|
|
|
|
|
|
#pod state => 'normal', |
17
|
|
|
|
|
|
|
#pod ); |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod $hero->powerup('mushroom'); # doop doop doop! |
20
|
|
|
|
|
|
|
#pod $hero->powerup('flower'); # change clothes |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod $hero->damage for (1 .. 2); # cue the Mario Death Music |
23
|
|
|
|
|
|
|
#pod |
24
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod This class subclasses Games::Nintendo::Mario, providing a model of the behavior |
27
|
|
|
|
|
|
|
#pod of the Mario Brothers in New Super Mario Brothers. All of the methods |
28
|
|
|
|
|
|
|
#pod described in the Mario interface exist as documented. |
29
|
|
|
|
|
|
|
#pod |
30
|
|
|
|
|
|
|
#pod =head2 NAMES |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod The plumber may be named Mario or Luigi. |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod =head2 STATES |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod The plumber's state may be any of: normal super fire shell mini mega |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod =head2 POWERUPS |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod Valid powerups are: mushroom flower shell mega_mushroom mini_mushroom |
41
|
|
|
|
|
|
|
#pod |
42
|
|
|
|
|
|
|
#pod =method games |
43
|
|
|
|
|
|
|
#pod |
44
|
|
|
|
|
|
|
#pod This ruleset reflects Mario in New Super Mario Bros., the first SMB game for |
45
|
|
|
|
|
|
|
#pod Nintendo DS. |
46
|
|
|
|
|
|
|
#pod |
47
|
|
|
|
|
|
|
#pod =cut |
48
|
|
|
|
|
|
|
|
49
|
10
|
|
|
10
|
|
30
|
sub _names { qw[Mario Luigi] } |
50
|
10
|
|
|
10
|
|
29
|
sub _states { qw[normal super fire shell mini mega] } |
51
|
0
|
|
|
0
|
|
0
|
sub _items { qw[mushroom flower shell mega_mushroom mini_mushroom] } |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my %__default_behavior = ( |
54
|
|
|
|
|
|
|
damage => 'dead', |
55
|
|
|
|
|
|
|
mushroom => 'super', |
56
|
|
|
|
|
|
|
flower => 'fire', |
57
|
|
|
|
|
|
|
shell => 'shell', |
58
|
|
|
|
|
|
|
mega_mushroom => 'mega', |
59
|
|
|
|
|
|
|
mini_mushroom => 'mini', |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my %state = ( |
63
|
|
|
|
|
|
|
normal => { %__default_behavior }, |
64
|
|
|
|
|
|
|
super => { |
65
|
|
|
|
|
|
|
%__default_behavior, |
66
|
|
|
|
|
|
|
damage => 'normal', |
67
|
|
|
|
|
|
|
mushroom => 'save', |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
fire => { |
70
|
|
|
|
|
|
|
%__default_behavior, |
71
|
|
|
|
|
|
|
damage => 'normal', |
72
|
|
|
|
|
|
|
flower => 'save', |
73
|
|
|
|
|
|
|
mushroom => 'save', |
74
|
|
|
|
|
|
|
}, |
75
|
|
|
|
|
|
|
shell => { |
76
|
|
|
|
|
|
|
%__default_behavior, |
77
|
|
|
|
|
|
|
damage => 'super', |
78
|
|
|
|
|
|
|
mushroom => 'save', |
79
|
|
|
|
|
|
|
flower => 'save', |
80
|
|
|
|
|
|
|
}, |
81
|
|
|
|
|
|
|
mega => { map { $_ => 'ignore' } keys %__default_behavior }, |
82
|
|
|
|
|
|
|
mini => { %__default_behavior, mini => 'save' }, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub games { |
86
|
0
|
|
|
0
|
1
|
0
|
return ('New Super Mario Bros.'); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _set_state { |
90
|
20
|
|
|
20
|
|
36
|
my ($self, $state, $item) = @_; |
91
|
|
|
|
|
|
|
|
92
|
20
|
100
|
|
|
|
50
|
if ($state eq 'save') { |
93
|
6
|
|
|
|
|
14
|
$self->{saved_item} = $item; |
94
|
|
|
|
|
|
|
} else { |
95
|
14
|
|
|
|
|
23
|
$self->{state} = $state; |
96
|
|
|
|
|
|
|
} |
97
|
20
|
|
|
|
|
77
|
return $self; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub powerup { |
101
|
20
|
|
|
20
|
1
|
43
|
my ($self, $item) = @_; |
102
|
|
|
|
|
|
|
|
103
|
20
|
|
|
|
|
48
|
my $state = $self->state; |
104
|
|
|
|
|
|
|
Carp::confess "current state unknown" |
105
|
20
|
50
|
|
|
|
59
|
unless my $state_info = $state{ $state }; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Carp::confess "behavior for $item in $state unknown" |
108
|
20
|
50
|
|
|
|
71
|
unless my $new_state = $state_info->{$item}; |
109
|
20
|
|
|
|
|
43
|
$self->_set_state($new_state, $item); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub damage { |
113
|
6
|
|
|
6
|
1
|
13
|
my ($self) = @_; |
114
|
6
|
|
|
|
|
14
|
$self->powerup('damage'); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
"Go Wigi!"; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |