Show
Ignore:
Timestamp:
12/16/07 22:39:00 (2 years ago)
Author:
eevee
Message:

Added a class to wrap around location/Pokemon pairs, and simplified location data on Pokemon pages. (#228)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee/Schema/Pokemon.pm

    r350 r388  
    44use warnings; 
    55use base 'DBIx::Class'; 
     6 
     7use Vee::Dex::EncounterSet; 
    68 
    79=head1 NAME 
     
    133135} 
    134136 
     137=head2 sane_encounters 
     138 
     139Returns the following data structure representing this Pokemon's wild 
     140encounters: 
     141 
     142    [ 
     143        { 
     144            location => $location_obj, 
     145            section  => $section, 
     146            methods  => { 
     147                grass => [ 
     148                    { 
     149                        levels => [ 5, 7 ], 
     150                        rarity => 100, 
     151                    }, ... 
     152                ], ... 
     153            } 
     154        }, ... 
     155    ] 
     156 
     157=cut 
     158 
     159sub sane_encounters { 
     160    my ($self) = @_; 
     161 
     162    my @encounter_sets; 
     163 
     164    my $sections_rs = $self->encounters_rs( undef, { 
     165        group_by => 'location_id, section', 
     166    } ); 
     167 
     168    while (my $section = $sections_rs->next) { 
     169        my $encounters_rs = $section->location->encounters_rs( { 
     170            version     => 'diamond', 
     171            section     => $section->section, 
     172        } ); 
     173 
     174        push @encounter_sets, Vee::Dex::EncounterSet->new($encounters_rs, $self); 
     175    } 
     176 
     177    return @encounter_sets; 
     178} 
     179 
    135180=head1 SEE ALSO 
    136181