+create_translation_table('growth_rate_prose', GrowthRate, 'prose',
+ name = Column(Unicode(20), nullable=False, index=True,
+ info=dict(description="The name", format='plaintext', official=False)),
+)
+
+class Item(TableBase):
+ u"""An Item from the games, like "Poké Ball" or "Bicycle".
+ """
+ __tablename__ = 'items'
+ __singlename__ = 'item'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="A numeric ID"))
+ identifier = Column(Unicode(20), nullable=False,
+ info=dict(description="An identifier", format='identifier'))
+ category_id = Column(Integer, ForeignKey('item_categories.id'), nullable=False,
+ info=dict(description="ID of a category this item belongs to"))
+ cost = Column(Integer, nullable=False,
+ info=dict(description=u"Cost of the item when bought. Items sell for half this price."))
+ fling_power = Column(Integer, nullable=True,
+ info=dict(description=u"Power of the move Fling when used with this item."))
+ fling_effect_id = Column(Integer, ForeignKey('item_fling_effects.id'), nullable=True,
+ info=dict(description=u"ID of the fling-effect of the move Fling when used with this item. Note that these are different from move effects."))
+
+ @property
+ def appears_underground(self):
+ u"""True if the item appears underground, as specified by the appropriate flag
+ """
+ return any(flag.identifier == u'underground' for flag in self.flags)
+
+create_translation_table('item_names', Item, 'names',
+ relation_lazy='joined',
+ name = Column(Unicode(20), nullable=False, index=True,
+ info=dict(description="The name", format='plaintext', official=True, ripped=True)),
+)
+create_translation_table('item_prose', Item, 'prose',
+ short_effect = Column(Unicode(256), nullable=False,
+ info=dict(description="A short summary of the effect", format='plaintext')),
+ effect = Column(markdown.MarkdownColumn(5120), nullable=False,
+ info=dict(description=u"Detailed description of the item's effect.", format='markdown')),
+)
+create_translation_table('item_flavor_summaries', Item, 'flavor_summaries',
+ flavor_summary = Column(Unicode(512), nullable=True,
+ info=dict(description=u"Text containing facts from all flavor texts, for languages without official game translations", official=False, format='plaintext', ripped=True)),
+)
+
+class ItemCategory(TableBase):
+ u"""An item category
+ """
+ # XXX: This is fanon, right?
+ __tablename__ = 'item_categories'
+ __singlename__ = 'item_category'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="A numeric ID"))
+ pocket_id = Column(Integer, ForeignKey('item_pockets.id'), nullable=False,
+ info=dict(description="ID of the pocket these items go to"))
+ identifier = Column(Unicode(16), nullable=False,
+ info=dict(description="An identifier", format='identifier'))
+
+create_translation_table('item_category_prose', ItemCategory, 'prose',
+ relation_lazy='joined',
+ name = Column(Unicode(16), nullable=False, index=True,
+ info=dict(description="The name", format='plaintext', official=False)),
+)
+
+class ItemFlag(TableBase):
+ u"""An item attribute such as "consumable" or "holdable".
+ """
+ __tablename__ = 'item_flags'
+ __singlename__ = 'item_flag'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="A numeric ID"))
+ identifier = Column(Unicode(24), nullable=False,
+ info=dict(description="Identifier of the flag", format='identifier'))
+
+create_translation_table('item_flag_prose', ItemFlag, 'prose',
+ name = Column(Unicode(24), nullable=False, index=True,
+ info=dict(description="The name", format='plaintext', official=False)),
+ description = Column(Unicode(64), nullable=False,
+ info=dict(description="Short description of the flag", format='plaintext')),
+)
+
+class ItemFlagMap(TableBase):
+ u"""Maps an item flag to its item.
+ """
+ __tablename__ = 'item_flag_map'
+ item_id = Column(Integer, ForeignKey('items.id'), primary_key=True, autoincrement=False, nullable=False,
+ info=dict(description="The ID of the item"))
+ item_flag_id = Column(Integer, ForeignKey('item_flags.id'), primary_key=True, autoincrement=False, nullable=False,
+ info=dict(description="The ID of the item flag"))
+
+class ItemFlavorText(TableBase):
+ u"""An in-game description of an item
+ """
+ __tablename__ = 'item_flavor_text'
+ __singlename__ = 'item_flavor_text'
+ summary_column = Item.flavor_summaries_table, 'flavor_summary'
+ item_id = Column(Integer, ForeignKey('items.id'), primary_key=True, autoincrement=False, nullable=False,
+ info=dict(description="The ID of the item"))
+ version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, autoincrement=False, nullable=False,
+ info=dict(description="ID of the version group that sports this text"))
+ language_id = Column(Integer, ForeignKey('languages.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="The language"))
+ flavor_text = Column(Unicode(255), nullable=False,
+ info=dict(description="The flavor text itself", official=True, format='gametext'))
+
+class ItemFlingEffect(TableBase):
+ u"""An effect of the move Fling when used with a specific item
+ """
+ __tablename__ = 'item_fling_effects'
+ __singlename__ = 'item_fling_effect'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="A numeric ID"))
+
+create_translation_table('item_fling_effect_prose', ItemFlingEffect, 'prose',
+ effect = Column(Unicode(255), nullable=False,
+ info=dict(description="Description of the effect", format='plaintext')),
+)
+
+class ItemGameIndex(TableBase):
+ u"""The internal ID number a game uses for an item
+ """
+ __tablename__ = 'item_game_indices'
+ item_id = Column(Integer, ForeignKey('items.id'), primary_key=True, autoincrement=False, nullable=False,
+ info=dict(description="The database ID of the item"))
+ generation_id = Column(Integer, ForeignKey('generations.id'), primary_key=True, autoincrement=False, nullable=False,
+ info=dict(description="ID of the generation of games"))
+ game_index = Column(Integer, nullable=False,
+ info=dict(description="Internal ID of the item in the generation"))
+
+class ItemPocket(TableBase):
+ u"""A pocket that categorizes items
+ """
+ __tablename__ = 'item_pockets'
+ __singlename__ = 'item_pocket'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="A numeric ID"))
+ identifier = Column(Unicode(16), nullable=False,
+ info=dict(description="An identifier of this pocket", format='identifier'))
+
+create_translation_table('item_pocket_names', ItemPocket, 'names',
+ relation_lazy='joined',
+ name = Column(Unicode(16), nullable=False, index=True,
+ info=dict(description="The name", format='plaintext', official=True)),
+)
+
+class Location(TableBase):
+ u"""A place in the Pokémon world
+ """
+ __tablename__ = 'locations'
+ __singlename__ = 'location'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="A numeric ID"))
+ region_id = Column(Integer, ForeignKey('regions.id'),
+ info=dict(description="ID of the region this location is in"))
+ identifier = Column(Unicode(64), nullable=False,
+ info=dict(description="An identifier", format='identifier'))
+
+create_translation_table('location_names', Location, 'names',
+ relation_lazy='joined',
+ name = Column(Unicode(64), nullable=False, index=True,
+ info=dict(description="The name", format='plaintext', official=True)),
+)
+
+class LocationArea(TableBase):
+ u"""A sub-area of a location
+ """
+ __tablename__ = 'location_areas'
+ __singlename__ = 'location_area'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="A numeric ID"))
+ location_id = Column(Integer, ForeignKey('locations.id'), nullable=False,
+ info=dict(description="ID of the location this area is part of"))
+ game_index = Column(Integer, nullable=False,
+ info=dict(description="ID the games ude for this area"))
+ identifier = Column(Unicode(64), nullable=True,
+ info=dict(description="An identifier", format='identifier'))
+
+create_translation_table('location_area_prose', LocationArea, 'prose',
+ relation_lazy='joined',
+ name = Column(Unicode(64), nullable=False, index=True,
+ info=dict(description="The name", format='plaintext', official=False)),
+)
+
+class LocationAreaEncounterRate(TableBase):
+ # XXX: What's this exactly? Someone add the docstring & revise the descriptions
+ __tablename__ = 'location_area_encounter_rates'
+ location_area_id = Column(Integer, ForeignKey('location_areas.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="ID of the area"))
+ encounter_terrain_id = Column(Integer, ForeignKey('encounter_terrain.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="ID of the terrain"))
+ version_id = Column(Integer, ForeignKey('versions.id'), primary_key=True, autoincrement=False,
+ info=dict(description="ID of the version"))
+ rate = Column(Integer, nullable=True,
+ info=dict(description="The encounter rate")) # units?
+
+class LocationGameIndex(TableBase):
+ u"""IDs the games use internally for locations
+ """
+ __tablename__ = 'location_game_indices'
+ location_id = Column(Integer, ForeignKey('locations.id'), nullable=False, primary_key=True, autoincrement=False,
+ info=dict(description="Database ID of the locaion"))
+ generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False, primary_key=True, autoincrement=False,
+ info=dict(description="ID of the generation this entry to"))
+ game_index = Column(Integer, nullable=False,
+ info=dict(description="Internal game ID of the location"))
+
+class Machine(TableBase):
+ u"""A TM or HM; numbered item that can teach a move to a Pokémon
+ """
+ __tablename__ = 'machines'
+ machine_number = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="Number of the machine for TMs, or 100 + the munber for HMs"))
+ version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="Versions this entry applies to"))
+ item_id = Column(Integer, ForeignKey('items.id'), nullable=False,
+ info=dict(description="ID of the corresponding Item"))
+ move_id = Column(Integer, ForeignKey('moves.id'), nullable=False,
+ info=dict(description="ID of the taught move"))
+
+ @property
+ def is_hm(self):
+ u"""True if this machine is a HM, False if it's a TM
+ """
+ return self.machine_number >= 100
+
+class Move(TableBase):
+ u"""A Move: technique or attack a Pokémon can learn to use
+ """
+ __tablename__ = 'moves'
+ __singlename__ = 'move'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="A numeric ID"))
+ identifier = Column(Unicode(24), nullable=False,
+ info=dict(description="An identifier", format='identifier'))
+ generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False,
+ info=dict(description="ID of the generation this move first appeared in"))
+ type_id = Column(Integer, ForeignKey('types.id'), nullable=False,
+ info=dict(description="ID of the move's elemental type"))
+ power = Column(SmallInteger, nullable=False,
+ info=dict(description="Base power of the move"))
+ pp = Column(SmallInteger, nullable=True,
+ info=dict(description="Base PP (Power Points) of the move, nullable if not applicable (e.g. Struggle and Shadow moves)."))
+ accuracy = Column(SmallInteger, nullable=True,
+ info=dict(description="Accuracy of the move; NULL means it never misses"))
+ priority = Column(SmallInteger, nullable=False,
+ info=dict(description="The move's priority bracket"))
+ target_id = Column(Integer, ForeignKey('move_targets.id'), nullable=False,
+ info=dict(description="ID of the target (range) of the move"))
+ damage_class_id = Column(Integer, ForeignKey('move_damage_classes.id'), nullable=False,
+ info=dict(description="ID of the damage class (physical/special) of the move"))
+ effect_id = Column(Integer, ForeignKey('move_effects.id'), nullable=False,
+ info=dict(description="ID of the move's effect"))
+ effect_chance = Column(Integer, nullable=True,
+ info=dict(description="The chance for a secondary effect. What this is a chance of is specified by the move's effect."))
+ contest_type_id = Column(Integer, ForeignKey('contest_types.id'), nullable=True,
+ info=dict(description="ID of the move's Contest type (e.g. cool or smart)"))
+ contest_effect_id = Column(Integer, ForeignKey('contest_effects.id'), nullable=True,
+ info=dict(description="ID of the move's Contest effect"))
+ super_contest_effect_id = Column(Integer, ForeignKey('super_contest_effects.id'), nullable=True,
+ info=dict(description="ID of the move's Super Contest effect"))
+
+create_translation_table('move_names', Move, 'names',
+ relation_lazy='joined',
+ name = Column(Unicode(24), nullable=False, index=True,
+ info=dict(description="The name", format='plaintext', official=True, ripped=True))
+)
+create_translation_table('move_flavor_summaries', Move, 'flavor_summaries',
+ flavor_summary = Column(Unicode(512), nullable=True,
+ info=dict(description=u"Text containing facts from all flavor texts, for languages without official game translations", official=False, format='plaintext', ripped=True)),
+)
+
+class MoveBattleStyle(TableBase):
+ u"""A battle style of a move""" # XXX: Explain better
+ __tablename__ = 'move_battle_styles'
+ __singlename__ = 'move_battle_style'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="A numeric ID"))
+ identifier = Column(Unicode(8), nullable=False,
+ info=dict(description="An identifier", format='identifier'))
+
+create_translation_table('move_battle_style_prose', MoveBattleStyle, 'prose',
+ relation_lazy='joined',
+ name = Column(Unicode(8), nullable=False, index=True,
+ info=dict(description="The name", format='plaintext', official=False)),
+)
+
+class MoveChangelog(TableBase):
+ """History of changes to moves across main game versions."""
+ __tablename__ = 'move_changelog'
+ __singlename__ = 'move_changelog'
+ move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="ID of the move that changed"))
+ changed_in_version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="ID of the version group in which the move changed"))
+ type_id = Column(Integer, ForeignKey('types.id'), nullable=True,
+ info=dict(description="Prior type of the move, or NULL if unchanged"))
+ power = Column(SmallInteger, nullable=True,
+ info=dict(description="Prior base power of the move, or NULL if unchanged"))
+ pp = Column(SmallInteger, nullable=True,
+ info=dict(description="Prior base PP of the move, or NULL if unchanged"))
+ accuracy = Column(SmallInteger, nullable=True,
+ info=dict(description="Prior accuracy of the move, or NULL if unchanged"))
+ effect_id = Column(Integer, ForeignKey('move_effects.id'), nullable=True,
+ info=dict(description="Prior ID of the effect, or NULL if unchanged"))
+ effect_chance = Column(Integer, nullable=True,
+ info=dict(description="Prior effect chance, or NULL if unchanged"))
+
+class MoveDamageClass(TableBase):
+ u"""Any of the damage classes moves can have, i.e. physical, special, or non-damaging.
+ """
+ __tablename__ = 'move_damage_classes'
+ __singlename__ = 'move_damage_class'
+ id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
+ info=dict(description="A numeric ID"))
+ identifier = Column(Unicode(16), nullable=False,
+ info=dict(description="An identifier", format='identifier'))
+
+create_translation_table('move_damage_class_prose', MoveDamageClass, 'prose',
+ relation_lazy='joined',
+ name = Column(Unicode(16), nullable=False, index=True,
+ info=dict(description="The name", format='plaintext', official=False)),
+ description = Column(Unicode(64), nullable=False,
+ info=dict(description="A description of the class", format='plaintext')),
+)