| 1 | package Vee::Schema::Items; |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | use base 'DBIx::Class'; |
|---|
| 6 | |
|---|
| 7 | =head1 NAME |
|---|
| 8 | |
|---|
| 9 | Vee::Schema::Items - DBIC class for the C<items> table |
|---|
| 10 | |
|---|
| 11 | =cut |
|---|
| 12 | |
|---|
| 13 | __PACKAGE__->load_components('Core'); |
|---|
| 14 | __PACKAGE__->table('items'); |
|---|
| 15 | __PACKAGE__->add_columns(qw/ id game_id berry_id name category cost col5 hp_plus_maybe fling_power fling_effect natural_gift_power natural_gift_type col12 col13 col14 col15 col16 col17 col18 col19 col20 col21 col22 col23 effort_hp effort_at effort_de effort_sp effort_sa effort_sd hp_restored pp_restored happiness1 happiness2 happiness3 is_underground dpblurb description /); |
|---|
| 16 | __PACKAGE__->set_primary_key('id'); |
|---|
| 17 | |
|---|
| 18 | __PACKAGE__->has_many(pokemon_items => 'Vee::Schema::PokemonItems', 'item_id', { join_type => 'left' }); |
|---|
| 19 | __PACKAGE__->many_to_many(pokemon => 'pokemon_items', 'pokemon'); |
|---|
| 20 | |
|---|
| 21 | __PACKAGE__->might_have(berry => 'Vee::Schema::Berries', { 'foreign.id' => 'self.berry_id' }); |
|---|
| 22 | |
|---|
| 23 | =head1 METHODS |
|---|
| 24 | |
|---|
| 25 | =head2 display_name |
|---|
| 26 | |
|---|
| 27 | Returns this item's name, suitable for display. This method actually just |
|---|
| 28 | replaces 'Poke' with 'Poké', as the database is not currently designed |
|---|
| 29 | for Unicode. |
|---|
| 30 | |
|---|
| 31 | =cut |
|---|
| 32 | |
|---|
| 33 | sub display_name { |
|---|
| 34 | my ($self) = @_; |
|---|
| 35 | |
|---|
| 36 | my $name = $self->name; |
|---|
| 37 | $name =~ s/Poke/Poké/; |
|---|
| 38 | return $name; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | =head2 display_name |
|---|
| 42 | |
|---|
| 43 | Returns the filename (sans extension) for this item's sprite. |
|---|
| 44 | |
|---|
| 45 | =cut |
|---|
| 46 | |
|---|
| 47 | sub sprite_name { |
|---|
| 48 | my ($self) = @_; |
|---|
| 49 | |
|---|
| 50 | my $name = lc $self->name; |
|---|
| 51 | # TMs! |
|---|
| 52 | |
|---|
| 53 | $name =~ tr/ /-/; |
|---|
| 54 | $name =~ tr/-a-z0-9//cd; |
|---|
| 55 | |
|---|
| 56 | return $name; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | =head2 fling_description |
|---|
| 60 | |
|---|
| 61 | Returns the effect this item will cause when Fling is used with it. |
|---|
| 62 | |
|---|
| 63 | =cut |
|---|
| 64 | |
|---|
| 65 | sub fling_description { |
|---|
| 66 | my ($self) = @_; |
|---|
| 67 | |
|---|
| 68 | return 'n/a' if not $self->fling_power; |
|---|
| 69 | |
|---|
| 70 | my $desc = 'Inflicts regular damage with ' . $self->fling_power . ' power.'; |
|---|
| 71 | $desc .= ' ' . $self->fling_effect |
|---|
| 72 | if $self->fling_effect; |
|---|
| 73 | |
|---|
| 74 | return $desc; |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | =head1 SEE ALSO |
|---|
| 78 | |
|---|
| 79 | L<Vee::Schema>, L<DBIx::Class> |
|---|
| 80 | |
|---|
| 81 | =head1 AUTHOR |
|---|
| 82 | |
|---|
| 83 | Maintainer: Alex "Eevee" Munroe (C<veekun@veekun.com>) |
|---|
| 84 | |
|---|
| 85 | See the included F<AUTHORS> file for a full list of contributers. |
|---|
| 86 | |
|---|
| 87 | =head1 LICENSE |
|---|
| 88 | |
|---|
| 89 | See the included F<LICENSE> file. |
|---|
| 90 | |
|---|
| 91 | =cut |
|---|
| 92 | |
|---|
| 93 | 1; |
|---|