Changeset 429

Show
Ignore:
Timestamp:
04/27/08 20:49:18 (2 months ago)
Author:
eevee
Message:

Few small fixes for new breeding chains applet (#302).
Deals a little better with invalid moves/Pokemon, form actually works.

Location:
veekun/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee/Controller/Dex/Utils.pm

    r428 r429  
    247247    # XXX do the retrievals in Inflator code 
    248248    my $pokemon = $c->model('DBIC::Pokemon')->find($form->param_value('pokemon')); 
    249     warn join '|', $form->param_list('move'); 
    250249    my @moves   = map { $c->model('DBIC::Moves')->find($_) } $form->param_list('move'); 
    251250 
     
    253252    my $version = 'dp'; 
    254253 
     254    ### Misc error handling 
     255 
     256    if ($pokemon->breeding_code == 255) { 
     257        $s->{error_msg} = $pokemon->name . ' cannot breed.'; 
     258        return; 
     259    } 
     260 
     261    my @unlearnable_moves; 
     262    for my $move (@moves) { 
     263        my $method = $pokemon->move_method_string($move, $version); 
     264        if (not $method) { 
     265            push @unlearnable_moves, $move; 
     266        } 
     267    } 
     268    if (@unlearnable_moves) { 
     269        my @move_names = map { $_->name } @unlearnable_moves; 
     270        if (@move_names > 2) { 
     271            $move_names[-1] = 'or ' . $move_names[-1]; 
     272        } 
     273        $s->{error_msg} = $pokemon->name . " cannot inherit " 
     274                        . join(', ', @move_names) . '.'; 
     275        return; 
     276    } 
     277 
     278    # Find potential members of the genealogy 
    255279    my @learners = $c->model('DBIC::Pokemon')->search( { 
    256280        -or => [ { 
     281            -nest => \ "FIND_IN_SET('dp', pokemon_moves.versions)", 
    257282            'pokemon_moves.move_id' => $moves[0]->id, 
    258283            'pokemon_moves.method'  => [qw[ level egg machine ]], 
    259             -nest   => \ "FIND_IN_SET('dp', pokemon_moves.versions)", 
    260 #            'pokemon.gender_rate' => $gender_restriction, 
     284            'gender_rate'           => { -not_in => [ 0, 254, 255 ] }, 
    261285        }, { 
    262286            # Smeargle can, technically, learn anything 
  • veekun/trunk/templates/dex/utils/breeding_chains.tt

    r428 r429  
    22 
    33<h1>Breeding Chain Finder</h1> 
     4[% form.start %] 
    45<dl class="compact"> 
    56    <dt>Pok&eacute;mon</dt> 
     
    89    <dd>[% form.get_field(name => 'move') %]</dd> 
    910</dl> 
    10   <p> <input type="submit" value="Find chains"/> <input type="reset" value="Reset form"/> </p> 
     11<p> <input type="submit" value="Find chains"/> <input type="reset" value="Reset form"/> </p> 
     12[% form.end %] 
    1113[% RETURN IF NOT form.submitted OR form.has_errors %] 
    1214 
    1315<h1>Chains</h1> 
     16[% IF NOT flattened_tree %] 
     17<p> No breeding chains found. </p> 
     18[%     RETURN %] 
     19[% END %] 
     20 
    1421<p> This tree is arranged by combinations of egg groups.  Any Pok&eacute;mon from a set may be used; since they have the same egg groups, they are all equally valid partners for all the Pok&eacute;mon in the sets above and below them. </p> 
    1522 
     
    2229[% color = 1 %] 
    2330[% FOR node IN flattened_tree %] 
    24 [%     indent_style = 'style="padding-left: ' _ (node.indent  * 2) _ 'em;"' %] 
     31[%     indent_style = 'style="padding-left: ' _ (node.indent * 32) _ 'px;"' %] 
    2532[%     UNLESS loop.first %] 
    2633<tr class="heading left">