id = Column(Integer, primary_key=True, nullable=False)
encounter_condition_id = Column(Integer, ForeignKey('encounter_conditions.id'), primary_key=False, nullable=False, autoincrement=False)
name = Column(Unicode(64), nullable=False)
+ is_default = Column(Boolean, nullable=False)
class EncounterConditionValueMap(TableBase):
"""Maps encounters to the specific conditions under which they occur."""
__tablename__ = 'encounter_slots'
id = Column(Integer, primary_key=True, nullable=False)
+ version_group_id = Column(Integer, ForeignKey('version_groups.id'), nullable=False, autoincrement=False)
encounter_terrain_id = Column(Integer, ForeignKey('encounter_terrain.id'), primary_key=False, nullable=False, autoincrement=False)
rarity = Column(Integer, nullable=False, autoincrement=False)
class Generation(TableBase):
__tablename__ = 'generations'
id = Column(Integer, primary_key=True, nullable=False)
+ main_region_id = Column(Integer, ForeignKey('regions.id'))
name = Column(Unicode(16), nullable=False)
- main_region = Column(Unicode(16), nullable=False)
class GrowthRate(TableBase):
"""`formula` is written in LaTeX math notation."""
__tablename__ = 'locations'
__singlename__ = 'location'
id = Column(Integer, primary_key=True, nullable=False)
- generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False)
+ region_id = Column(Integer, ForeignKey('regions.id'))
name = Column(Unicode(64), nullable=False)
class LocationArea(TableBase):
type_id = Column(Integer, ForeignKey('types.id'), nullable=False)
slot = Column(Integer, primary_key=True, nullable=False, autoincrement=False)
+class Region(TableBase):
+ """Major areas of the world: Kanto, Johto, etc."""
+ __tablename__ = 'regions'
+ id = Column(Integer, primary_key=True, nullable=False)
+ name = Column(Unicode(16), nullable=False)
+
class Stat(TableBase):
__tablename__ = 'stats'
id = Column(Integer, primary_key=True, nullable=False)
id = Column(Integer, primary_key=True, nullable=False)
name = Column(Unicode(8), nullable=False)
abbreviation = Column(Unicode(3), nullable=False)
+ generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False)
+ damage_class_id = Column(Integer, ForeignKey('move_damage_classes.id'), nullable=False) ## ??? is none; everything else is physical or special
class VersionGroup(TableBase):
__tablename__ = 'version_groups'
id = Column(Integer, primary_key=True, nullable=False)
generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False)
+class VersionGroupRegion(TableBase):
+ __tablename__ = 'version_group_regions'
+ version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False)
+ region_id = Column(Integer, ForeignKey('regions.id'), primary_key=True, nullable=False)
+
class Version(TableBase):
__tablename__ = 'versions'
id = Column(Integer, primary_key=True, nullable=False)
EvolutionChain.growth_rate = relation(GrowthRate, backref='evolution_chains')
Generation.versions = relation(Version, secondary=VersionGroup.__table__)
+Generation.main_region = relation(Region)
+
+Location.region = relation(Region, backref='locations')
LocationArea.location = relation(Location, backref='areas')
PokemonStat.stat = relation(Stat)
+# This is technically a has-many; Generation.main_region_id -> Region.id
+Region.generation = relation(Generation, uselist=False)
+Region.version_group_regions = relation(VersionGroupRegion, backref='region',
+ order_by='VersionGroupRegion.version_group_id')
+Region.version_groups = association_proxy('version_group_regions', 'version_group')
+
SuperContestCombo.first = relation(Move, primaryjoin=SuperContestCombo.first_move_id==Move.id,
backref='super_contest_combo_first')
SuperContestCombo.second = relation(Move, primaryjoin=SuperContestCombo.second_move_id==Move.id,
==TypeEfficacy.target_type_id,
backref='target_type')
+Type.generation = relation(Generation, backref='types')
+Type.damage_class = relation(MoveDamageClass, backref='types')
+
Version.version_group = relation(VersionGroup, backref='versions')
Version.generation = association_proxy('version_group', 'generation')
VersionGroup.generation = relation(Generation, backref='version_groups')
+VersionGroup.version_group_regions = relation(VersionGroupRegion, backref='version_group')
+VersionGroup.regions = association_proxy('version_group_regions', 'region')