Changeset 380
- Timestamp:
- 11/14/07 00:22:10 (2 years ago)
- Location:
- veekun/trunk
- Files:
-
- 2 modified
-
lib/Vee/Controller/Dex.pm (modified) (3 diffs)
-
templates/dex/page/move.tt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
veekun/trunk/lib/Vee/Controller/Dex.pm
r379 r380 16 16 # TODO: move this somewhere shared 17 17 my $MAX_WILDCARD_RESULTS = 10; # maximum wildcard matches per category 18 my $MAX_LEARNERS = 50; # maximum learners per method on a move page 18 19 19 20 =head1 NAME … … 982 983 my $method = 'other'; 983 984 $method = $pm->method if $valid_methods{ $pm->method }; 984 for my $ver (split /,/, $pm->version) { 985 my @versions; 986 987 if ($method eq 'other') { 988 # XXX: this will break if there are more other moves than the max 989 @versions = ('all'); 990 } else { 991 @versions = split /,/, $pm->version; 992 } 993 994 for my $ver (@versions) { 985 995 $pokemon_hash{$method}{$pm->pokeid}{pokemon} ||= $pm->pokemon; 986 996 $pokemon_hash{$method}{$pm->pokeid}{$ver} = $pm->level || 1; … … 991 1001 my %learners; # method => [ version => level, pokemon => pokemon ] 992 1002 for my $method (keys %pokemon_hash) { 993 @{ $learners{$method} } = sort { $a->{pokemon}->name cmp $b->{pokemon}->name } values %{ $pokemon_hash{$method} }; 1003 my @sorted_learners = sort { 1004 $a->{pokemon}->name cmp $b->{pokemon}->name 1005 } values %{ $pokemon_hash{$method} }; 1006 1007 if (@sorted_learners > $MAX_LEARNERS) { 1008 $learners{$method} = {}; 1009 for my $learner_hash (@sorted_learners) { 1010 for my $version (keys %$learner_hash) { 1011 $learners{$method}{$version}++; 1012 } 1013 } 1014 } else { 1015 $learners{$method} = \@sorted_learners; 1016 } 994 1017 } 995 1018 -
veekun/trunk/templates/dex/page/move.tt
r379 r380 178 178 <!-- ####################################################################### --> 179 179 180 <h1>Pokémon</h1> 181 <p> <a href="[% c.uri_for('pokemon/search', { move => this.name }) %]"><img src="/images/see-also.png" alt="See also:"/> All [% pokemon_count %] in the Pokémon search</a> </p> 182 180 183 [% learn_versions = ['rb','y','gs','c','rusa','frlg','dp'] %] 181 184 182 185 [% IF learners.level %] 183 186 <h2>By leveling up</h2> 187 <p class="total">[% learners.level.size %] Pokémon</p> 184 188 <table cellspacing="0" class="dex-table dex-pokemon"> 185 189 <tr class="heading"> … … 211 215 [% END %] 212 216 </table> 213 <div class="total">Level-up Pokémon: [% learners.level.size %]</div>214 217 [% END %] 215 218 … … 219 222 [% tutor_versions = ['c','e','frlg','dp'] %] 220 223 [% machine_versions = ['rby','gsc','rsfl','dp'] %] 224 [% other_versions = [] %] 221 225 [% versions_map = { 'rby' => 'y', 'gsc' => 'c', 'rsfl' => 'rusa' } %] 222 226 223 <h1>Pokémon</h1>224 <p> <a href="[% c.uri_for('pokemon/search', { move => this.name }) %]"><img src="/images/see-also.png" alt="See also:"/> This move in the Pokémon search</a> </p>225 226 227 [%# TODO: yellow/crystal-only TMs %] 227 228 228 [% FOREACH method IN ['machine', 'egg', 'tutor' ] %]229 [% FOREACH method IN ['machine', 'egg', 'tutor', 'other'] %] 229 230 [% NEXT IF NOT learners.exists(method) %] 230 231 [% list = learners.$method %] 232 [% tmp = method _ '_versions'; our_versions = $tmp %] 231 233 <h2>[% method | ucfirst %]</h2> 234 [% IF list.exists('pokemon') # this is a too-big hash %] 235 <p> Too many to list! </p> 236 <ul> 237 [% FOR version IN our_versions %] 238 [% specific_version = versions_map.exists(version) ? versions_map.$version : version %] 239 <li> <a href="[% c.uri_for('pokemon/search', { move => this.name, move_method => method, move_version => specific_version }) %]">[% Icons.$version +%] [%+ list.$specific_version %]</a> </li> 240 [% END %] 241 <li> <a href="[% c.uri_for('pokemon/search', { move => this.name, move_method => method }) %]">Total: [% list.$specific_version %]</a> </li> 242 </ul> 243 [% NEXT %] 244 [% END %] 245 <p class="total">[% list.size %] Pokémon</p> 232 246 <table cellspacing="0" class="dex-table dex-pokemon"> 233 247 <tr class="heading"> 234 [% tmp = method _ '_versions'; our_versions = $tmp %]235 248 [% FOREACH version IN our_versions %] 236 249 <th class="level">[% Icons.$version %]</th> … … 261 274 [% END %] 262 275 </table> 263 <div class="total">[% list.size %] Pokémon</div> 264 [% END %] 265 266 <hr/> 267 <div class="total">Total Pokémon: [% pokemon_count %]</div> 276 [% END %] 268 277 269 278 <!-- ####################################################################### -->
