Changeset 393
- Timestamp:
- 12/29/07 21:29:06 (11 months ago)
- Location:
- veekun/trunk
- Files:
-
- 2 added
- 8 modified
- 1 moved
-
lib/Vee/Controller/Dex.pm (modified) (1 diff)
-
lib/Vee/Dex/EncounterSet.pm (modified) (5 diffs)
-
lib/Vee/Schema/LocationEncounters.pm (modified) (2 diffs)
-
lib/Vee/Schema/LocationSections.pm (added)
-
lib/Vee/Schema/Locations.pm (modified) (1 diff)
-
lib/Vee/Schema/Pokemon.pm (modified) (1 diff)
-
root/dex-images/gameui/daytime.png (moved) (moved from veekun/trunk/root/dex-images/gameui/day.png)
-
root/dex-images/gameui/morning.png (added)
-
templates/dex/common.tt (modified) (1 diff)
-
templates/dex/page/location.tt (modified) (1 diff)
-
templates/dex/page/pokemon.tt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
veekun/trunk/lib/Vee/Controller/Dex.pm
r390 r393 993 993 994 994 my %encounters; 995 my $encounters_rs = $row->encounters_rs({ 996 method => { '!=' => [qw/ surfing old-rod good-rod super-rod /] }, # temporary 997 }, { 998 order_by => 'section ASC, method = "grass" DESC', 999 }); 1000 while (my $encounter_row = $encounters_rs->next) { 1001 my $arrayref = $encounters{ $encounter_row->section } 1002 ->{ $encounter_row->method } ||= []; 1003 1004 # copy the grass values over for replacement rows whose mechanics we're 1005 # pretty sure about 1006 @$arrayref = @{ dclone $encounters{ $encounter_row->section }{grass} } 1007 if not @$arrayref and 1008 (grep { $encounter_row->method eq $_ } qw/ daytime night poketore swarm / 1009 or $encounter_row->method =~ /^ds-/); 1010 1011 if (defined $arrayref->[ $encounter_row->rarity ]) { 1012 $arrayref->[ $encounter_row->rarity ]{pokemon} = 1013 $encounter_row->pokemon_id; 1014 } else { 1015 $arrayref->[ $encounter_row->rarity ] = { 1016 pokemon => $encounter_row->pokemon_id, 1017 level => $encounter_row->level, 1018 }; 1019 } 1020 } 1021 1022 my %pokemon; 1023 # my $rarity_key = ($method =~ /rod|surfing/) ? 'locsurfpercents' : 'locpercents'; 1024 my $rarity_ct = scalar @{ $Generations[-1]{locpercents} }; 1025 for my $section (keys %encounters) { 1026 for my $method (keys %{ $encounters{$section} }) { 1027 my @poke_list = @{ $encounters{$section}{$method} }; 1028 1029 # if this isn't a full list, leave it alone and return 1030 if (@poke_list != $rarity_ct or not defined $poke_list[0]) { 1031 # WRONG: $pokemon{$section}{$method} = [ uniq map { $_->{pokemon} } grep { $_ } @poke_list ]; 1032 next; 1033 } 1034 1035 for my $index (0 .. $rarity_ct - 1) { 1036 $pokemon{$section}{ $poke_list[$index]{pokemon} } 1037 { $poke_list[$index]{level} }{$method} += 1038 $Generations[-1]{locpercents}[$index]; 1039 } 1040 } 1041 } 1042 995 996 my $sections_rs = $row->sections_rs; 997 while (my $section = $sections_rs->next) { 998 my $grouped_pokemon_rs = $section->encounters_rs( { 999 version => 'diamond', 1000 }, { 1001 group_by => 'pokemon_id', 1002 } ); 1003 1004 while (my $enc_pokemon = $grouped_pokemon_rs->next) { 1005 my $encounters_rs = $section->encounters_rs( { 1006 version => 'diamond', 1007 pokemon_id => $enc_pokemon->pokemon->id, 1008 } ); 1009 $encounters_rs->reset; 1010 1011 push @{ $encounters{$section->name} }, Vee::Dex::EncounterSet->new( 1012 $encounters_rs, 1013 $enc_pokemon->pokemon, 1014 ); 1015 } 1016 1017 @{ $encounters{$section->name} } = sort { 1018 $a->pokemon->name cmp $b->pokemon->name 1019 } @{ $encounters{$section->name} }; 1020 } 1021 1043 1022 $s->{this} = $row; 1044 $s->{encounters} = \% pokemon;1023 $s->{encounters} = \%encounters; 1045 1024 } 1046 1025 -
veekun/trunk/lib/Vee/Dex/EncounterSet.pm
r388 r393 7 7 8 8 use List::Util qw/sum/; 9 use List::MoreUtils qw/uniq/; 9 10 10 11 use Vee::Dex; … … 153 154 $self->pokemon($pokemon); 154 155 my $arbitrary_row = $rs->first; 155 $self->location($arbitrary_row-> location);156 $self->location($arbitrary_row->section->location); 156 157 $self->section($arbitrary_row->section); 157 158 $rs->reset; … … 170 171 # } 171 172 173 # warn $self->location->name, ' [', $self->section->name, "]\n"; 172 174 while (my $enc = $rs->next) { 175 # warn join ' ', $enc->method, $enc->pokemon->name, $enc->rarity, $enc->level; 173 176 my ($slot_category, $slot_bucket); 174 177 if ($WaterMethods{ $enc->method }) { … … 277 280 follows: 278 281 279 level => [ $min, $max ], 280 rarity => $rarity, 281 method => { $category => $bucket }, 282 level => [ $min, $max ], 283 category => $category, 284 rarities => [ 285 { rarity => $rarity, buckets => \@buckets }, 286 ... 287 ], 288 buckets => { 289 $bucket => $rarity, 290 ... 291 }, 282 292 283 293 C<$min> and C<$max> are the minimum and maximum levels at which the Pokemon 284 294 can appear with this method. 285 295 286 C<$category> and C<$bucket> are the category and bucket, respectively, in which 287 this Pokemon most simply appears. Note that in the case of C<$category> being 288 C<'time'> or C<'dual-slot'>, C<$bucket> may be an arrayref. 289 290 C<$rarity> is the total rarity for this Pokemon with the given method(s). 291 292 Pokemon and an arrayref of the level range at which it appears, in the form 293 C<[$lo, $hi]>. If a tie between methods should arise, the first item will be 294 an arrayref. 295 296 If the Pokemon appears at all three times of day while walking around, C<undef> 297 will be returned as the method name. 296 C<$category> is the method category in which this Pokemon most simply appears. 297 298 The C<buckets> key contains a hashref mapping buckets to rarities. 299 300 The C<rarities> key contains an arrayref of hashrefs, each containing a rarity 301 and a list of buckets with that rarity, in order from most common to rarest. 302 This is convenient for compact display. 298 303 299 304 =cut … … 332 337 333 338 if (%bucket_rarities) { 339 my @grouped_rarities; 340 341 # Show these in order of most likely to least likely, and group any 342 # that have the same rarity 343 for my $rarity (sort { $b <=> $a } uniq values %bucket_rarities) { 344 my @buckets = grep { 345 $bucket_rarities{$_} == $rarity 346 } keys %bucket_rarities; 347 348 # Sort buckets by the order defined in @SimpleMethods 349 my $o = 0; 350 my %order = map { $_ => $o++ } @$buckets; 351 @buckets = sort { $order{$a} <=> $order{$b} } @buckets; 352 353 push @grouped_rarities, { 354 buckets => \@buckets, 355 rarity => $rarity, 356 }; 357 } 358 334 359 return { 335 360 level => [ $all_min, $all_max ], 336 361 category => $category, 337 rarities => \%bucket_rarities, 362 rarities => \@grouped_rarities, 363 buckets => \%bucket_rarities, 338 364 }; 339 }340 }341 342 return;343 344 my %time_rarities;345 for my $time (qw/ morning daytime night /) {346 $time_rarities{$time} = $self->rarity(time => $time);347 }348 349 my $times_ct = grep { $_ } values %time_rarities;350 if ($times_ct == 3) {351 return undef, 100;352 } elsif ($times_ct) {353 my @times = grep { $time_rarities{$_} } keys %time_rarities;354 my $times_ref = @times > 1 ? \@times : $times[0];355 return $times_ref, 100;356 }357 358 my @attempts = (359 [ swarm => 1 ],360 [ radar => 1 ],361 );362 363 for my $att (@attempts) {364 my $rarity = $self->rarity(@$att);365 if ($rarity) {366 return $att->[0], $rarity;367 365 } 368 366 } -
veekun/trunk/lib/Vee/Schema/LocationEncounters.pm
r350 r393 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('location_encounters'); 15 __PACKAGE__->add_columns(qw/ location_id rarity version section pokemon_id method min_level max_level /);16 __PACKAGE__->set_primary_key(qw/ location_id rarity /);15 __PACKAGE__->add_columns(qw/ section_id rarity version pokemon_id method min_level max_level /); 16 __PACKAGE__->set_primary_key(qw/ section_id rarity /); 17 17 18 18 __PACKAGE__->belongs_to(pokemon => 'Vee::Schema::Pokemon', 'pokemon_id'); 19 __PACKAGE__->belongs_to( location => 'Vee::Schema::Locations', 'location_id');19 __PACKAGE__->belongs_to(section => 'Vee::Schema::LocationSections', 'section_id'); 20 20 21 21 =head1 METHODS … … 30 30 sub level { 31 31 my ($self) = @_; 32 32 33 33 my $level; 34 34 my ($min, $max) = ($self->min_level, $self->max_level); -
veekun/trunk/lib/Vee/Schema/Locations.pm
r350 r393 16 16 __PACKAGE__->set_primary_key('id'); 17 17 18 __PACKAGE__->has_many( encounters => 'Vee::Schema::LocationEncounters', 'location_id');18 __PACKAGE__->has_many(sections => 'Vee::Schema::LocationSections', 'location_id'); 19 19 20 20 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/Pokemon.pm
r389 r393 162 162 my @encounter_sets; 163 163 164 my $ sections_rs = $self->encounters_rs( undef, {165 group_by => ' location_id, section',164 my $grouped_sections_rs = $self->encounters_rs( undef, { 165 group_by => 'section_id', 166 166 } ); 167 167 168 while (my $ section = $sections_rs->next) {169 my $encounters_rs = $ section->location->encounters_rs( {168 while (my $enc_section = $grouped_sections_rs->next) { 169 my $encounters_rs = $enc_section->section->encounters_rs( { 170 170 version => 'diamond', 171 section => $section->section,171 section_id => $enc_section->section->id, 172 172 } ); 173 173 -
veekun/trunk/templates/dex/common.tt
r359 r393 118 118 [%- END %] 119 119 120 [%# n.b.: this takes the structure returned from EncSet->simplest_method %] 121 [% MACRO simple_method_cells(simple_method) BLOCK %] 122 <td> [% simple_method.level.0 %][% IF simple_method.level.0 != simple_method.level.1; ' - '; simple_method.level.1; END %] </td> 123 [% category = simple_method.category %] 124 <td> 125 [% FOR hashref IN simple_method.rarities %] 126 [% FOR bucket IN hashref.buckets %] 127 [% SWITCH category %] 128 [% CASE 'time' %]<img src="/dex-images/gameui/[% bucket %].png" alt="[% bucket | ucfirst %]" title="[% bucket | ucfirst %]"/> 129 [% CASE 'swarm' %]<img src="/dex-images/items/teachy-tv.png" alt="Swarm" title="Swarm"/> 130 [% CASE 'water' %]<img src="/dex-images/items/[% bucket == 'surfing' ? 'hm-water' : bucket %].png" alt="[% bucket %]" title="[% bucket %]"/> 131 [% CASE 'pokeradar' %]<img src="/dex-images/items/poke-radar.png" alt="Poké Radar" title="Poké Radar"/> 132 [% CASE 'dualslot' %][% Icons.$bucket %] 133 [% END %] 134 [% ' ' %] 135 [% END %] 136 [% hashref.rarity %]% 137 [% '; ' UNLESS loop.last %] 138 [% END %] 139 </td> 120 140 [% END %] 141 142 [% END %] -
veekun/trunk/templates/dex/page/location.tt
r143 r393 4 4 5 5 <h1>[% this.name %] Pokémon</h1> 6 <p><strong>ATTN:</strong> This page sucks at the moment, doesn't include everything, and does weird things for places where the Diamond and Pearl encounters are different. It should suffice for most uses, but be wary.</p> 7 <p>Radar, swarm, and dual slot percentages assume that it is morning.</p> 8 [% FOR section IN encounters.keys.sort %] 9 [% IF section %] 6 7 <p>Sorry, Pearl players! Only Diamond for the moment.</p> 8 9 [% FOREACH section IN encounters.keys %] 10 10 11 <h2>[% section %]</h2> 11 [% END %] 12 <table class="dex-table dex-locations" cellspacing="0" 12 <table cellspacing="0" cellpadding="3" class="dex-table dex-locations"> 13 13 <tr class="heading"> 14 <th class="name">Pokémon</th> 15 <th class="levels">Lv</th> 16 [% FOR method_pair IN known_methods %] 17 <th>[% method_pair.1 %]</th> 18 [% END %] 14 <th> Pokémon </th> 15 <th> Level </th> 16 <th> Method </th> 19 17 </tr> 20 18 [% color = 1 %] 21 [% last_pokemon = 0 %] 22 [% FOR p IN encounters.$section.keys.nsort %] 23 [% FOR level IN encounters.$section.$p.keys.nsort %] 24 [% IF p != encounters.$section.keys.nsort.0 AND loop.first %] 25 <tr> <td colspan="[% 2 + known_methods.size %]" class="hbar"></td> </tr> 26 [% END %] 19 [% FOREACH enc IN encounters.$section %] 27 20 <tr class="color[% color %]"> 28 <td class="name">[% IF loop.first %]<a href="[% dex_uri('pokemon', PokemonNames.$p) %]">[% PokemonNames.$p %]</a>[% END %]</td> 29 <td class="levels">[% level %]</td> 30 [% FOR method_pair IN known_methods %] 31 <td>[% chance = encounters.$section.$p.$level.${ method_pair.0 }; chance _ '%' IF chance %]</td> 32 [% END %] 21 <td> <a href="[% dex_uri('pokemon', enc.pokemon.name) %]">[% enc.pokemon.name %]</a> </td> 22 [% simple_method_cells(enc.simplest_method.hash) %] 33 23 </tr> 34 [% color = 3 - color %] 35 [% END %] 24 [% color = 3 - color %] 36 25 [% END %] 37 26 </table> 38 27 [% END %] 28 -
veekun/trunk/templates/dex/page/pokemon.tt
r388 r393 276 276 277 277 <h1>Locations</h1> 278 <!--<p><a href="[% dex_uri('pokemon', this.name) %]/map"><img src="/images/see-also.png" alt="See also:"/> Location map</a></p>--> 279 <p>Location map returning eventually...</p> 280 [%# TODO: this is kinda hacky! %] 281 <p>Numbers are levels. Bars are relative rarity. Hover for a percentage.</p> 282 <p>Swarms, the Pokéradar, and dual-slot icons are shown if [% this.name %] shows up during the event but <em>not</em> normally. See the location page for gritty details.</p> 283 284 <table cellspacing="0" cellpadding="3" class="dex-table dex-locations" style="display: inline-table;"> 278 [%# TODO fix ghastly links %] 279 <p><a href="[% dex_uri('pokemon', this.name) %]/map"><img src="/images/see-also.png" alt="See also:"/> Location map</a></p> 280 281 <p>Sorry, Pearl players! Only Diamond for the moment.</p> 282 283 <table cellspacing="0" cellpadding="3" class="dex-table dex-locations"> 285 284 <tr class="heading"> 286 285 <th> Area </th> 287 286 <th> Section </th> 288 287 <th> Level </th> 289 <th> Morn </th> 290 <th> Day </th> 291 <th> Night </th> 288 <th> Method </th> 292 289 </tr> 293 290 [% color = 1 %] 294 291 [% FOREACH enc IN new_encounters %] 295 292 <tr class="color[% color %]"> 296 <td> [% enc.location.name %] </td> 297 <td> [% enc.section %] </td> 298 [% SET simple_method = enc.simplest_method.hash %] 299 <td> [% simple_method.level.0 %][% IF simple_method.level.0 != simple_method.level.1; ' - '; simple_method.level.1; END %] </td> 300 [% category = simple_method.category %] 301 [% SWITCH category %] 302 [% CASE 'time' %] 303 <td> [% simple_method.rarities.morning %]% </td> 304 <td> [% simple_method.rarities.daytime %]% </td> 305 <td> [% simple_method.rarities.night %]% </td> 306 [% CASE 'swarm' %] 307 <td colspan="3"><img src="/dex-images/items/teachy-tv.png" alt="Swarm" title="Swarm"/> [% simple_method.rarities.1 %]%</td> 308 [% CASE 'water' %] 309 <td colspan="3">[% FOR rod IN simple_method.rarities.keys %]<img src="/dex-images/items/[% rod == 'surfing' ? 'hm-water' : rod %].png" alt="[% rod %]" title="[% rod %]"/> [% simple_method.rarities.$rod %]%[% '; ' UNLESS loop.last %][% END %] </td> 310 [% CASE 'pokeradar' %] 311 <td colspan="3"><img src="/dex-images/items/poke-radar.png" alt="Radar" title="Radar"/> [% simple_method.rarities.1 %]%</td> 312 [% CASE 'dualslot' %] 313 <td colspan="3">[% FOR ver IN simple_method.rarities.keys %][% Icons.$ver %] [%+ simple_method.rarities.$ver %]%[% '; ' UNLESS loop.last %][% END %]</td> 314 [% CASE %] 315 <td colspan="3">unknown: [% category %]: [% simple_method.rarities.keys.sort.join %]</td> 316 [% END %] 293 <td> <a href="[% dex_uri('locations', enc.location.name) %]">[% enc.location.name %]</a> </td> 294 <td> [% enc.section.name %] </td> 295 [% simple_method_cells(enc.simplest_method.hash) %] 317 296 </tr> 318 297 [% color = 3 - color %]
