Changeset 108
- Timestamp:
- 04/22/07 04:16:57 (3 years ago)
- Location:
- veekun/branches/layout
- Files:
-
- 3 modified
-
lib/Vee/Controller/Dex.pm (modified) (6 diffs)
-
lib/Vee/Dex.pm (modified) (1 diff)
-
templates/dex/page/pokemon.tt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
veekun/branches/layout/lib/Vee/Controller/Dex.pm
r107 r108 11 11 use List::MoreUtils qw/uniq/; 12 12 use Storable qw/dclone/; 13 use Data::Dumper; 13 14 14 15 =head1 NAME … … 412 413 my $encounters_rs = $row->encounters_rs(undef, { 413 414 prefetch => 'location', 414 group_by => [qw/ location_id section method /],415 group_by => [qw/ version location_id section method /], 415 416 416 417 # this minor hackery will essentially collapse multiple rows for a … … 430 431 my (%loc_seen_methods, $loc_any_sections, %loc_bases); 431 432 while (my $encounter = $encounters_rs->next) { 432 my $sec_ref = $locations{ $encounter-> location->name }{ $encounter->section } ||= {};433 my $sec_ref = $locations{ $encounter->version }{ $encounter->location->name }{ $encounter->section } ||= {}; 433 434 434 435 my $is_replacement = grep { $encounter->method eq $_ } qw/ daytime night /; … … 439 440 my @rarities = split / /, $encounter->rarity; 440 441 441 # this assumes that the levels are already in the database, although 442 # it will quietly assume otherwise if they happen to be zero, in which 443 # case the levels will just potentially be off a bit. 442 # this assumes that the levels are already in the database! 444 443 # sql: UPDATE location_encounters l INNER JOIN location_encounters l2 USING (location_id, section, rarity) SET l.min_level = l2.min_level, l.max_level = l2.max_level WHERE l.method IN ('daytime', 'night') AND l2.method = 'grass'; 445 444 446 445 if ($is_replacement and 447 my $base_ref = $loc_bases{ $encounter-> location->name }{ $encounter->section })446 my $base_ref = $loc_bases{ $encounter->version }{ $encounter->location->name }{ $encounter->section }) 448 447 { 449 448 @rarities = uniq @rarities, split / /, $base_ref->rarity; 450 warn $encounter->section; warn @rarities; warn $base_ref->rarity;451 449 450 # TODO: lol this doesn't work all that well 452 451 $min = min $min, $base_ref->min_level; 453 $max = m in$max, $base_ref->max_level;452 $max = max $max, $base_ref->max_level; 454 453 } 455 454 … … 469 468 rarity => $rarity, 470 469 }; 471 $loc_bases{ $encounter-> location->name }{ $encounter->section } = $encounter470 $loc_bases{ $encounter->version }{ $encounter->location->name }{ $encounter->section } = $encounter 472 471 if $encounter->method eq 'grass'; 473 472 … … 475 474 $loc_any_sections = 1 if $encounter->section; 476 475 } 476 477 local $Data::Dumper::Sortkeys = 1; 478 if ( Dumper($locations{diamond}) eq Dumper($locations{pearl}) ) { 479 %locations = ( dp => $locations{diamond} ); 480 } 481 477 482 $s->{encounters} = \%locations; 478 483 -
veekun/branches/layout/lib/Vee/Dex.pm
r92 r108 39 39 { games => 'Gold/Silver/Crystal', short => 'new', abbr => 'gsc', maxid => 251, maxmoveid => 251, region => 'Johto', }, 40 40 { games => 'Ruby/Sapphire/Emerald/Fire/Leaf', short => 'rusa', abbr => 'rse', maxid => 386, maxmoveid => 354, region => 'Hoenn', locpercents => [qw/20 20 10 10 10 10 5 5 4 4 1 1/], }, 41 { games => 'Diamond/Pearl', short => 'dp', abbr => 'dp', maxid => 493, maxmoveid => 470, region => 'S hinou', locpercents => [qw/20 20 10 10 10 10 5 5 4 4 11/], },41 { games => 'Diamond/Pearl', short => 'dp', abbr => 'dp', maxid => 493, maxmoveid => 470, region => 'Sinnoh', locpercents => [qw/20 20 10 10 10 10 5 5 4 4 1 1/], locsurfpercents => [qw/60 30 5 4 1/], }, 42 42 ); 43 43 -
veekun/branches/layout/templates/dex/page/pokemon.tt
r107 r108 322 322 323 323 <h1>Locations</h1> 324 <p> <a href="[% dex_uri('pokemon', this.name) %]/map[%# TODO %]"><img src="/images/see-also.png" alt="See also:"/> Location map</a> </p> 324 <p> Location map will return shortly... </p> 325 [%# TODO: this is hacky! %] 326 [% FOR version IN encounters.keys.sort %] 327 [% IF version != 'dp' %] 328 <h2>[% Icons.${ version.substr(0, 1) } %] [% version | ucfirst %]</h2> 329 [% END %] 325 330 [% IF location_columns.keys.size %] 326 331 <table cellspacing="0" cellpadding="3" class="dex-table dex-locations"> … … 379 384 [% END %] 380 385 [% color = 1 %] 381 [% FOR location IN encounters. keys.sort %]382 [% FOR section IN encounters.$ location.keys.sort %]383 [% methods = encounters.$location.$section %]386 [% FOR location IN encounters.$version.keys.sort %] 387 [% FOR section IN encounters.$version.$location.keys.sort %] 388 [% methods = encounters.$version.$location.$section %] 384 389 <tr class="color[% color %]"> 385 390 <td class="dex-locations-zone">[% location %]</td>[% IF location_columns.section %] <td class="dex-locations-zone">[% section %]</td>[% END %] 386 391 [% IF location_columns.grass %] 387 <td>[% methods.grass.level %][% IF methods.grass.rarity %]<div class="minibar" title="[% methods.grass.rarity %]%"><div class=" minibar-bar" style="width: [% methods.grass.rarity %]%;"></div></div>[% END %]</td>392 <td>[% methods.grass.level %][% IF methods.grass.rarity %]<div class="minibar" title="[% methods.grass.rarity %]%"><div class="fill" style="width: [% methods.grass.rarity %]%;"></div></div>[% END %]</td> 388 393 [% END %] 389 394 [% IF location_columns.daytime %] 390 <td>[% IF methods.daytime %][% methods.daytime.level %][% IF methods.daytime.rarity %]<div class="minibar" title="[% methods.daytime.rarity %]%"><div class=" minibar-bar" style="width: [% methods.daytime.rarity %]%;"></div></div>[% END %][% END %]</td>395 <td>[% IF methods.daytime %][% methods.daytime.level %][% IF methods.daytime.rarity %]<div class="minibar" title="[% methods.daytime.rarity %]%"><div class="fill" style="width: [% methods.daytime.rarity %]%;"></div></div>[% END %][% END %]</td> 391 396 [% END %] 392 397 [% IF location_columns.night %] 393 <td>[% IF methods.night %][% methods.night.level %][% IF methods.night.rarity %]<div class="minibar" title="[% methods.night.rarity %]%"><div class=" minibar-bar" style="width: [% methods.night.rarity %]%;"></div></div>[% END %][% END %]</td>398 <td>[% IF methods.night %][% methods.night.level %][% IF methods.night.rarity %]<div class="minibar" title="[% methods.night.rarity %]%"><div class="fill" style="width: [% methods.night.rarity %]%;"></div></div>[% END %][% END %]</td> 394 399 [% END %] 395 400 [% FOR m IN ['surfing', 'old-rod', 'good-rod', 'super-rod'] %] … … 403 408 <td>[% IF methods.poketore %]<img src="/dex-images/items/poketore.png" alt="poketore"/>[% END %]</td> 404 409 [% END %] 405 [% IF location_columns.dualslot %]410 [% IF location_columns.dualslot %] 406 411 <td class="dex-locations-ds">[% Icons.ru IF methods.${'ds-ruby'} %]</td> 407 412 <td class="dex-locations-ds">[% Icons.sa IF methods.${'ds-sapphire'} %]</td> … … 411 416 [% END %] 412 417 </tr> 413 [% color = 3 - color %]418 [% color = 3 - color %] 414 419 [% END %] 415 420 [% END %] 416 421 </table> 417 422 [% ELSE %] 418 <p> This Pokémon is not available in the wild in D/P. </p> 423 <p> This Pokémon is not available in the wild. </p> 424 [% END %] 419 425 [% END %] 420 426 <!-- ####################################################################### -->
