diff options
-rw-r--r-- | lib/Games/SMTNocturne/Fusion/Chart.pm | 11 | ||||
-rw-r--r-- | lib/Games/SMTNocturne/Fusion/Demon.pm | 18 |
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/Games/SMTNocturne/Fusion/Chart.pm b/lib/Games/SMTNocturne/Fusion/Chart.pm index 0284d3b..dd21ec5 100644 --- a/lib/Games/SMTNocturne/Fusion/Chart.pm +++ b/lib/Games/SMTNocturne/Fusion/Chart.pm @@ -33,8 +33,15 @@ multi method fuse (ClassName $self: SMTDemon $demon1 is coerce, multi method fuse (ClassName $self: Element $demon1 is coerce, SMTDemon $demon2 is coerce) { - # XXX: fix - return; + my $direction = $demon2->elemental_fusion_direction($demon1->name); + return unless defined $direction; + + if ($direction eq 'down') { + return $demon2->level_down; + } + else { + return $demon2->level_up; + } } multi method fuse (ClassName $self: Mitama $demon1 is coerce, diff --git a/lib/Games/SMTNocturne/Fusion/Demon.pm b/lib/Games/SMTNocturne/Fusion/Demon.pm index bc386d1..23df00c 100644 --- a/lib/Games/SMTNocturne/Fusion/Demon.pm +++ b/lib/Games/SMTNocturne/Fusion/Demon.pm @@ -99,6 +99,24 @@ sub lookup { return wantarray ? @possible : (@possible == 1 ? $possible[0] : undef); } +sub level_up { + my $self = shift; + my @possible = $self->lookup( + type => $self->type, + level => sub { $_ > $self->level }, + ); + return $possible[0]; +} + +sub level_down { + my $self = shift; + my @possible = $self->lookup( + type => $self->type, + level => sub { $_ < $self->level }, + ); + return $possible[$#possible]; +} + __PACKAGE__->meta->make_immutable; 1; |