diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-10-04 01:39:13 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-10-04 01:39:13 -0500 |
commit | 0ef5c12401d666027fcdb502a2611e43b9385389 (patch) | |
tree | aa8089a9ce60a20aac37a3c81b7016f2ea31b463 /lib | |
parent | c7322b667b8e7b256101d7168e7cb6bc862e59bb (diff) | |
download | games-smtnocturne-fusion-0ef5c12401d666027fcdb502a2611e43b9385389.tar.gz games-smtnocturne-fusion-0ef5c12401d666027fcdb502a2611e43b9385389.zip |
add a (currently inefficient) method for finding ways to create demons
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Games/SMTNocturne/Fusion/Chart.pm | 36 |
1 files changed, 36 insertions, 0 deletions
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__ |