From 0ef5c12401d666027fcdb502a2611e43b9385389 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 4 Oct 2009 01:39:13 -0500 Subject: add a (currently inefficient) method for finding ways to create demons --- lib/Games/SMTNocturne/Fusion/Chart.pm | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/Games/SMTNocturne/Fusion/Chart.pm b/lib/Games/SMTNocturne/Fusion/Chart.pm index 69f2fd5..897f993 100644 --- a/lib/Games/SMTNocturne/Fusion/Chart.pm +++ b/lib/Games/SMTNocturne/Fusion/Chart.pm @@ -32,6 +32,42 @@ sub fuse { return $possible[0]; } +sub fusions_for { + my $self = shift; + my ($demon) = @_; + $demon = Games::SMTNocturne::Fusion::Demon->lookup($demon) + unless blessed($demon); + + my $type = $demon->type; + my @type_combos; + for my $type1 (keys %{ $self->_type_chart }) { + for my $type2 (grep { defined } keys %{ $self->_type_chart->{$type1} } ) { + my $fusion_type = $self->_type_chart->{$type1}{$type2}; + push @type_combos, [$type1, $type2] + if defined $fusion_type && $type eq $fusion_type; + } + } + + my @found; + for my $combo (@type_combos) { + my @type1_demons = Games::SMTNocturne::Fusion::Demon->lookup( + type => $combo->[0], + ); + my @type2_demons = Games::SMTNocturne::Fusion::Demon->lookup( + type => $combo->[1], + ); + for my $demon1 (@type1_demons) { + for my $demon2 (@type2_demons) { + my $fusion = $self->fuse($demon1, $demon2); + push @found, [$demon1, $demon2] + if defined $fusion && $fusion->name eq $demon->name; + } + } + } + + return @found; +} + 1; __DATA__ -- cgit v1.2.3-54-g00ecf