diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-05-25 02:45:51 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-05-25 02:45:51 -0400 |
commit | f38fc9b0f8c6b90b3d93518357d894be5864892e (patch) | |
tree | 9c68a62e44235cf3f769eec9f5fa93151ec33d75 /lib | |
parent | bfb381b794062830a33eab3739e23a7204fdeebf (diff) | |
download | games-smtnocturne-demons-f38fc9b0f8c6b90b3d93518357d894be5864892e.tar.gz games-smtnocturne-demons-f38fc9b0f8c6b90b3d93518357d894be5864892e.zip |
function to get possible demons that can be fused into a given demon
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Games/SMTNocturne/Demons.pm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Games/SMTNocturne/Demons.pm b/lib/Games/SMTNocturne/Demons.pm index b648bf6..336a12a 100644 --- a/lib/Games/SMTNocturne/Demons.pm +++ b/lib/Games/SMTNocturne/Demons.pm @@ -23,4 +23,25 @@ sub fuse { ); } +sub fusions_for { + my ($demon) = @_; + + $demon = Games::SMTNocturne::Demons::Demon->from_name($demon) + unless ref($demon); + + my @fusions; + my %seen; + for my $types (Games::SMTNocturne::Demons::FusionChart::unfuse($demon->type)) { + my ($type1, $type2) = @$types; + for my $demon1 (Games::SMTNocturne::Demons::Demon->from_type($type1)) { + for my $demon2 (Games::SMTNocturne::Demons::Demon->from_type($type2)) { + push @fusions, [ $demon1, $demon2 ] + if fuse($demon1, $demon2) eq $demon; + } + } + } + + return @fusions; +} + 1; |