Go/Relation/Dual.pm

filter: Statementstmt 93.4% 129 / 138 Branchbran 79.7% 59 / 74 Conditioncond 68.1% 15 / 22 MC/DCmcdc 45.4% 5 / 11 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 85.3% 216 / 253 CC 68 SCAR 28.1
CC
68
Cov
87%
__ANON__
23.3
__ANON__
19.6
__ANON__
15.1
CRAP 16.6
« Go/IV.pm ↑ Summary Go/Relation/Single.pm »
1 package Data::Pokemon::Go::Relation::Dual;
2 7 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 extends 'Data::Pokemon::Go::Relation::Single';
7  
8 # subroutine ==============================================================
9  
10 8735 ▶override 'effective' => sub {
Subroutine __ANON__: called CC=10 SCAR=23.0
11 8735 my $self = shift;
12 8735 ▶ return super() if @{ $self->types() } == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->types;} == 1 1246 7489 8735
13  
14 7489 my @types = map{ Data::Pokemon::Go::Relation::Single->new( types => $_ ) } @{ $self->types() };
15  
16 7489 my %hash;
17 7489 foreach my $type ( $types[0]->effective(), $types[1]->effective() ) {
18 44405 ▶ $hash{$type} = $hash{$type}? 1.96: 1.4;
Branch: 1 branch
BranchTrueFalseTotal
$hash{$type} ? : 3808 40597 44405
19 }
20  
21 7489 foreach my $type ( $types[0]->invalid(), $types[1]->invalid() ) {
22 57614 ▶ delete $hash{$type} if $hash{$type};
Branch: 1 branch
BranchTrueFalseTotal
if $hash{$type} 10344 47270 57614
23 }
24  
25 7489 my @list = ();
26 7489 ▶ while( my ( $type, $damage ) = each %hash ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %hash) 30253 7489 37742
27 30253 push @list, { type => $type, damage => $damage };
28 }
29 7489 my @order = sort{ $b->{damage} <=> $a->{damage} } @list;
30 7489 ▶ return map{ $_->{type} } @order if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 6217 1272 7489
31 1272 ▶ return $order[0]{type} if @order == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @order == 1 66 1206 1272
32 1206 ▶ return $order[0]{type} if $order[0]{damage} > 1.4;
Branch: 1 branch
BranchTrueFalseTotal
if $order[0]{"damage"} > "1.4" 436 770 1206
33 770 return;
34 7 };
35  
36 14679 ▶override 'invalid' => sub {
Subroutine __ANON__: called CC=9 SCAR=23.2
37 14679 my $self = shift;
38 14679 ▶ return super() if @{ $self->types() } == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->types;} == 1 8437 6242 14679
39  
40 6242 my @types = map{ Data::Pokemon::Go::Relation::Single->new( types => $_ ) } @{ $self->types() };
41  
42 6242 my %hash;
43 6242 foreach my $type ( $types[0]->invalid(), $types[1]->invalid() ) {
44 46966 ▶ $hash{$type} = $hash{$type}? 0.51: 0.714;
Branch: 1 branch
BranchTrueFalseTotal
$hash{$type} ? : 5080 41886 46966
45 }
46  
47 6242 foreach my $type ( $types[0]->effective(), $types[1]->effective() ) {
48 37384 delete $hash{$type};
49 }
50  
51 6242 my @list = ();
52 6242 ▶ while( my ( $type, $damage ) = each %hash ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %hash) 34044 6242 40286
53 34044 push @list, { type => $type, damage => $damage };
54 }
55 6242 my @order = sort{ $a->{damage} <=> $b->{damage} } @list;
56 6242 ▶ return map{ $_->{type} } @order if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 6242 0 6242
57 0 ▶ return $order[0]{type} if @order == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @order == 1 0 0 0
58 0 ▶ return $order[0]{type} if $order[0]{damage} < 0.714;
Branch: 1 branch
BranchTrueFalseTotal
if $order[0]{"damage"} < "0.714" 0 0 0
59 0 return;
60 7 };
61  
62 8022 ▶override 'advantage' => sub {
Subroutine __ANON__: called CC=17 SCAR=29.8
63 8022 my $self = shift;
64 8022 ▶ return super() if @{ $self->types() } == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->types;} == 1 2416 5606 8022
65  
66 5606 my @types = map{ Data::Pokemon::Go::Relation::Single->new( types => $_ ) } @{ $self->types() };
67  
68 5606 my %hash;
69 5606 foreach my $type ( $types[0]->advantage(), $types[1]->advantage() ) {
70 36202 ▶ $hash{$type} = $hash{$type}? 0.51: 0.714;
Branch: 1 branch
BranchTrueFalseTotal
$hash{$type} ? : 4129 32073 36202
71 }
72  
73 5606 my %average;
74 5606 foreach my $type0 ( $types[0]->advantage() ){
75 18562 foreach my $type1 ( $types[1]->disadvantage() ){
76 54196 ▶ $average{$type0} ||= 1 if $type0 eq $type1;
Branch: 1 branch
BranchTrueFalseTotal
if $type0 eq $type1 2928 51268 54196
Condition50%1/2
$average{$type0} ||= 1
l!l
02928
MC/DC0%0/1
$average{$type0} ||= 1
$average{$type0}
Truth table50%1/2
A
A= $average{$type0}
Aresult
11
00
77 }
78 }
79 5606 foreach my $type0 ( $types[0]->disadvantage() ){
80 16118 foreach my $type1 ( $types[1]->advantage() ){
81 50059 ▶ $average{$type0} ||= 1 if $type0 eq $type1;
Branch: 1 branch
BranchTrueFalseTotal
if $type0 eq $type1 2956 47103 50059
Condition50%1/2
$average{$type0} ||= 1
l!l
02956
MC/DC0%0/1
$average{$type0} ||= 1
$average{$type0}
Truth table50%1/2
A
A= $average{$type0}
Aresult
11
00
82 }
83 }
84  
85 5606 foreach my $type ( $self->invalid(), keys %average ) {
86 36451 delete $hash{$type};
87 }
88  
89 5606 my @list = ();
90 5606 ▶ while( my ( $type, $damage ) = each %hash ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %hash) 24518 5606 30124
91 24518 push @list, { type => $type, damage => $damage };
92 }
93 5606 my @order = sort{ $a->{damage} <=> $b->{damage} } @list;
94 5606 ▶ return map{ $_->{type} } @order if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 5606 0 5606
95 0 ▶ return $order[0]{type} if @order == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @order == 1 0 0 0
96 0 ▶ return $order[0]{type} if $order[0]{damage} < 0.714;
Branch: 1 branch
BranchTrueFalseTotal
if $order[0]{"damage"} < "0.714" 0 0 0
97 0 return;
98 7 };
99  
100 4757 ▶override 'disadvantage' => sub {
Subroutine __ANON__: called CC=21 SCAR=31.5
101 4757 my $self = shift;
102 4757 ▶ return super() if @{ $self->types() } == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->types;} == 1 494 4263 4757
103  
104 4263 my @types = map{ Data::Pokemon::Go::Relation::Single->new( types => $_ ) } @{ $self->types() };
105  
106 4263 my %hash;
107 4263 foreach my $type ( $types[0]->disadvantage(), $types[1]->disadvantage() ) {
108 25078 ▶ $hash{$type} = $hash{$type}? 1.96: 1.4;
Branch: 1 branch
BranchTrueFalseTotal
$hash{$type} ? : 1985 23093 25078
109 }
110  
111 4263 my %average;
112 4263 foreach my $type0 ( $types[0]->advantage() ){
113 14451 foreach my $type1 ( $types[1]->disadvantage() ){
114 42622 ▶ $average{$type0} ||= 1 if $type0 eq $type1;
Branch: 1 branch
BranchTrueFalseTotal
if $type0 eq $type1 2182 40440 42622
Condition50%1/2
$average{$type0} ||= 1
l!l
02182
MC/DC0%0/1
$average{$type0} ||= 1
$average{$type0}
Truth table50%1/2
A
A= $average{$type0}
Aresult
11
00
115 }
116 }
117 4263 foreach my $type0 ( $types[0]->disadvantage() ){
118 12315 foreach my $type1 ( $types[1]->advantage() ){
119 38894 ▶ $average{$type0} ||= 1 if $type0 eq $type1;
Branch: 1 branch
BranchTrueFalseTotal
if $type0 eq $type1 2168 36726 38894
Condition50%1/2
$average{$type0} ||= 1
l!l
02168
MC/DC0%0/1
$average{$type0} ||= 1
$average{$type0}
Truth table50%1/2
A
A= $average{$type0}
Aresult
11
00
120 }
121 }
122  
123 4263 foreach my $type ( keys %average ) {
124 4350 delete $hash{$type};
125 }
126  
127 4263 foreach my $type ( $self->effective() ) {
128 17805 my $attacker = Data::Pokemon::Go::Relation::Single->new( types => $type );
129 17805 foreach my $effective ( $attacker->effective() ) {
130 54529 ▶ $hash{$type} ||= 1 if grep{ $_ eq $effective } @{ $self->types() };
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq $effective;} @{$self->types;} 2326 52203 54529
Condition100%2/2
$hash{$type} ||= 1
l!l
12981028
MC/DC100%1/1
$hash{$type} ||= 1
$hash{$type}
Truth table100%2/2
A
A= $hash{$type}
Aresult
11
00
131 }
132 }
133  
134 4263 my @list = ();
135 4263 ▶ while( my ( $type, $damage ) = each %hash ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %hash) 19771 4263 24034
136 19771 push @list, { type => $type, damage => $damage };
137 }
138 4263 my @order = sort{ $b->{damage} <=> $a->{damage} } @list;
139 4263 ▶ return map{ $_->{type} } @order if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 4263 0 4263
140 0 ▶ return $order[0]{type} if @order == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @order == 1 0 0 0
141 0 ▶ return $order[0]{type} if $order[0]{damage} > 1.4;
Branch: 1 branch
BranchTrueFalseTotal
if $order[0]{"damage"} > "1.4" 0 0 0
142 0 return;
143 7 };
144  
145 2024 ▶override 'recommended' => sub {
Subroutine __ANON__: called CC=15 SCAR=27.1
146 2024 my $self = shift;
147 2024 ▶ return super() if @{ $self->types() } == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->types;} == 1 752 1272 2024
148  
149 1272 my @recommended = ();
150 1272 foreach my $type1 ( $self->effective() ){
151 4924 foreach my $type2 ( $self->advantage() ){
152 21768 ▶ push @recommended, $type1 if $type1 && $type2 and $type1 eq $type2;
Branch: 1 branch
BranchTrueFalseTotal
if $type1 and $type2 and $type1 eq $type2 2884 18884 21768
Condition50%3/6
$type1 and $type2 and $type1 eq $type2
!ll&&!rl&&r
0188842884
$type1 and $type2
!ll&&!rl&&r
0021768
MC/DC33%1/3
$type1 and $type2 and $type1 eq $type2
$type1 $type2 $type1 eq $type2
Truth table50%2/4
A and B and C
A= $type1B= $type2C= $type1 eq $type2
ABCresult
0XX0
10X0
1100
1111
153 }
154 }
155 1272 ▶ @recommended = ( $self->effective(), $self->advantage() ) unless @recommended;
Branch: 1 branch
BranchTrueFalseTotal
unless @recommended 46 1226 1272
156 1272 my $effective = $self->effective();
157 1272 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($effective and not grep({/^$effective$/;} $self->disadvantage) and not grep({/^$effective$/;} @recommended)) 83 1189 1272
Condition100%6/6
$effective and not grep({/^$effective$/;} $self->disadvantage) and not grep({/^$effective$/;} @recommended)
!ll&&!rl&&r
77141883
$effective and not grep({/^$effective$/;} $self->disadvantage)
!ll&&!rl&&r
7701501
MC/DC100%3/3
$effective and not grep({/^$effective$/;} $self->disadvantage) and not grep({/^$effective$/;} @recommended)
$effective not grep({/^$effective$/;} $self->disadvantage) not grep({/^$effective$/;} @recommended)
Truth table100%4/4
A and not(B) and not(C)
A= $effectiveB= not grep({/^$effective$/;} $self->disadvantage)C= not grep({/^$effective$/;} @recommended)
ABCresult
0XX0
10X0
1100
1111
158 $effective
159 2398 and not grep{ /^$effective$/ } $self->disadvantage()
160 1269 and not grep{ /^$effective$/ } @recommended
161 ) {
162 83 unshift @recommended, $effective;
163 }
164  
165 1272 ▶ for( my $i = 0; $i <= @recommended; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= @recommended) 4397 1272 5669
166 4397 ▶ next unless $recommended[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless $recommended[$i] 1272 3125 4397
167 3125 foreach my $type ( $self->disadvantage() ) {
168 14516 ▶ splice @recommended, $i, 1 if $type eq $recommended[$i];
Branch: 1 branch
BranchTrueFalseTotal
if $type eq $recommended[$i] 40 14476 14516
169 }
170 }
171 1272 return @recommended;
172 7 };
173  
174 7 __PACKAGE__->meta->make_immutable;
175 7 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
176  
177 7 1;
178 __END__
« Go/IV.pm ↑ Summary Go/Relation/Single.pm »