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

Revision 406, 2.0 KB (checked in by eevee, 2 years ago)

Database refactoring. Renamed columns and tables to be more consistent and more readable. (#58)

Line 
1package Vee::Schema::Items;
2
3use strict;
4use warnings;
5use base 'DBIx::Class';
6
7=head1 NAME
8
9Vee::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 blurb_dp 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
27Returns this item's name, suitable for display.  This method actually just
28replaces 'Poke' with 'Pok&eacute;', as the database is not currently designed
29for Unicode.
30
31=cut
32
33sub display_name {
34    my ($self) = @_;
35
36    my $name = $self->name;
37    $name =~ s/Poke/Pok&eacute;/;
38    return $name;
39}
40
41=head2 display_name
42
43Returns the filename (sans extension) for this item's sprite.
44
45=cut
46
47sub 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
61Returns the effect this item will cause when Fling is used with it.
62
63=cut
64
65sub 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
79L<Vee::Schema>, L<DBIx::Class>
80
81=head1 AUTHOR
82
83Maintainer: Alex "Eevee" Munroe (C<veekun@veekun.com>)
84
85See the included F<AUTHORS> file for a full list of contributers.
86
87=head1 LICENSE
88
89See the included F<LICENSE> file.
90
91=cut
92
931;
Note: See TracBrowser for help on using the browser.