line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Pokemon::Go::IV; |
2
|
1
|
|
|
1
|
|
579
|
use 5.008001; |
|
1
|
|
|
|
|
3
|
|
3
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
5
|
use YAML::XS; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
4
|
use List::Util qw(first); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
6
|
1
|
|
|
1
|
|
5
|
use File::Share 'dist_dir'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
56
|
|
7
|
|
|
|
|
|
|
my $dir = dist_dir('Data-Pokemon-Go'); |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
11
|
1
|
|
|
1
|
|
6565
|
no Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $data = YAML::XS::LoadFile("$dir/LV.yaml"); |
14
|
|
|
|
|
|
|
my %Dust = (); |
15
|
|
|
|
|
|
|
push @{ $Dust{ $_->{Dust} } }, { LV => $_->{LV}, Candy => $_->{Candy} } foreach @$data; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _calculate_CP { |
18
|
1242
|
|
|
1242
|
|
1817
|
my $self = shift; |
19
|
1242
|
|
|
|
|
4261
|
my %arg = @_; |
20
|
1242
|
50
|
|
|
|
2605
|
croak "argument 'name' is required" unless exists $arg{name}; |
21
|
1242
|
50
|
|
|
|
2167
|
croak "argument 'LV' is required" unless exists $arg{LV}; |
22
|
1242
|
50
|
|
|
|
2214
|
croak "argument 'ST' is required" unless exists $arg{ST}; |
23
|
1242
|
50
|
|
|
|
1903
|
croak "argument 'AT' is required" unless exists $arg{AT}; |
24
|
1242
|
50
|
|
|
|
2017
|
croak "argument 'DF' is required" unless exists $arg{DF}; |
25
|
|
|
|
|
|
|
|
26
|
1242
|
|
|
|
|
31815
|
my $pg = Data::Pokemon::Go::Pokemon->new( name => $arg{name} ); |
27
|
1242
|
|
|
|
|
3232
|
my $stamina = $pg->stamina() + $arg{ST}; |
28
|
1242
|
|
|
|
|
2998
|
my $attack = $pg->attack() + $arg{AT}; |
29
|
1242
|
|
|
|
|
3010
|
my $defense = $pg->defense() + $arg{DF}; |
30
|
1242
|
|
|
|
|
2826
|
my $CPM = $self->_calculate_CPM( from => $arg{LV} ); |
31
|
1242
|
|
|
|
|
5074
|
my $CP = int( sqrt($stamina) * $attack * sqrt($defense) * $CPM ** 2 / 10 ); |
32
|
1242
|
50
|
|
|
|
32363
|
return $CP if $CP > 10; |
33
|
0
|
|
|
|
|
0
|
return 10; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _calculate_CPM { |
37
|
1242
|
|
|
1242
|
|
1698
|
my $self = shift; |
38
|
1242
|
|
|
|
|
2818
|
my %arg = @_; |
39
|
1242
|
50
|
|
|
|
2396
|
croak "argument 'from' is required" unless exists $arg{from}; |
40
|
1242
|
|
|
54648
|
|
7401
|
my $ref = first{ $_->{LV} == $arg{from} } @$data; |
|
54648
|
|
|
|
|
59323
|
|
41
|
1242
|
|
|
|
|
5616
|
return $ref->{CPM}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _calculate_HP { |
45
|
0
|
|
|
0
|
|
|
my $self = shift; |
46
|
0
|
|
|
|
|
|
my %arg = @_; |
47
|
0
|
0
|
|
|
|
|
croak "argument 'name' is required" unless exists $arg{name}; |
48
|
0
|
0
|
|
|
|
|
croak "argument 'LV' is required" unless exists $arg{LV}; |
49
|
0
|
0
|
|
|
|
|
croak "argument 'ST' is required" unless exists $arg{ST}; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $CPM = $self->_calculate_CPM( from => $arg{LV} ); |
52
|
0
|
|
|
|
|
|
my $pg = Data::Pokemon::Go::Pokemon->new( name => $arg{name} ); |
53
|
0
|
|
|
|
|
|
return int ( ( $pg->stamina() + $arg{ST} ) * $CPM ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _guess_LV { |
57
|
0
|
|
|
0
|
|
|
my $self = shift; |
58
|
0
|
|
|
|
|
|
my %arg = @_; |
59
|
0
|
0
|
|
|
|
|
croak "argument 'name' is required" unless exists $arg{name}; |
60
|
0
|
0
|
|
|
|
|
croak "argument 'HP' is required" unless exists $arg{HP}; |
61
|
0
|
0
|
|
|
|
|
croak "argument 'ST' is required" unless exists $arg{ST}; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $pg = Data::Pokemon::Go::Pokemon->new( name => $arg{name} ); |
64
|
0
|
|
|
|
|
|
my @LV = (); |
65
|
0
|
|
|
|
|
|
for( my $i = 1.0; $i <= 40.5; $i += 0.5 ){ |
66
|
0
|
0
|
|
|
|
|
push @LV, $i if $self->_calculate_HP( @_, LV => $i ) == $arg{HP}; |
67
|
|
|
|
|
|
|
} |
68
|
0
|
|
|
|
|
|
return @LV; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _guess_ST { |
72
|
0
|
|
|
0
|
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
my %arg = @_; |
74
|
0
|
0
|
|
|
|
|
croak "argument 'name' is required" unless exists $arg{name}; |
75
|
0
|
0
|
|
|
|
|
croak "argument 'HP' is required" unless exists $arg{HP}; |
76
|
0
|
|
|
|
|
|
my $ST = 0; |
77
|
0
|
|
|
|
|
|
for( my $i = 0; $i <= 15; $i++ ){ |
78
|
0
|
0
|
|
|
|
|
return $i if $self->_guess_LV( @_, ST => $i ); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
__END__ |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=encoding utf-8 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Data::Pokemon::Go::IV - It's new $module |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 SYNOPSIS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
use Data::Pokemon::Go::IV; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 DESCRIPTION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Data::Pokemon::Go::IV is ... |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 LICENSE |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Copyright (C) Yuki Yoshida. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
104
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Yuki Yoshida E<lt>worthmine@gmail.comE<gt> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|