Changeset 108

Show
Ignore:
Timestamp:
04/22/07 04:16:57 (3 years ago)
Author:
eevee
Message:

Added better encounter support.. still a ways to go, though.

Location:
veekun/branches/layout
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • veekun/branches/layout/lib/Vee/Controller/Dex.pm

    r107 r108  
    1111use List::MoreUtils qw/uniq/; 
    1212use Storable qw/dclone/; 
     13use Data::Dumper; 
    1314 
    1415=head1 NAME 
     
    412413    my $encounters_rs = $row->encounters_rs(undef, { 
    413414        prefetch  => 'location', 
    414         group_by  => [qw/ location_id section method /], 
     415        group_by  => [qw/ version location_id section method /], 
    415416 
    416417        # this minor hackery will essentially collapse multiple rows for a 
     
    430431    my (%loc_seen_methods, $loc_any_sections, %loc_bases); 
    431432    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 } ||= {}; 
    433434 
    434435        my $is_replacement = grep { $encounter->method eq $_ } qw/ daytime night /; 
     
    439440        my @rarities = split / /, $encounter->rarity; 
    440441 
    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! 
    444443        # 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'; 
    445444 
    446445        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 }) 
    448447        { 
    449448            @rarities = uniq @rarities, split / /, $base_ref->rarity; 
    450             warn $encounter->section; warn @rarities; warn $base_ref->rarity; 
    451449             
     450            # TODO: lol this doesn't work all that well 
    452451            $min = min $min, $base_ref->min_level; 
    453             $max = min $max, $base_ref->max_level; 
     452            $max = max $max, $base_ref->max_level; 
    454453        } 
    455454 
     
    469468            rarity => $rarity, 
    470469        }; 
    471         $loc_bases{ $encounter->location->name }{ $encounter->section } = $encounter 
     470        $loc_bases{ $encounter->version }{ $encounter->location->name }{ $encounter->section } = $encounter 
    472471            if $encounter->method eq 'grass'; 
    473472 
     
    475474        $loc_any_sections = 1 if $encounter->section; 
    476475    } 
     476 
     477    local $Data::Dumper::Sortkeys = 1; 
     478    if ( Dumper($locations{diamond}) eq Dumper($locations{pearl}) ) { 
     479        %locations = ( dp => $locations{diamond} ); 
     480    } 
     481 
    477482    $s->{encounters} = \%locations; 
    478483 
  • veekun/branches/layout/lib/Vee/Dex.pm

    r92 r108  
    3939    { games => 'Gold/Silver/Crystal',             short => 'new',  abbr => 'gsc', maxid => 251, maxmoveid => 251, region => 'Johto', }, 
    4040    { 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 => 'Shinou', 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 => 'Sinnoh', locpercents => [qw/20 20 10 10 10 10 5 5 4 4 1 1/], locsurfpercents => [qw/60 30 5 4 1/], }, 
    4242); 
    4343 
  • veekun/branches/layout/templates/dex/page/pokemon.tt

    r107 r108  
    322322 
    323323<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 %] 
    325330[% IF location_columns.keys.size %] 
    326331<table cellspacing="0" cellpadding="3" class="dex-table dex-locations"> 
     
    379384[% END %] 
    380385[% 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 %] 
    384389<tr class="color[% color %]"> 
    385390    <td class="dex-locations-zone">[% location %]</td>[% IF location_columns.section %] <td class="dex-locations-zone">[% section %]</td>[% END %] 
    386391[% 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> 
    388393[% END %] 
    389394[% 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> 
    391396[% END %] 
    392397[% 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> 
    394399[% END %] 
    395400[%         FOR m IN ['surfing', 'old-rod', 'good-rod', 'super-rod'] %] 
     
    403408    <td>[% IF methods.poketore %]<img src="/dex-images/items/poketore.png" alt="poketore"/>[% END %]</td> 
    404409[% END %] 
    405 [%         IF location_columns.dualslot %]  
     410[% IF location_columns.dualslot %]  
    406411    <td class="dex-locations-ds">[% Icons.ru IF methods.${'ds-ruby'} %]</td> 
    407412    <td class="dex-locations-ds">[% Icons.sa IF methods.${'ds-sapphire'} %]</td> 
     
    411416[% END %] 
    412417</tr> 
    413 [%         color = 3 - color %] 
     418[%             color = 3 - color %] 
    414419[%     END %] 
    415420[% END %] 
    416421</table> 
    417422[% ELSE %] 
    418 <p> This Pok&eacute;mon is not available in the wild in D/P. </p> 
     423<p> This Pok&eacute;mon is not available in the wild. </p> 
     424[% END %] 
    419425[% END %] 
    420426<!-- ####################################################################### -->