summaryrefslogtreecommitdiffstats
path: root/lib/Games/SMTNocturne/Demons.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-05-25 15:45:46 -0400
committerJesse Luehrs <doy@tozt.net>2014-05-25 15:45:46 -0400
commitdc31eaead0386016a265f7b2371cd2e166a395b0 (patch)
tree1eca7434bed843ee7be8a9f7f769e28fcd8012f7 /lib/Games/SMTNocturne/Demons.pm
parented332d993c9b5b3c8bec2eae957005e445d21376 (diff)
downloadgames-smtnocturne-demons-dc31eaead0386016a265f7b2371cd2e166a395b0.tar.gz
games-smtnocturne-demons-dc31eaead0386016a265f7b2371cd2e166a395b0.zip
expand fusions_for to include special fusions
Diffstat (limited to 'lib/Games/SMTNocturne/Demons.pm')
-rw-r--r--lib/Games/SMTNocturne/Demons.pm87
1 files changed, 86 insertions, 1 deletions
diff --git a/lib/Games/SMTNocturne/Demons.pm b/lib/Games/SMTNocturne/Demons.pm
index b54eda8..d7f4a58 100644
--- a/lib/Games/SMTNocturne/Demons.pm
+++ b/lib/Games/SMTNocturne/Demons.pm
@@ -75,7 +75,92 @@ sub fusions_for {
}
}
- return @fusions;
+ my $special = Games::SMTNocturne::Demons::FusionChart::special_fusion_for(
+ $demon->name
+ );
+ my @special_fusions;
+ if ($special) {
+ for my $key (qw(demon1 demon2 demon3 target sacrifice)) {
+ next unless $special->{$key};
+ if (my $name = $special->{$key}{name}) {
+ $special->{$key} = [
+ Games::SMTNocturne::Demons::Demon->from_name($name)
+ ];
+ }
+ elsif (my $type = $special->{$key}{type}) {
+ my @types = ref($type) ? (@$type) : ($type);
+ $special->{$key} = [
+ map {
+ Games::SMTNocturne::Demons::Demon->from_type($_)
+ } @types
+ ];
+ }
+ }
+
+ if ($special->{demon3}) {
+ for my $demon1 (@{ $special->{demon1} }) {
+ for my $demon2 (@{ $special->{demon2} }) {
+ for my $demon3 (@{ $special->{demon3} }) {
+ push @special_fusions, [ $demon1, $demon2, $demon3 ];
+ push @special_fusions, [ $demon1, $demon3, $demon2 ];
+ push @special_fusions, [ $demon2, $demon3, $demon1 ];
+ }
+ }
+ }
+ }
+ elsif ($special->{demon2}) {
+ for my $demon1 (@{ $special->{demon1} }) {
+ for my $demon2 (@{ $special->{demon2} }) {
+ push @special_fusions, [ $demon1, $demon2 ];
+ }
+ }
+ }
+ elsif ($special->{demon1}) {
+ if ($special->{target}) {
+ my @target_fusions = map {
+ fusions_for($_)
+ } @{ $special->{target} };
+ push @special_fusions, grep {
+ my $fusion = $_;
+ grep { $_ eq $fusion->[0] || $_ eq $fusion->[1] }
+ @{ $special->{demon1} }
+ } @target_fusions;
+ }
+ else {
+ die "???";
+ }
+ }
+ else {
+ if ($special->{target}) {
+ push @special_fusions, map {
+ fusions_for($_)
+ } @{ $special->{target} };
+ }
+ else {
+ die "???";
+ }
+ }
+
+ if ($special->{sacrifice}) {
+ @special_fusions = map {
+ my $sac = $_;
+ map { [ @$_, $sac ] } @special_fusions
+ } @{ $special->{sacrifice} };
+ }
+
+ if ($special->{deathstone}) {
+ push @$_, '<deathstone>' for @special_fusions;
+ }
+
+ if ($special->{kagatsuchi}) {
+ @special_fusions = map {
+ my $phase = $_;
+ map { [ @$_, "<kagatsuchi $phase>" ] } @special_fusions
+ } @{ $special->{kagatsuchi} };
+ }
+ }
+
+ return @fusions, @special_fusions;
}
sub _try_special_fusion {