root/veekun/trunk/lib/Vee/Schema/LocationEncounters.pm

Revision 393, 1.2 KB (checked in by eevee, 2 years ago)

Locations mini-commit.
- Redid location pages to match the new format.
- Removed incorrect header text from Pokemon pages.
- Fixed up EncounterSet?->simplest_method to return more display-friendly data (thus merging together buckets with the same rarity), and corrected the old documentation. Also removed old inaccessible code.
- Refactored sections into their own database table.
- Refactored method-cell code into its own macro.

Line 
1package Vee::Schema::LocationEncounters;
2
3use strict;
4use warnings;
5use base 'DBIx::Class';
6
7=head1 NAME
8
9Vee::Schema::LocationEncounters - DBIC class for the C<location_encounters> table
10
11=cut
12
13__PACKAGE__->load_components('Core');
14__PACKAGE__->table('location_encounters');
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
18__PACKAGE__->belongs_to(pokemon => 'Vee::Schema::Pokemon', 'pokemon_id');
19__PACKAGE__->belongs_to(section => 'Vee::Schema::LocationSections', 'section_id');
20
21=head1 METHODS
22
23=head2 level
24
25Returns this encounter's level range formatted in a human-readable way, i.e.
26"A - B", or just "A" if the range is actually just one level.
27
28=cut
29
30sub level {
31    my ($self) = @_;
32
33    my $level;
34    my ($min, $max) = ($self->min_level, $self->max_level);
35
36    if ($min == $max) {
37        $level = $min;
38    } else {
39        $level = $min . ' - ' . $max;
40    }
41
42    return $level;
43}
44
45=head1 SEE ALSO
46
47L<Vee::Schema>, L<DBIx::Class>
48
49=head1 AUTHOR
50
51Maintainer: Alex "Eevee" Munroe (C<veekun@veekun.com>)
52
53See the included F<AUTHORS> file for a full list of contributers.
54
55=head1 LICENSE
56
57See the included F<LICENSE> file.
58
59=cut
60
611;
Note: See TracBrowser for help on using the browser.