summaryrefslogtreecommitdiffstats
path: root/lib/Games/SMTNocturne/Demons
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-05-25 10:39:31 -0400
committerJesse Luehrs <doy@tozt.net>2014-05-25 10:39:31 -0400
commit26bba9f137ac161c9c394c74332968fd91d7acfc (patch)
tree7eb735c2884dcba4ff2c697a7a4be44867a68ba6 /lib/Games/SMTNocturne/Demons
parent03e8cf1b65841d6264fb021af6c7460dabac931f (diff)
downloadgames-smtnocturne-demons-26bba9f137ac161c9c394c74332968fd91d7acfc.tar.gz
games-smtnocturne-demons-26bba9f137ac161c9c394c74332968fd91d7acfc.zip
refactor
Diffstat (limited to 'lib/Games/SMTNocturne/Demons')
-rw-r--r--lib/Games/SMTNocturne/Demons/Demon.pm14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Games/SMTNocturne/Demons/Demon.pm b/lib/Games/SMTNocturne/Demons/Demon.pm
index 7371df5..41b689a 100644
--- a/lib/Games/SMTNocturne/Demons/Demon.pm
+++ b/lib/Games/SMTNocturne/Demons/Demon.pm
@@ -30,14 +30,20 @@ sub from_name {
}
sub from_fusion_stats {
- my ($class, $type, $level, $fusion_type) = @_;
+ my ($class, $options) = @_;
- die "unknown type $type" unless $DEMONS_BY_TYPE{$type};
+ die "unknown type $options->{type}"
+ unless $DEMONS_BY_TYPE{$options->{type}};
+
+ my @possible = @{ $DEMONS_BY_TYPE{$options->{type}} };
+
+ @possible = grep { $_->fusion_type eq $options->{fusion_type} } @possible
+ if $options->{fusion_type};
my $found;
- for my $demon (grep { $_->fusion_type eq $fusion_type } @{ $DEMONS_BY_TYPE{$type} }) {
+ for my $demon (@possible) {
$found = $demon;
- last if $demon->level >= $level;
+ last if $demon->level >= $options->{level};
}
return $found;