line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Pokemon::Go::Relation::Dual; |
2
|
7
|
|
|
7
|
|
3866
|
use 5.008001; |
|
7
|
|
|
|
|
23
|
|
3
|
|
|
|
|
|
|
|
4
|
7
|
|
|
7
|
|
35
|
use Moose; |
|
7
|
|
|
|
|
22
|
|
|
7
|
|
|
|
|
38
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'Data::Pokemon::Go::Relation::Single'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# subroutine ============================================================== |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
override 'effective' => sub { |
11
|
|
|
|
|
|
|
my $self = shift; |
12
|
|
|
|
|
|
|
return super() if @{ $self->types() } == 1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my @types = map{ Data::Pokemon::Go::Relation::Single->new( types => $_ ) } @{ $self->types() }; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %hash; |
17
|
|
|
|
|
|
|
foreach my $type ( $types[0]->effective(), $types[1]->effective() ) { |
18
|
|
|
|
|
|
|
$hash{$type} = $hash{$type}? 1.96: 1.4; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
foreach my $type ( $types[0]->invalid(), $types[1]->invalid() ) { |
22
|
|
|
|
|
|
|
delete $hash{$type} if $hash{$type}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my @list = (); |
26
|
|
|
|
|
|
|
while( my ( $type, $damage ) = each %hash ) { |
27
|
|
|
|
|
|
|
push @list, { type => $type, damage => $damage }; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
my @order = sort{ $b->{damage} <=> $a->{damage} } @list; |
30
|
|
|
|
|
|
|
return map{ $_->{type} } @order if wantarray; |
31
|
|
|
|
|
|
|
return $order[0]{type} if @order == 1; |
32
|
|
|
|
|
|
|
return $order[0]{type} if $order[0]{damage} > 1.4; |
33
|
|
|
|
|
|
|
return; |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
override 'invalid' => sub { |
37
|
|
|
|
|
|
|
my $self = shift; |
38
|
|
|
|
|
|
|
return super() if @{ $self->types() } == 1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my @types = map{ Data::Pokemon::Go::Relation::Single->new( types => $_ ) } @{ $self->types() }; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my %hash; |
43
|
|
|
|
|
|
|
foreach my $type ( $types[0]->invalid(), $types[1]->invalid() ) { |
44
|
|
|
|
|
|
|
$hash{$type} = $hash{$type}? 0.51: 0.714; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
foreach my $type ( $types[0]->effective(), $types[1]->effective() ) { |
48
|
|
|
|
|
|
|
delete $hash{$type}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my @list = (); |
52
|
|
|
|
|
|
|
while( my ( $type, $damage ) = each %hash ) { |
53
|
|
|
|
|
|
|
push @list, { type => $type, damage => $damage }; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
my @order = sort{ $a->{damage} <=> $b->{damage} } @list; |
56
|
|
|
|
|
|
|
return map{ $_->{type} } @order if wantarray; |
57
|
|
|
|
|
|
|
return $order[0]{type} if @order == 1; |
58
|
|
|
|
|
|
|
return $order[0]{type} if $order[0]{damage} < 0.714; |
59
|
|
|
|
|
|
|
return; |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
override 'advantage' => sub { |
63
|
|
|
|
|
|
|
my $self = shift; |
64
|
|
|
|
|
|
|
return super() if @{ $self->types() } == 1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my @types = map{ Data::Pokemon::Go::Relation::Single->new( types => $_ ) } @{ $self->types() }; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my %hash; |
69
|
|
|
|
|
|
|
foreach my $type ( $types[0]->advantage(), $types[1]->advantage() ) { |
70
|
|
|
|
|
|
|
$hash{$type} = $hash{$type}? 0.51: 0.714; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my %average; |
74
|
|
|
|
|
|
|
foreach my $type0 ( $types[0]->advantage() ){ |
75
|
|
|
|
|
|
|
foreach my $type1 ( $types[1]->disadvantage() ){ |
76
|
|
|
|
|
|
|
$average{$type0} ||= 1 if $type0 eq $type1; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
foreach my $type0 ( $types[0]->disadvantage() ){ |
80
|
|
|
|
|
|
|
foreach my $type1 ( $types[1]->advantage() ){ |
81
|
|
|
|
|
|
|
$average{$type0} ||= 1 if $type0 eq $type1; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
foreach my $type ( $self->invalid(), keys %average ) { |
86
|
|
|
|
|
|
|
delete $hash{$type}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my @list = (); |
90
|
|
|
|
|
|
|
while( my ( $type, $damage ) = each %hash ) { |
91
|
|
|
|
|
|
|
push @list, { type => $type, damage => $damage }; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
my @order = sort{ $a->{damage} <=> $b->{damage} } @list; |
94
|
|
|
|
|
|
|
return map{ $_->{type} } @order if wantarray; |
95
|
|
|
|
|
|
|
return $order[0]{type} if @order == 1; |
96
|
|
|
|
|
|
|
return $order[0]{type} if $order[0]{damage} < 0.714; |
97
|
|
|
|
|
|
|
return; |
98
|
|
|
|
|
|
|
}; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
override 'disadvantage' => sub { |
101
|
|
|
|
|
|
|
my $self = shift; |
102
|
|
|
|
|
|
|
return super() if @{ $self->types() } == 1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my @types = map{ Data::Pokemon::Go::Relation::Single->new( types => $_ ) } @{ $self->types() }; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my %hash; |
107
|
|
|
|
|
|
|
foreach my $type ( $types[0]->disadvantage(), $types[1]->disadvantage() ) { |
108
|
|
|
|
|
|
|
$hash{$type} = $hash{$type}? 1.96: 1.4; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my %average; |
112
|
|
|
|
|
|
|
foreach my $type0 ( $types[0]->advantage() ){ |
113
|
|
|
|
|
|
|
foreach my $type1 ( $types[1]->disadvantage() ){ |
114
|
|
|
|
|
|
|
$average{$type0} ||= 1 if $type0 eq $type1; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
foreach my $type0 ( $types[0]->disadvantage() ){ |
118
|
|
|
|
|
|
|
foreach my $type1 ( $types[1]->advantage() ){ |
119
|
|
|
|
|
|
|
$average{$type0} ||= 1 if $type0 eq $type1; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
foreach my $type ( keys %average ) { |
124
|
|
|
|
|
|
|
delete $hash{$type}; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
foreach my $type ( $self->effective() ) { |
128
|
|
|
|
|
|
|
my $attacker = Data::Pokemon::Go::Relation::Single->new( types => $type ); |
129
|
|
|
|
|
|
|
foreach my $effective ( $attacker->effective() ) { |
130
|
|
|
|
|
|
|
$hash{$type} ||= 1 if grep{ $_ eq $effective } @{ $self->types() }; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my @list = (); |
135
|
|
|
|
|
|
|
while( my ( $type, $damage ) = each %hash ) { |
136
|
|
|
|
|
|
|
push @list, { type => $type, damage => $damage }; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
my @order = sort{ $b->{damage} <=> $a->{damage} } @list; |
139
|
|
|
|
|
|
|
return map{ $_->{type} } @order if wantarray; |
140
|
|
|
|
|
|
|
return $order[0]{type} if @order == 1; |
141
|
|
|
|
|
|
|
return $order[0]{type} if $order[0]{damage} > 1.4; |
142
|
|
|
|
|
|
|
return; |
143
|
|
|
|
|
|
|
}; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
override 'recommended' => sub { |
146
|
|
|
|
|
|
|
my $self = shift; |
147
|
|
|
|
|
|
|
return super() if @{ $self->types() } == 1; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
my @recommended = (); |
150
|
|
|
|
|
|
|
foreach my $type1 ( $self->effective() ){ |
151
|
|
|
|
|
|
|
foreach my $type2 ( $self->advantage() ){ |
152
|
|
|
|
|
|
|
push @recommended, $type1 if $type1 && $type2 and $type1 eq $type2; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
@recommended = ( $self->effective(), $self->advantage() ) unless @recommended; |
156
|
|
|
|
|
|
|
my $effective = $self->effective(); |
157
|
|
|
|
|
|
|
if ( |
158
|
|
|
|
|
|
|
$effective |
159
|
|
|
|
|
|
|
and not grep{ /^$effective$/ } $self->disadvantage() |
160
|
|
|
|
|
|
|
and not grep{ /^$effective$/ } @recommended |
161
|
|
|
|
|
|
|
) { |
162
|
|
|
|
|
|
|
unshift @recommended, $effective; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
for( my $i = 0; $i <= @recommended; $i++ ) { |
166
|
|
|
|
|
|
|
next unless $recommended[$i]; |
167
|
|
|
|
|
|
|
foreach my $type ( $self->disadvantage() ) { |
168
|
|
|
|
|
|
|
splice @recommended, $i, 1 if $type eq $recommended[$i]; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
return @recommended; |
172
|
|
|
|
|
|
|
}; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
175
|
7
|
|
|
7
|
|
55287
|
no Moose; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
36
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |
178
|
|
|
|
|
|
|
__END__ |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=encoding utf-8 |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 NAME |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Data::Pokemon::Go::Relation::Dual - It's new $module |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 SYNOPSIS |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
use Data::Pokemon::Go::Relation::Dual; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 DESCRIPTION |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Data::Pokemon::Go::Relation::Dual is ... |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 LICENSE |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Copyright (C) Yuki Yoshida. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
199
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 AUTHOR |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Yuki Yoshida E<lt>worthmine@gmail.comE<gt> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=cut |
206
|
|
|
|
|
|
|
|