|
Revision 432, 1.5 KB
(checked in by eevee, 22 months ago)
|
|
Changed breeding chain calculator to interpret its Pokemon input as a target rather than.. whatever it was before. (#309)
Also added some more detail on reading the results.
|
| Line | |
|---|
| 1 | package Vee::Schema::EvoChains; |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | use base 'DBIx::Class'; |
|---|
| 6 | |
|---|
| 7 | =head1 NAME |
|---|
| 8 | |
|---|
| 9 | Vee::Schema::EvoChains - DBIC class for the C<evo_chains> table |
|---|
| 10 | |
|---|
| 11 | =cut |
|---|
| 12 | |
|---|
| 13 | __PACKAGE__->load_components('Core'); |
|---|
| 14 | __PACKAGE__->table('evo_chains'); |
|---|
| 15 | __PACKAGE__->add_columns(qw/ |
|---|
| 16 | id |
|---|
| 17 | growth_rate |
|---|
| 18 | steps |
|---|
| 19 | baby_item |
|---|
| 20 | /); |
|---|
| 21 | __PACKAGE__->set_primary_key('id'); |
|---|
| 22 | |
|---|
| 23 | __PACKAGE__->has_many(pokemon => 'Vee::Schema::Pokemon', 'evo_chain_id'); |
|---|
| 24 | |
|---|
| 25 | =head2 baby_form |
|---|
| 26 | |
|---|
| 27 | Returns the baby Pokemon in this chain, if any. |
|---|
| 28 | |
|---|
| 29 | =cut |
|---|
| 30 | |
|---|
| 31 | sub baby_form { |
|---|
| 32 | my ($self) = @_; |
|---|
| 33 | |
|---|
| 34 | return $self->pokemon( \ 'FIND_IN_SET(flags, "baby")' )->single; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | =head2 basic_form |
|---|
| 38 | |
|---|
| 39 | Returns the basic form of this Pokemon. |
|---|
| 40 | |
|---|
| 41 | =cut |
|---|
| 42 | |
|---|
| 43 | sub basic_form { |
|---|
| 44 | my ($self) = @_; |
|---|
| 45 | |
|---|
| 46 | return $self->pokemon( |
|---|
| 47 | \ 'NOT FIND_IN_SET(flags, "baby")', |
|---|
| 48 | { |
|---|
| 49 | order_by => 'id ASC', |
|---|
| 50 | })->first; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | =head2 egg_forms |
|---|
| 54 | |
|---|
| 55 | Returns any Pokemon that can result from a breeding in this chain. |
|---|
| 56 | |
|---|
| 57 | =cut |
|---|
| 58 | |
|---|
| 59 | sub egg_forms { |
|---|
| 60 | my ($self) = @_; |
|---|
| 61 | my @ret; |
|---|
| 62 | |
|---|
| 63 | my $baby_form = $self->baby_form; |
|---|
| 64 | if ($baby_form) { |
|---|
| 65 | push @ret, $baby_form; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | my $basic_form = $self->basic_form; |
|---|
| 69 | if (not $baby_form |
|---|
| 70 | or $self->baby_item) # e.g. Munchlax with incense |
|---|
| 71 | { |
|---|
| 72 | push @ret, $basic_form; |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | return @ret; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | =head1 SEE ALSO |
|---|
| 79 | |
|---|
| 80 | L<Vee::Schema>, L<DBIx::Class> |
|---|
| 81 | |
|---|
| 82 | =head1 AUTHOR |
|---|
| 83 | |
|---|
| 84 | Maintainer: Alex "Eevee" Munroe (C<veekun@veekun.com>) |
|---|
| 85 | |
|---|
| 86 | See the included F<AUTHORS> file for a full list of contributers. |
|---|
| 87 | |
|---|
| 88 | =head1 LICENSE |
|---|
| 89 | |
|---|
| 90 | See the included F<LICENSE> file. |
|---|
| 91 | |
|---|
| 92 | =cut |
|---|
| 93 | |
|---|
| 94 | 1; |
|---|