| 1 | package Data::Pokemon::Go::Role::Types; | ||||||||||
| 2 | 8 | ▶ | use 5.008001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 8 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 8 | ▶ | use Encode; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 8 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 8 | ▶ | use Moose::Util::TypeConstraints; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 8 | our @All = qw( | |||||||||
| 10 | ノーマル かくとう どく じめん ひこう むし いわ | ||||||||||
| 11 | ゴースト はがね ほのお みず でんき くさ こおり | ||||||||||
| 12 | エスパー ドラゴン あく フェアリー | ||||||||||
| 13 | ); | ||||||||||
| 14 | |||||||||||
| 15 | 8 | enum 'Type' => \@All; | |||||||||
| 16 | 8 | has types => ( is => 'rw', default => 'ノーマル', isa => 'Type' ); | |||||||||
| 17 | |||||||||||
| 18 | 8 | ▶ | no Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | # initialize ============================================================== | ||||||||||
| 21 | 8 | ▶ | use YAML::XS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 8 | ▶ | use File::Share 'dist_dir'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 8 | my $dir = dist_dir('Data-Pokemon-Go'); | |||||||||
| 24 | |||||||||||
| 25 | 8 | our $Ref_Advantage = YAML::XS::LoadFile("$dir/Relations.yaml"); | |||||||||
| 26 | 8 | our $Relations = {}; | |||||||||
| 27 | |||||||||||
| 28 | 8 | ▶ | while( my( $type, $ref ) = each %$Ref_Advantage ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 144 | ▶ | while( my( $relation, $values ) = each %$ref ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 432 | ▶ | next unless ref $values; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 344 | foreach my $value (@$values){ | |||||||||
| 32 | 960 | ▶ | push @{$Relations->{$value}{invalid}}, $type if $relation eq 'invalid'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 960 | ▶ | unshift @{$Relations->{$value}{invalid}}, $type if $relation eq 'void'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 960 | ▶ | push @{$Relations->{$value}{effective}}, $type if $relation eq 'effective'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | } | ||||||||||
| 36 | } | ||||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 8 | 1; | |||||||||
| 40 | __END__ | ||||||||||