+# encoding: utf8
+
from sqlalchemy import Column, ForeignKey, MetaData, Table
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import backref, relation
has_gen4_fem_sprite = Column(Boolean, nullable=False)
has_gen4_fem_back_sprite = Column(Boolean, nullable=False)
+ ### Stuff to handle alternate Pokémon forms
+
+ @property
+ def national_id(self):
+ """Returns the National Pokédex number for this Pokémon. Use this
+ instead of the id directly; alternate formes may make the id incorrect.
+ """
+
+ if self.forme_base_pokemon_id:
+ return self.forme_base_pokemon_id
+ return self.id
+
+ @property
+ def full_name(self):
+ """Returns the name of this Pokémon, including its Forme, if any."""
+
+ if self.forme_name:
+ return "%s %s" % (self.forme_name.capitalize(), self.name)
+ return self.name
+
class PokemonAbility(TableBase):
__tablename__ = 'pokemon_abilities'
pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
version_id = Column(Integer, ForeignKey('versions.id'), primary_key=True, nullable=False, autoincrement=False)
flavor_text = Column(Unicode(255), nullable=False)
+class PokemonFormGroup(TableBase):
+ __tablename__ = 'pokemon_form_groups'
+ pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
+ description = Column(Unicode(255), nullable=False)
+
+class PokemonFormSprite(TableBase):
+ __tablename__ = 'pokemon_form_sprites'
+ id = Column(Integer, primary_key=True, nullable=False)
+ pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
+ name = Column(Unicode(16), nullable=True)
+
class PokemonName(TableBase):
__tablename__ = 'pokemon_names'
pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
PokemonFlavorText.version = relation(Version)
+PokemonFormGroup.pokemon = relation(Pokemon, backref=backref('form_group',
+ uselist=False))
+PokemonFormSprite.pokemon = relation(Pokemon, backref='form_sprites')
+
PokemonName.language = relation(Language)
PokemonStat.stat = relation(Stat)