summaryrefslogtreecommitdiffstats
path: root/lib/Games/SMTNocturne/Demons.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-05-25 03:04:41 -0400
committerJesse Luehrs <doy@tozt.net>2014-05-25 03:04:41 -0400
commitf0f1344105ccd1057d5c7310c7bb295e7fc1702e (patch)
tree797180c8971f9bf6cb5bbf760b65364ceb077455 /lib/Games/SMTNocturne/Demons.pm
parentf38fc9b0f8c6b90b3d93518357d894be5864892e (diff)
downloadgames-smtnocturne-demons-f0f1344105ccd1057d5c7310c7bb295e7fc1702e.tar.gz
games-smtnocturne-demons-f0f1344105ccd1057d5c7310c7bb295e7fc1702e.zip
refactor to support elemental and mitama fusions
Diffstat (limited to 'lib/Games/SMTNocturne/Demons.pm')
-rw-r--r--lib/Games/SMTNocturne/Demons.pm69
1 files changed, 61 insertions, 8 deletions
diff --git a/lib/Games/SMTNocturne/Demons.pm b/lib/Games/SMTNocturne/Demons.pm
index 336a12a..70f861e 100644
--- a/lib/Games/SMTNocturne/Demons.pm
+++ b/lib/Games/SMTNocturne/Demons.pm
@@ -13,14 +13,30 @@ sub fuse {
$demon2 = Games::SMTNocturne::Demons::Demon->from_name($demon2)
unless ref($demon2);
- my $new_type = Games::SMTNocturne::Demons::FusionChart::fuse(
- $demon1->type, $demon2->type
- );
- my $new_level = ($demon1->level + $demon2->level) / 2;
-
- return Games::SMTNocturne::Demons::Demon->from_type_and_level(
- $new_type, $new_level
- );
+ if ($demon1->type eq 'Element' && $demon2->type eq 'Element') {
+ return _fuse_mitama($demon1, $demon2);
+ }
+ elsif ($demon1->type eq 'Element' || $demon2->type eq 'Element') {
+ return _element_fusion(
+ $demon1->type eq 'Element'
+ ? ($demon1, $demon2) : ($demon2, $demon1)
+ );
+ }
+ elsif ($demon1->type eq 'Mitama' && $demon2->type eq 'Mitama') {
+ # XXX what does this do?
+ }
+ elsif ($demon1->type eq 'Mitama' || $demon2->type eq 'Mitama') {
+ return _mitama_fusion(
+ $demon1->type eq 'Mitama'
+ ? ($demon1, $demon2) : ($demon2, $demon1)
+ );
+ }
+ elsif ($demon1->type eq $demon2->type) {
+ return _fuse_element($demon1, $demon2);
+ }
+ else {
+ return _normal_fusion($demon1, $demon2);
+ }
}
sub fusions_for {
@@ -44,4 +60,41 @@ sub fusions_for {
return @fusions;
}
+sub _fuse_mitama {
+ my ($element1, $element2) = @_;
+
+ die "element fusion nyi";
+}
+
+sub _element_fusion {
+ my ($element, $demon) = @_;
+
+ die "element fusion nyi";
+}
+
+sub _mitama_fusion {
+ my ($mitama, $demon) = @_;
+
+ return $demon;
+}
+
+sub _fuse_element {
+ my ($demon1, $demon2) = @_;
+
+ die "element fusion nyi";
+}
+
+sub _normal_fusion {
+ my ($demon1, $demon2) = @_;
+
+ my $new_type = Games::SMTNocturne::Demons::FusionChart::fuse(
+ $demon1->type, $demon2->type
+ );
+ my $new_level = ($demon1->level + $demon2->level) / 2;
+
+ return Games::SMTNocturne::Demons::Demon->from_type_and_level(
+ $new_type, $new_level
+ );
+}
+
1;