line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Pokemon::Go::Pokemon; |
2
|
6
|
|
|
6
|
|
394523
|
use 5.008001; |
|
6
|
|
|
|
|
69
|
|
3
|
6
|
|
|
6
|
|
32
|
use utf8; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
29
|
|
4
|
6
|
|
|
6
|
|
125
|
use Carp; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
317
|
|
5
|
6
|
|
|
6
|
|
33
|
use Exporter 'import'; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
384
|
|
6
|
|
|
|
|
|
|
our @EXPORT_OK = qw( $All @List @Types ); |
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
2657
|
use Moose; |
|
6
|
|
|
|
|
2274892
|
|
|
6
|
|
|
|
|
37
|
|
9
|
6
|
|
|
6
|
|
42179
|
use Moose::Util::TypeConstraints; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
53
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
enum 'Countries' => [qw( en ja ca fr )]; |
12
|
|
|
|
|
|
|
has lang => ( is => 'ro', isa => 'Countries', required => 1, default => 'ja' ); |
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
|
16197
|
use YAML::XS; |
|
6
|
|
|
|
|
14205
|
|
|
6
|
|
|
|
|
344
|
|
15
|
6
|
|
|
6
|
|
2189
|
use File::Share 'dist_dir'; |
|
6
|
|
|
|
|
108746
|
|
|
6
|
|
|
|
|
496
|
|
16
|
|
|
|
|
|
|
my $dir = $ENV{'USER'} eq 'yuki.yoshida'? 'share': dist_dir('Data-Pokemon-Go'); |
17
|
|
|
|
|
|
|
|
18
|
6
|
|
|
6
|
|
2509
|
use Data::Pokemon::Go::Relation; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
397
|
|
19
|
|
|
|
|
|
|
our @Types = @Data::Pokemon::Go::Role::Types::All; |
20
|
6
|
|
|
6
|
|
2983
|
use Data::Pokemon::Go::Skill; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
2223
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $skill = Data::Pokemon::Go::Skill->new(); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $All = {}; |
25
|
|
|
|
|
|
|
our @List = (); |
26
|
|
|
|
|
|
|
foreach my $region (qw|Kanto Johto Hoenn Sinnoh Unova Alola Galar|){ |
27
|
|
|
|
|
|
|
my $data = YAML::XS::LoadFile("$dir/$region.yaml"); |
28
|
|
|
|
|
|
|
map{ |
29
|
|
|
|
|
|
|
my $fullname = get_fullname( bless( { lang => 'ja' }, __PACKAGE__ ), $_ ); |
30
|
|
|
|
|
|
|
push @List, $fullname; |
31
|
|
|
|
|
|
|
$All->{ $fullname } = $_; |
32
|
|
|
|
|
|
|
} @$data; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
enum 'PokemonName' => \@List; |
36
|
|
|
|
|
|
|
has name => ( is => 'rw', isa => 'PokemonName' ); |
37
|
|
|
|
|
|
|
before 'name' => sub { |
38
|
|
|
|
|
|
|
my $self = shift; |
39
|
|
|
|
|
|
|
my $name = shift; |
40
|
|
|
|
|
|
|
my $form = shift || ''; |
41
|
|
|
|
|
|
|
if ( defined $name and $name =~ /^(\w+)\((\w+)\)$/ ){ |
42
|
|
|
|
|
|
|
$name = $1; |
43
|
|
|
|
|
|
|
$form = $2; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# croak "unvalid name: $name($form)" |
47
|
|
|
|
|
|
|
# if defined $name and defined $form and not $self->exists($name) and not $self->exists( $name, $form ); |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
51
|
6
|
|
|
6
|
|
55
|
no Moose; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
42
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub exists { |
54
|
2136
|
|
|
2136
|
0
|
1241451
|
my $self = shift; |
55
|
2136
|
|
|
|
|
3719
|
my $name = shift; |
56
|
2136
|
|
100
|
|
|
7477
|
my $form = shift || undef; |
57
|
|
|
|
|
|
|
|
58
|
2136
|
100
|
66
|
|
|
13620
|
if ( not defined $form and defined $name and $name =~ /^(\w+)\((\w+)\)$/ ){ |
|
|
|
100
|
|
|
|
|
59
|
193
|
|
|
|
|
1694
|
return CORE::exists $All->{"$1($2)"}; |
60
|
|
|
|
|
|
|
} |
61
|
1943
|
|
|
|
|
58939
|
my $fullname = $All->{$name}{'Name'}{$self->lang()}; |
62
|
1943
|
50
|
|
|
|
4080
|
return 0 unless defined $fullname; |
63
|
1943
|
100
|
|
|
|
6485
|
return 1 unless $form; |
64
|
2
|
|
|
|
|
5
|
$fullname .= "($form)"; |
65
|
2
|
|
|
|
|
13
|
return CORE::exists $All->{$fullname}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub id { |
69
|
2131
|
|
|
2131
|
0
|
8110
|
my $self = shift; |
70
|
2131
|
|
|
|
|
4074
|
my $name = $self->name(); |
71
|
2131
|
|
|
|
|
5863
|
my $id = $All->{$name}{ID}; |
72
|
2131
|
50
|
|
|
|
6515
|
carp "'ID' may be invalid: $id" unless $id =~ /^\d{3}$/; |
73
|
2131
|
|
|
|
|
8125
|
return $id; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub types { |
77
|
6259
|
|
|
6259
|
0
|
13136
|
my $self = shift; |
78
|
6259
|
|
|
|
|
16307
|
my $name = $self->name(); |
79
|
6259
|
|
|
|
|
14515
|
my $typesref = $All->{$name}{Types}; |
80
|
6259
|
50
|
|
|
|
14922
|
carp "'Types' may be invalid: $typesref" unless ref $typesref eq 'ARRAY'; |
81
|
6259
|
|
|
|
|
100430
|
return $typesref; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub skill { |
85
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
86
|
0
|
|
|
|
|
0
|
my $name = $self->name(); |
87
|
0
|
|
|
|
|
0
|
my $ref = $All->{$name}{Skill}; |
88
|
0
|
|
|
|
|
0
|
my @skill; |
89
|
0
|
|
|
|
|
0
|
foreach my $name (@$ref) { |
90
|
0
|
|
|
|
|
0
|
$skill->name($name); |
91
|
0
|
|
|
|
|
0
|
$skill->own_type( $self->types() ); |
92
|
0
|
|
|
|
|
0
|
push @skill, $skill->as_string(); |
93
|
|
|
|
|
|
|
} |
94
|
0
|
|
|
|
|
0
|
return @skill; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub special { |
98
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
99
|
0
|
|
|
|
|
0
|
my $name = $self->name(); |
100
|
0
|
|
|
|
|
0
|
my $ref = $All->{$name}{Special}; |
101
|
0
|
|
|
|
|
0
|
my @skill; |
102
|
0
|
|
|
|
|
0
|
foreach my $name (@$ref) { |
103
|
0
|
|
|
|
|
0
|
$skill->name($name); |
104
|
0
|
|
|
|
|
0
|
$skill->own_type( $self->types() ); |
105
|
0
|
|
|
|
|
0
|
push @skill, $skill->as_string(); |
106
|
|
|
|
|
|
|
} |
107
|
0
|
|
|
|
|
0
|
return @skill; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub effective { |
111
|
688
|
|
|
688
|
0
|
1244
|
my $self = shift; |
112
|
688
|
|
|
|
|
1659
|
return Data::Pokemon::Go::Relation->new( types => $self->types() )->effective(); |
113
|
|
|
|
|
|
|
}; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub invalid { |
116
|
688
|
|
|
688
|
0
|
1115
|
my $self = shift; |
117
|
688
|
|
|
|
|
1598
|
return Data::Pokemon::Go::Relation->new( types => $self->types() )->invalid(); |
118
|
|
|
|
|
|
|
}; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub advantage { |
121
|
688
|
|
|
688
|
0
|
1013
|
my $self = shift; |
122
|
688
|
|
|
|
|
1627
|
return Data::Pokemon::Go::Relation->new( types => $self->types() )->advantage(); |
123
|
|
|
|
|
|
|
}; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub disadvantage { |
126
|
688
|
|
|
688
|
0
|
1080
|
my $self = shift; |
127
|
688
|
|
|
|
|
1458
|
return Data::Pokemon::Go::Relation->new( types => $self->types() )->disadvantage(); |
128
|
|
|
|
|
|
|
}; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub recommended { |
131
|
1376
|
|
|
1376
|
0
|
4018
|
my $self = shift; |
132
|
1376
|
|
|
|
|
2854
|
return Data::Pokemon::Go::Relation->new( types => $self->types() )->recommended(); |
133
|
|
|
|
|
|
|
}; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub stamina { |
136
|
1930
|
|
|
1930
|
0
|
2855
|
my $self = shift; |
137
|
1930
|
|
|
|
|
5108
|
my $name = $self->name(); |
138
|
1930
|
50
|
|
|
|
5728
|
croak "'Stamina' is undefined for $name" unless exists $All->{$name}{'Stamina'}; |
139
|
1930
|
|
|
|
|
6617
|
return $All->{$name}{Stamina}; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub attack { |
143
|
1930
|
|
|
1930
|
0
|
2805
|
my $self = shift; |
144
|
1930
|
|
|
|
|
4494
|
my $name = $self->name(); |
145
|
1930
|
50
|
|
|
|
5051
|
croak "'Attack' is undefined for $name" unless exists $All->{$name}{'Attack'}; |
146
|
1930
|
|
|
|
|
6068
|
return $All->{$name}{Attack}; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub defense { |
150
|
1930
|
|
|
1930
|
0
|
2810
|
my $self = shift; |
151
|
1930
|
|
|
|
|
3910
|
my $name = $self->name(); |
152
|
1930
|
50
|
|
|
|
4949
|
croak "'Defense' is undefined for $name" unless exists $All->{$name}{'Defense'}; |
153
|
1930
|
|
|
|
|
6329
|
return $All->{$name}{Defense}; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub max { |
157
|
1242
|
|
|
1242
|
0
|
443144
|
my $self = shift; |
158
|
1242
|
|
|
|
|
1955
|
my $when = shift; |
159
|
1242
|
50
|
|
|
|
6870
|
croak "Unvalid param $when into sub max()" |
160
|
|
|
|
|
|
|
unless $when =~ /(:?Boosted|Hatched|Grown)/; |
161
|
|
|
|
|
|
|
|
162
|
1242
|
|
|
|
|
3522
|
my $name = $self->name(); |
163
|
1242
|
50
|
|
|
|
4161
|
croak "'$when' is undefined for $name" unless exists $All->{$name}{'MAXCP'}{$when}; |
164
|
1242
|
|
|
|
|
6777
|
return $All->{$name}{'MAXCP'}{$when}; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub isNotWild { |
168
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
169
|
0
|
|
|
|
|
0
|
my $name = $self->name(); |
170
|
0
|
|
|
|
|
0
|
return $All->{$name}{'isNotWild'}; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub isNotAvailable { |
174
|
688
|
|
|
688
|
0
|
958
|
my $self = shift; |
175
|
688
|
|
|
|
|
1822
|
my $name = $self->name(); |
176
|
688
|
|
|
|
|
2058
|
return $All->{$name}{'isNotAvailable'}; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub hasOtherForm { |
180
|
640
|
|
|
640
|
0
|
1467
|
my $self = shift; |
181
|
640
|
|
|
|
|
1210
|
my $name = $self->name(); |
182
|
640
|
|
|
|
|
1550
|
return $All->{$name}{'hasOtherForm'}; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub hasForms { |
186
|
755
|
|
|
755
|
0
|
2216
|
my $self = shift; |
187
|
755
|
|
|
|
|
1467
|
my $name = $self->name(); |
188
|
755
|
100
|
|
|
|
2570
|
return exists $All->{$name}{'Form'}? $All->{$name}{'Form'} : 0; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub get_fullname { |
192
|
4816
|
|
|
4816
|
0
|
63650
|
my $self = shift; |
193
|
4816
|
|
|
|
|
5157
|
my $ref = shift; |
194
|
4816
|
|
|
|
|
9818
|
my $fullname = $self->get_Pokemon_name($ref); |
195
|
4816
|
100
|
|
|
|
8383
|
$fullname .= '(' . $ref->{'Form'} . ')' if exists $ref->{'Form'}; |
196
|
4816
|
|
|
|
|
6790
|
return $fullname; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub get_Pokemon_name { |
200
|
4883
|
|
|
4883
|
0
|
6995
|
my $self = shift; |
201
|
4883
|
|
|
|
|
6262
|
my $ref = shift; |
202
|
4883
|
|
|
|
|
100867
|
my $lang = $self->lang(); |
203
|
4883
|
50
|
|
|
|
10203
|
croak "No name for $lang" unless exists $ref->{'Name'}{$lang}; |
204
|
4883
|
|
|
|
|
8024
|
return $ref->{'Name'}{$lang}; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
1; |
208
|
|
|
|
|
|
|
__END__ |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=encoding utf-8 |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 NAME |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Data::Pokemon::Go::Pokemon - It's new $module |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 SYNOPSIS |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
use Data::Pokemon::Go::Pokemon; |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 DESCRIPTION |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Data::Pokemon::Go::Pokemon is ... |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 LICENSE |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Copyright (C) Yuki Yoshida. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
229
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 AUTHOR |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Yuki Yoshida E<lt>worthmine@gmail.comE<gt> |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=cut |