Changeset 406 for veekun/trunk/lib/Vee/Controller/Dex/Search.pm
- Timestamp:
- 02/08/08 02:44:39 (2 years ago)
- Files:
-
- 1 modified
-
veekun/trunk/lib/Vee/Controller/Dex/Search.pm (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
veekun/trunk/lib/Vee/Controller/Dex/Search.pm
r348 r406 49 49 breed => { type => 'select', options => [ [ 0 => 'n/a' ], map { [ $_ => ($_ ? "$_: " : '') . $BreedingGroups[$_] ] } 1 .. $#BreedingGroups ], count => 2 }, 50 50 breed_mode => { type => 'select', options => [ [ and => 'exactly' ], [ or => 'either of' ] ], default => 'or' }, 51 gender => { type => 'select', options => [ [ any => 'anything' ], [ 255 => 'no gender' ], [ not255 => 'any gender' ], map { [ $_ => lc gender_text($_) ] } qw/0 31 63 127 191 254/ ] },51 gender_rate => { type => 'select', options => [ [ any => 'anything' ], [ 255 => 'no gender' ], [ not255 => 'any gender' ], map { [ $_ => lc gender_text($_) ] } qw/0 31 63 127 191 254/ ] }, 52 52 ability => { type => 'text', size => 20, title => 'Enter the name or number of an ability' }, 53 53 color => { type => 'select', options => [qw/any black blue brown gray green pink purple red white yellow/], title => 'I have no explanation for why this is here' }, … … 123 123 if ($ability) { 124 124 $joins{pokemon_abilities} = 1; 125 $criteria{'pokemon_abilities.ability id'} = $ability->id;125 $criteria{'pokemon_abilities.ability_id'} = $ability->id; 126 126 } 127 127 } … … 142 142 143 143 # BREEDING AND STUFF 144 if (defined $p->{gender } and $p->{gender} ne 'any') {145 if ($p->{gender } eq 'not255') {146 $criteria{'me.gender '} = { '!=' => 255 };144 if (defined $p->{gender_rate} and $p->{gender_rate} ne 'any') { 145 if ($p->{gender_rate} eq 'not255') { 146 $criteria{'me.gender_rate'} = { '!=' => 255 }; 147 147 } else { 148 $criteria{'me.gender '} = $p->{gender};148 $criteria{'me.gender_rate'} = $p->{gender_rate}; 149 149 } 150 150 } … … 154 154 $criteria{'breeds.breed'} = \@breeds; 155 155 if ($p->{breed_mode} eq 'and') { 156 $clauses{having}{'COUNT(DISTINCT breeds.poke id, breeds.breed)'} = scalar @breeds;156 $clauses{having}{'COUNT(DISTINCT breeds.pokemon_id, breeds.breed)'} = scalar @breeds; 157 157 158 158 if (@breeds == 1) { … … 192 192 for my $move (@{ $p->{move} }) { 193 193 # XXX: show some message if a move is invalid? 194 my $move id = get_move($move);195 push @moveids, $move id if defined $moveid;194 my $move_id = get_move($move); 195 push @moveids, $move_id if defined $move_id; 196 196 } 197 197 if (@moveids) { 198 $joins{pokemo ves} = 1;199 $criteria{'pokemo ves.moveid'} = \@moveids;200 $clauses{having}{'COUNT(DISTINCT pokemo ves.pokeid, pokemoves.moveid)'} = scalar @moveids;198 $joins{pokemon_moves} = 1; 199 $criteria{'pokemon_moves.move_id'} = \@moveids; 200 $clauses{having}{'COUNT(DISTINCT pokemon_moves.pokemon_id, pokemon_moves.move_id)'} = scalar @moveids; 201 201 202 202 if ($p->{move_method}) { 203 $criteria{'pokemo ves.method'} = $p->{move_method};203 $criteria{'pokemon_moves.method'} = $p->{move_method}; 204 204 } 205 205 if ($p->{move_version}) { 206 push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemo ves.version)" } Vee::Utils::array($p->{move_version}) ] };206 push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemon_moves.versions)" } Vee::Utils::array($p->{move_version}) ] }; 207 207 } 208 208 } … … 237 237 238 238 if ($evo_stages{base}) { 239 $criteria{'me.ev parent'} = 0;239 $criteria{'me.evo_parent_id'} = 0; 240 240 } 241 241 … … 308 308 }; 309 309 310 for my $col (qw/power acc pp effect_chance priority/) {310 for my $col (qw/power accuracy pp effect_chance priority/) { 311 311 for my $endpoint (keys %endpoints) { 312 312 $move_search_fields->{ $col . '_' . $endpoint } = { type => 'text', size => 4, maxlength => 3, title => "\u$endpoints{$endpoint}{english} $col" }; … … 366 366 } 367 367 if (@pokemonids) { 368 $joins{pokemo ves} = 1;369 $criteria{'pokemo ves.pokeid'} = \@pokemonids;370 $clauses{having}{'COUNT(DISTINCT pokemo ves.pokeid, pokemoves.moveid)'} = scalar @pokemonids;368 $joins{pokemon_moves} = 1; 369 $criteria{'pokemon_moves.pokemon_id'} = \@pokemonids; 370 $clauses{having}{'COUNT(DISTINCT pokemon_moves.pokemon_id, pokemon_moves.move_id)'} = scalar @pokemonids; 371 371 372 372 if ($p->{move_method}) { 373 $criteria{'pokemo ves.method'} = $p->{move_method};373 $criteria{'pokemon_moves.method'} = $p->{move_method}; 374 374 } 375 375 if ($p->{move_version}) { 376 push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemo ves.version)" } Vee::Utils::array($p->{move_version}) ] };376 push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemon_moves.versions)" } Vee::Utils::array($p->{move_version}) ] }; 377 377 } 378 378 } … … 380 380 381 381 # NUMBERS 382 for my $numbar (qw/power acc pp effect_chance priority/) {382 for my $numbar (qw/power accuracy pp effect_chance priority/) { 383 383 for my $endpoint (keys %endpoints) { 384 384 my $value = $p->{$numbar . '_' . $endpoint};
