+class PokemonForm(TableBase):
+ u"""An individual form of a Pokémon.
+
+ Pokémon that do not have separate forms are still given a single row to
+ represent their single form.
+ """
+ __tablename__ = 'pokemon_forms'
+ __singlename__ = 'pokemon_form'
+ id = Column(Integer, primary_key=True, nullable=False,
+ info=dict(description=u'A unique ID for this form.'))
+ identifier = Column(Unicode(16), nullable=True,
+ info=dict(description=u"An identifier", format='identifier'))
+ form_base_pokemon_id = Column(Integer, ForeignKey('pokemon.id'), nullable=False, autoincrement=False,
+ info=dict(description=u'The ID of the base Pokémon for this form.'))
+ unique_pokemon_id = Column(Integer, ForeignKey('pokemon.id'), autoincrement=False,
+ info=dict(description=u'The ID of a Pokémon that represents specifically this form, for Pokémon with functionally-different forms like Wormadam.'))
+ introduced_in_version_group_id = Column(Integer, ForeignKey('version_groups.id'), autoincrement=False,
+ info=dict(description=u'The ID of the version group in which this form first appeared.'))
+ is_default = Column(Boolean, nullable=False,
+ info=dict(description=u'Set for exactly one form used as the default for each species.'))
+ order = Column(Integer, nullable=False, autoincrement=False,
+ info=dict(description=u'The order in which forms should be sorted. Multiple forms may have equal order, in which case they should fall back on sorting by name.'))
+ name = TextColumn(Unicode(16), nullable=False, index=True, plural='names',
+ info=dict(description="The name", format='plaintext', official=True))
+
+ @property
+ def pokemon(self):
+ u"""Returns the Pokémon for this form, using the form base as fallback.
+ """
+
+ return self.unique_pokemon or self.form_base_pokemon
+
+ @property
+ def full_name(self):
+ u"""Returns the full name of this form, e.g. "Plant Cloak"."""
+
+ if not self.name:
+ return None
+ elif self.form_group and self.form_group.term:
+ return u'{0} {1}'.format(self.name, self.form_group.term)
+ else:
+ return self.name
+
+ @property
+ def pokemon_name(self):
+ u"""Returns the name of this Pokémon with this form, e.g. "Plant
+ Burmy".
+ """
+
+ if self.name:
+ return u'{0} {1}'.format(self.name, self.form_base_pokemon.name)
+ else:
+ return self.form_base_pokemon.name
+
+class PokemonFormGroup(TableBase):
+ u"""Information about a Pokémon's forms as a group."""
+ __tablename__ = 'pokemon_form_groups'
+ __singlename__ = 'pokemon_form_group'
+ pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description=u"ID of the base form Pokémon"))
+ term = ProseColumn(Unicode(16), plural='terms', nullable=True,
+ info=dict(description=u"The term for this Pokémon's forms, e.g. \"Cloak\" for Burmy or \"Forme\" for Deoxys.", official=True, format='plaintext'))
+ is_battle_only = Column(Boolean, nullable=False,
+ info=dict(description=u"Set iff the forms only change in battle"))
+ description = ProseColumn(markdown.MarkdownColumn(1024), plural='descriptions', nullable=False,
+ info=dict(description=u"Description of how the forms work", format='markdown'))
+PokemonFormGroup.id = PokemonFormGroup.pokemon_id
+
+class PokemonFormPokeathlonStat(TableBase):
+ u"""A Pokémon form's performance in one Pokéathlon stat."""
+ __tablename__ = 'pokemon_form_pokeathlon_stats'
+ pokemon_form_id = Column(Integer, ForeignKey('pokemon_forms.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description=u'The ID of the Pokémon form.'))
+ pokeathlon_stat_id = Column(Integer, ForeignKey('pokeathlon_stats.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description=u'The ID of the Pokéathlon stat.'))
+ minimum_stat = Column(Integer, nullable=False, autoincrement=False,
+ info=dict(description=u'The minimum value for this stat for this Pokémon form.'))
+ base_stat = Column(Integer, nullable=False, autoincrement=False,
+ info=dict(description=u'The default value for this stat for this Pokémon form.'))
+ maximum_stat = Column(Integer, nullable=False, autoincrement=False,
+ info=dict(description=u'The maximum value for this stat for this Pokémon form.'))
+
+class PokemonHabitat(TableBase):
+ u"""The habitat of a Pokémon, as given in the FireRed/LeafGreen version Pokédex
+ """
+ __tablename__ = 'pokemon_habitats'
+ __singlename__ = 'pokemon_habitat'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description=u"A numeric ID"))
+ identifier = Column(Unicode(16), nullable=False,
+ info=dict(description=u"An identifier", format='identifier'))
+ name = TextColumn(Unicode(16), nullable=False, index=True, plural='names',
+ info=dict(description="The name", format='plaintext', official=True))
+
+class PokemonInternalID(TableBase):
+ u"""The number of a Pokémon a game uses internally
+ """
+ __tablename__ = 'pokemon_internal_ids'
+ pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, autoincrement=False, nullable=False,
+ info=dict(description=u"Database ID of the Pokémon"))
+ generation_id = Column(Integer, ForeignKey('generations.id'), primary_key=True, autoincrement=False, nullable=False,
+ info=dict(description=u"Database ID of the generation"))
+ internal_id = Column(Integer, nullable=False,
+ info=dict(description=u"Internal ID the generation's games use for the Pokémon"))
+
+class PokemonItem(TableBase):
+ u"""Record of an item a Pokémon can hold in the wild
+ """
+ __tablename__ = 'pokemon_items'
+ pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description=u"ID of the Pokémon"))
+ version_id = Column(Integer, ForeignKey('versions.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description=u"ID of the version this applies to"))
+ item_id = Column(Integer, ForeignKey('items.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description=u"ID of the item"))
+ rarity = Column(Integer, nullable=False,
+ info=dict(description=u"Chance of the Pokémon holding the item, in percent"))
+
+class PokemonMove(TableBase):
+ u"""Record of a move a Pokémon can learn
+ """
+ __tablename__ = 'pokemon_moves'
+ pokemon_id = Column(Integer, ForeignKey('pokemon.id'), nullable=False, index=True,
+ info=dict(description=u"ID of the Pokémon"))
+ version_group_id = Column(Integer, ForeignKey('version_groups.id'), nullable=False, index=True,
+ info=dict(description=u"ID of the version group this applies to"))
+ move_id = Column(Integer, ForeignKey('moves.id'), nullable=False, index=True,
+ info=dict(description=u"ID of the move"))
+ pokemon_move_method_id = Column(Integer, ForeignKey('pokemon_move_methods.id'), nullable=False, index=True,
+ info=dict(description=u"ID of the method this move is learned by"))
+ level = Column(Integer, nullable=True, index=True,
+ info=dict(description=u"Level the move is learned at, if applicable"))
+ order = Column(Integer, nullable=True,
+ info=dict(description=u"A sort key to produce the correct ordering when all else is equal")) # XXX: This needs a better description
+
+ __table_args__ = (
+ PrimaryKeyConstraint('pokemon_id', 'version_group_id', 'move_id', 'pokemon_move_method_id', 'level'),
+ {},
+ )
+
+class PokemonMoveMethod(TableBase):
+ u"""A method a move can be learned by, such as "Level up" or "Tutor".
+ """
+ __tablename__ = 'pokemon_move_methods'
+ __singlename__ = 'pokemon_move_method'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description=u"A numeric ID"))
+ identifier = Column(Unicode(64), nullable=False,
+ info=dict(description=u"An identifier", format='identifier'))
+ description = ProseColumn(Unicode(255), plural='descriptions', nullable=False,
+ info=dict(description=u"A detailed description of how the method works", format='plaintext'))
+ name = ProseColumn(Unicode(64), nullable=False, index=True, plural='names',
+ info=dict(description="The name", format='plaintext', official=False))
+
+class PokemonShape(TableBase):
+ u"""The shape of a Pokémon's body, as used in generation IV Pokédexes.
+ """
+ __tablename__ = 'pokemon_shapes'
+ __singlename__ = 'pokemon_shape'
+ id = Column(Integer, primary_key=True, nullable=False,
+ info=dict(description=u"A numeric ID"))
+ identifier = Column(Unicode(24), nullable=False,
+ info=dict(description=u"An identifier", format='identifier'))
+ awesome_name = ProseColumn(Unicode(16), plural='awesome_names', nullable=False,
+ info=dict(description=u"A splendiferous name of the body shape", format='plaintext'))
+ name = ProseColumn(Unicode(24), nullable=False, index=True, plural='names',
+ info=dict(description="The name", format='plaintext', official=False))