Go/Skill.pm

filter: Statementstmt 90.5% 77 / 85 Branchbran 61.5% 16 / 26 Conditioncond 61.5% 8 / 13 MC/DCmcdc 28.5% 2 / 7 Subroutinesub 94.1% 16 / 17 Podpod 0.0% 0 / 9 totaltotal 75.8% 119 / 157 CC 20 SCAR 15.5
CC
20
Cov
81%
as_string
20.0
__ANON__
5.1
strength
4.4
CRAP 4.7
« Go/Relation/Single.pm ↑ Summary Go/Pokemon.pm »
1 package Data::Pokemon::Go::Skill;
2 7 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use YAML::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 ▶use File::Share 'dist_dir';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 my $dir = dist_dir('Data-Pokemon-Go');
10  
11 7 with 'Data::Pokemon::Go::Role::Types';
12  
13 7 my $data = YAML::XS::LoadFile("$dir/Skill.yaml");
14 7 map{ $data->{$_}{name} = $_ } keys %$data;
15 7 our @All = map{ $_->{name} } sort{ $a->{type} cmp $b->{type} } values %$data;
16  
17 7 enum 'SkillName' => \@All;
18 7 has name => ( is => 'rw', isa => 'SkillName' );
19  
20 7 has own_type => ( is => 'rw', isa => 'ArrayRef[Type]' );
21  
22 166 ▶around 'types' => sub {
Subroutine __ANON__: called CC=5 SCAR=16.3
23 166 my $orig = shift;
24 166 my $self = shift;
25 166 my $name = $self->name();
26 166 my $type = $data->{$name}{type};
27 166 ▶ die "Type may be invalid: $type" unless $type;
Branch: 1 branch
BranchTrueFalseTotal
unless $type 0 166 166
28 166 ▶ die "Type may be invalid: $type" unless $name eq 'めざめるパワー' or grep{ $type eq $_ } @Data::Pokemon::Go::Role::Types::All;
Branch: 1 branch
BranchTrueFalseTotal
unless $name eq "\x{3081}\x{3056}\x{3081}\x{308b}\x{30d1}\x{30ef}\x{30fc}" or grep {$type eq $_;} @Data::Pokemon::Go::Role::Types::All 0 166 166
Condition66%2/3
$name eq "\x{3081}\x{3056}\x{3081}\x{308b}\x{30d1}\x{30ef}\x{30fc}" or grep {$type eq $_;} @Data::Pokemon::Go::Role::Types::All
l!l&&r!l&&!r
11650
MC/DC0%0/2
$name eq "\x{3081}\x{3056}\x{3081}\x{308b}\x{30d1}\x{30ef}\x{30fc}" or grep {$type eq $_;} @Data::Pokemon::Go::Role::Types::All
$name eq "\x{3081}\x{3056}\x{3081}\x{308b}\x{30d1}\x{30ef}\x{30fc}" grep {$type eq $_;} @Data::Pokemon::Go::Role::Types::All
Truth table66%2/3
A or B
A= $name eq "\x{3081}\x{3056}\x{3081}\x{308b}\x{30d1}\x{30ef}\x{30fc}"B= grep {$type eq $_;} @Data::Pokemon::Go::Role::Types::All
ABresult
1X1
011
000
29 166 ▶ return $self->$orig($type) unless $name eq 'めざめるパワー';
Branch: 1 branch
BranchTrueFalseTotal
unless $name eq "\x{3081}\x{3056}\x{3081}\x{308b}\x{30d1}\x{30ef}\x{30fc}" 165 1 166
30 1 return 'ランダム';
31 7 };
32  
33 7 __PACKAGE__->meta->make_immutable;
34 7 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 166 ▶sub exists {
Subroutine exists: called CC=1 SCAR=0.0
Pod undocumented
37 166 my $self = shift;
38 166 my $name = shift;
39 166 return CORE::exists $data->{$name};
40 }
41  
42 830 ▶sub strength {
Subroutine strength: called CC=4 SCAR=14.8
Pod undocumented
43 830 my $self = shift;
44 830 my $name = $self->name();
45 830 my $num = $data->{$name}{power};
46 830 ▶ die "'power' may be invalid: $num" unless $num =~ /^\d{1,3}$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $num =~ /^\d{1,3}$/ 0 830 830
47 0 ▶ $num *= 1.2 if grep{ $_ eq $self->types() } @{ $self->own_type() || [] };
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq $self->types;} @{$self->own_type or [];} 0 830 830
Condition50%1/2
$self->own_type || []
l!l
0830
MC/DC0%0/1
$self->own_type || []
$self->own_type
Truth table50%1/2
A
A= $self->own_type
Aresult
11
00
48 830 return $num;
49 }
50  
51 1442 ▶sub motion {
Subroutine motion: called CC=3 SCAR=11.3
Pod undocumented
52 1442 my $self = shift;
53 1442 my $name = $self->name();
54 1442 my $num = $data->{$name}{motion};
55 1442 ▶ die "'motion' may be invalid: $num" unless $num =~ /^\d{3,4}$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $num =~ /^\d{3,4}$/ 0 1442 1442
56 1442 ▶ return $num || 0.00;
Condition50%1/2
$num || 0.0
l!l
14420
MC/DC0%0/1
$num || 0.0
$num
Truth table50%1/2
A
A= $num
Aresult
11
00
57 }
58  
59 1104 ▶sub gauges {
Subroutine gauges: called CC=3 SCAR=11.0
Pod undocumented
60 1104 my $self = shift;
61 1104 my $name = $self->name();
62 1104 ▶ my $num = $data->{$name}{gauges} || 0;
Condition100%2/2
$data->{$name}{'gauges'} || 0
l!l
756348
MC/DC100%1/1
$data->{$name}{'gauges'} || 0
$data->{$name}{'gauges'}
Truth table100%2/2
A
A= $data->{$name}{'gauges'}
Aresult
11
00
63 1104 ▶ die "'gauges' may be invalid: $num" unless $num =~ /^(:?0|1|2|3)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $num =~ /^(:?0|1|2|3)$/ 0 1104 1104
64 1104 return $num;
65 }
66  
67 569 ▶sub energy {
Subroutine energy: called CC=2 SCAR=6.9
Pod undocumented
68 569 my $self = shift;
69 569 my $name = $self->name();
70 569 ▶ return $data->{$name}{'energy'} || 0;
Condition100%2/2
$data->{$name}{'energy'} || 0
l!l
456113
MC/DC100%1/1
$data->{$name}{'energy'} || 0
$data->{$name}{'energy'}
Truth table100%2/2
A
A= $data->{$name}{'energy'}
Aresult
11
00
71 }
72  
73 223 ▶sub EPS {
Subroutine EPS: called CC=2 SCAR=6.9
Pod undocumented
74 223 my $self = shift;
75 223 ▶ return 0.00 unless $self->energy;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->energy 109 114 223
76 114 my $eps = int( $self->energy / $self->motion * 100000 + 0.5 ) / 100;
77 114 return sprintf('%2d.%02d', int $eps, $eps % 1 );
78 }
79  
80 166 ▶sub DPS {
Subroutine DPS: called CC=2 SCAR=6.9
Pod undocumented
81 166 my $self = shift;
82 166 ▶ my $dps = $self->gauges()?
Branch: 1 branch
BranchTrueFalseTotal
$self->gauges ? : 108 58 166
83 int( $self->strength() / ( $self->motion() / 1000 + 1 ) * 100 + 0.5 ):
84 int( $self->strength() / ( $self->motion() / 1000 ) * 100 + 0.5 );
85 166 return sprintf('%2d.%02d', int $dps / 100 , $dps % 100 );
86 }
87  
88 498 ▶sub point {
Subroutine point: called CC=3 SCAR=11.0
Pod undocumented
89 498 my $self = shift;
90 498 ▶ my $point = $self->gauges()?
Branch: 1 branch
BranchTrueFalseTotal
$self->gauges ? : 324 174 498
91 ( $self->strength * 1000 - $self->motion ) / ( $self->motion + 1000 ) * 100:
92 ( ( $self->strength + $self->energy ) / 2 * 1000 - $self->motion )/ $self->motion * 100;
93 498 ▶ return sprintf('%2d.%02d', int $point / 100, $point % 100 ) if $point > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $point > 0 495 3 498
94 3 return '0.00';
95 }
96  
97 0 ▶sub as_string {
Subroutine as_string: not called CC=4 SCAR=30.0
Pod undocumented
98 0 my $self = shift;
99 0 my $better = '';
100 0 ▶ $better = '(タイプ一致)' if grep{ $_ eq $self->type() } @{ $self->own_type() || [] };
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq $self->type;} @{$self->own_type or [];} 0 0 0
Condition0%0/2
$self->own_type || []
l!l
00
MC/DC0%0/1
$self->own_type || []
$self->own_type
Truth table0%0/2
A
A= $self->own_type
Aresult
11
00
101 0 ▶ my $str = $self->gauges()?
Branch: 1 branch
BranchTrueFalseTotal
$self->gauges ? : 0 0 0
102 sprintf("%s(%s) 攻撃力:%.2f DPS:%.2f ゲージ数:%d 評価:%.2f%s\n",
103 $self->name,
104 $self->types,
105 $self->strength,
106 $self->DPS(),
107 $self->gauges(),
108 $self->point(),
109 $better,
110 ):
111 sprintf("%s(%s) 攻撃力:%.2f DPS:%.2f EPS:%.2f 評価:%.2f%s\n",
112 $self->name,
113 $self->types,
114 $self->strength,
115 $self->DPS(),
116 $self->EPS(),
117 $self->point(),
118 $better,
119 );
120  
121 0 return $str;
122 }
123  
124  
125 7 1;
126 __END__
« Go/Relation/Single.pm ↑ Summary Go/Pokemon.pm »