Show
Ignore:
Timestamp:
05/23/08 02:41:12 (22 months ago)
Author:
eevee
Message:

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.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee/Schema/EvoChains.pm

    r406 r432  
    2323__PACKAGE__->has_many(pokemon => 'Vee::Schema::Pokemon', 'evo_chain_id'); 
    2424 
     25=head2 baby_form 
     26 
     27Returns the baby Pokemon in this chain, if any. 
     28 
     29=cut 
     30 
     31sub baby_form { 
     32    my ($self) = @_; 
     33 
     34    return $self->pokemon( \ 'FIND_IN_SET(flags, "baby")' )->single; 
     35} 
     36 
     37=head2 basic_form 
     38 
     39Returns the basic form of this Pokemon. 
     40 
     41=cut 
     42 
     43sub 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 
     55Returns any Pokemon that can result from a breeding in this chain. 
     56 
     57=cut 
     58 
     59sub 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 
    2578=head1 SEE ALSO 
    2679