line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::SMTNocturne::Demons::Fusion; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
3
|
|
|
3
|
|
101
|
$Games::SMTNocturne::Demons::Fusion::AUTHORITY = 'cpan:DOY'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
$Games::SMTNocturne::Demons::Fusion::VERSION = '0.02'; |
6
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
208
|
|
7
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
139
|
|
8
|
3
|
|
|
3
|
|
14
|
use overload '""' => 'to_string'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
26
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: represents the results of a fusion |
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
321
|
use Games::SMTNocturne::Demons::Demon; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
2124
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
0
|
|
|
0
|
0
|
|
my ($class, $options, $demon1, $demon2, $sacrifice, $kagutsuchi) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $attrs = {}; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
$demon1 = Games::SMTNocturne::Demons::Demon->from_name($demon1) |
20
|
|
|
|
|
|
|
unless ref($demon1); |
21
|
0
|
0
|
|
|
|
|
$demon2 = Games::SMTNocturne::Demons::Demon->from_name($demon2) |
22
|
|
|
|
|
|
|
unless ref($demon2); |
23
|
0
|
|
|
|
|
|
$attrs->{demons} = [ sort { $a->name cmp $b->name } $demon1, $demon2 ]; |
|
0
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
if ($sacrifice) { |
26
|
0
|
0
|
|
|
|
|
if ($sacrifice eq '') { |
27
|
0
|
|
|
|
|
|
$attrs->{deathstone} = 1; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
0
|
0
|
|
|
|
|
$sacrifice = Games::SMTNocturne::Demons::Demon->from_name($sacrifice) |
31
|
|
|
|
|
|
|
unless ref($sacrifice); |
32
|
0
|
|
|
|
|
|
$attrs->{sacrifice} = $sacrifice; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$attrs->{kagutsuchi} = $kagutsuchi; |
37
|
0
|
|
0
|
|
|
|
$attrs->{options} = $options || {}; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
return bless $attrs, $class; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
0
|
|
sub options { $_[0]->{options} } |
44
|
0
|
|
|
0
|
1
|
|
sub demons { $_[0]->{demons} } |
45
|
0
|
|
|
0
|
1
|
|
sub sacrifice { $_[0]->{sacrifice} } |
46
|
0
|
|
|
0
|
1
|
|
sub deathstone { $_[0]->{deathstone} } |
47
|
0
|
|
|
0
|
1
|
|
sub kagutsuchi { $_[0]->{kagutsuchi} } |
48
|
|
|
|
|
|
|
sub result { |
49
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
require Games::SMTNocturne::Demons; |
51
|
0
|
|
|
|
|
|
$self->{result} ||= Games::SMTNocturne::Demons::fuse( |
52
|
0
|
|
|
|
|
|
@{ $self->demons }, |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
0
|
|
|
|
|
%{ $self->options }, |
55
|
|
|
|
|
|
|
sacrifice => $self->sacrifice, |
56
|
|
|
|
|
|
|
deathstone => $self->deathstone, |
57
|
0
|
|
0
|
|
|
|
kagutsuchi => @{ $self->kagutsuchi || [] }[0], |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub all_demons { |
63
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return ( |
66
|
0
|
0
|
|
|
|
|
@{ $self->demons }, |
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
($self->sacrifice ? ($self->sacrifice) : ()), |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub raw { |
72
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
my $array = [ $self->options, @{ $self->demons } ]; |
|
0
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
push @$array, $self->sacrifice |
75
|
|
|
|
|
|
|
if $self->sacrifice; |
76
|
0
|
0
|
|
|
|
|
push @$array, "" |
77
|
|
|
|
|
|
|
if $self->deathstone; |
78
|
0
|
0
|
|
|
|
|
push @$array, $self->kagutsuchi |
79
|
|
|
|
|
|
|
if defined $self->kagutsuchi; |
80
|
0
|
|
|
|
|
|
return $array; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub to_string { |
84
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $str = "Fuse " . $self->demons->[0] |
87
|
|
|
|
|
|
|
. " with " . $self->demons->[1]; |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
$str .= " while sacrificing " . $self->sacrifice |
90
|
|
|
|
|
|
|
if $self->sacrifice; |
91
|
0
|
0
|
|
|
|
|
$str .= " while sacrificing a deathstone" |
92
|
|
|
|
|
|
|
if $self->deathstone; |
93
|
0
|
|
|
|
|
|
$str .= " when Kagutsuchi is at phase " |
94
|
0
|
0
|
|
|
|
|
. join(", ", map { "$_/8" } @{ $self->kagutsuchi }) |
|
0
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
if defined $self->kagutsuchi; |
96
|
0
|
|
|
|
|
|
$str .= " resulting in " . $self->result; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $str; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |