"Characteristic" text, here called stat hints.
[zzz-pokedex.git] / pokedex / db / tables.py
index 635b967..adac6f1 100644 (file)
@@ -283,15 +283,6 @@ class EncounterSlot(TableBase):
     rarity = Column(Integer, nullable=False,
         info=dict(description="The chance of the encounter as a percentage"))
 
-class EncounterSlotCondition(TableBase):
-    u"""A condition that affects an encounter slot.
-    """
-    __tablename__ = 'encounter_slot_conditions'
-    encounter_slot_id = Column(Integer, ForeignKey('encounter_slots.id'), primary_key=True, nullable=False, autoincrement=False,
-        info=dict(description="The ID of the encounter slot"))
-    encounter_condition_id = Column(Integer, ForeignKey('encounter_conditions.id'), primary_key=True, nullable=False, autoincrement=False,
-        info=dict(description="The ID of the encounter condition"))
-
 class EvolutionChain(TableBase):
     u"""A family of Pokémon that are linked by evolution
     """
@@ -599,7 +590,7 @@ class MoveEffectChangelog(TableBase):
         info=dict(description="The ID of the effect that changed"))
     changed_in_version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False,
         info=dict(description="The ID of the version group in which the effect changed"))
-    effect = Column(markdown.MarkdownColumn(255), nullable=False,
+    effect = Column(markdown.MarkdownColumn(512), nullable=False,
         info=dict(description="A description of the old behavior", format='markdown'))
 
 class MoveFlag(TableBase):
@@ -637,6 +628,44 @@ class MoveFlavorText(TableBase):
     flavor_text = Column(Unicode(255), nullable=False,
         info=dict(description="The English flavor text", official=True, format='gametext'))
 
+class MoveMeta(TableBase):
+    u"""Metadata for move effects, sorta-kinda ripped straight from the game"""
+    __tablename__ = 'move_meta'
+    move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
+    meta_category_id = Column(Integer, ForeignKey('move_meta_categories.id'), nullable=False)
+    meta_ailment_id = Column(Integer, ForeignKey('move_meta_ailments.id'), nullable=False)
+    min_hits = Column(Integer, nullable=True, index=True)
+    max_hits = Column(Integer, nullable=True, index=True)
+    min_turns = Column(Integer, nullable=True, index=True)
+    max_turns = Column(Integer, nullable=True, index=True)
+    recoil = Column(Integer, nullable=False, index=True)
+    healing = Column(Integer, nullable=False, index=True)
+    crit_rate = Column(Integer, nullable=False, index=True)
+    ailment_chance = Column(Integer, nullable=False, index=True)
+    flinch_chance = Column(Integer, nullable=False, index=True)
+    stat_chance = Column(Integer, nullable=False, index=True)
+
+class MoveMetaAilment(TableBase):
+    u"""Common status ailments moves can inflict on a single Pokémon, including
+    major ailments like paralysis and minor ailments like trapping.
+    """
+    __tablename__ = 'move_meta_ailments'
+    id = Column(Integer, primary_key=True, nullable=False)
+    name = Column(Unicode(24), nullable=False)
+
+class MoveMetaCategory(TableBase):
+    u"""Very general categories that loosely group move effects."""
+    __tablename__ = 'move_meta_categories'
+    id = Column(Integer, primary_key=True, nullable=False)
+    description = Column(Unicode(64), nullable=False)
+
+class MoveMetaStatChange(TableBase):
+    u"""Stat changes moves (may) make."""
+    __tablename__ = 'move_meta_stat_changes'
+    move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
+    stat_id = Column(Integer, ForeignKey('stats.id'), primary_key=True, nullable=False, autoincrement=False)
+    change = Column(Integer, nullable=False, index=True)
+
 class MoveName(TableBase):
     u"""Non-English name of a move
     """
@@ -674,8 +703,8 @@ class Move(TableBase):
         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=False,
-        info=dict(description="Base PP (Power Points) 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,
@@ -993,7 +1022,7 @@ class PokemonEvolution(TableBase):
         info=dict(description=u"The ID of the location the evolution must be triggered at."))
     held_item_id = Column(Integer, ForeignKey('items.id'), nullable=True,
         info=dict(description=u"The ID of the item the Pokémon must hold."))
-    time_of_day = Column(Enum('morning', 'day', 'night', name='pokemon_evolution_time_of_day'), nullable=True,
+    time_of_day = Column(Enum('day', 'night', name='pokemon_evolution_time_of_day'), nullable=True,
         info=dict(description=u"The required time of day."))
     known_move_id = Column(Integer, ForeignKey('moves.id'), nullable=True,
         info=dict(description=u"The ID of the move the Pokémon must know."))
@@ -1229,6 +1258,17 @@ class Stat(TableBase):
     name = Column(Unicode(16), nullable=False,
         info=dict(description=u"The English name of the stat", official=True, format='plaintext'))
 
+class StatHint(TableBase):
+    u"""Flavor text for genes that appears in a Pokémon's summary.  Sometimes
+    called "characteristics".
+    """
+    __tablename__ = 'stat_hints'
+    id = Column(Integer, primary_key=True, nullable=False)
+    stat_id = Column(Integer, ForeignKey('stats.id'), nullable=False)
+    gene_mod_5 = Column(Integer, nullable=False, index=True)
+    text = Column(Unicode(24), nullable=False, index=True, unique=True,
+        info=dict(description=u"The English text displayed", official=True, format='plaintext'))
+
 class SuperContestCombo(TableBase):
     u"""Combo of two moves in a Super Contest.
     """
@@ -1273,8 +1313,8 @@ class Type(TableBase):
         info=dict(description=u"An arbitrary 3-letter abbreviation of this type.", format='plaintext'))  # XXX: Or is it not arbitrary?
     generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False,
         info=dict(description=u"The ID of the generation this type first appeared in."))
-    damage_class_id = Column(Integer, ForeignKey('move_damage_classes.id'), nullable=False,
-        info=dict(description=u"The ID of the damage class this type's moves had before Generation IV."))
+    damage_class_id = Column(Integer, ForeignKey('move_damage_classes.id'), nullable=True,
+        info=dict(description=u"The ID of the damage class this type's moves had before Generation IV, null if not applicable (e.g. ???)."))
 
 class TypeName(TableBase):
     u"""An official non-English name of an elemental type."""
@@ -1327,6 +1367,7 @@ Ability.foreign_names = relation(AbilityName, backref='ability')
 Ability.generation = relation(Generation, backref='abilities')
 Ability.all_pokemon = relation(Pokemon,
     secondary=PokemonAbility.__table__,
+    order_by=Pokemon.order,
     back_populates='all_abilities',
 )
 Ability.pokemon = relation(Pokemon,
@@ -1335,6 +1376,7 @@ Ability.pokemon = relation(Pokemon,
         PokemonAbility.ability_id == Ability.id,
         PokemonAbility.is_dream == False
     ),
+    order_by=Pokemon.order,
     back_populates='abilities',
 )
 Ability.dream_pokemon = relation(Pokemon,
@@ -1343,6 +1385,7 @@ Ability.dream_pokemon = relation(Pokemon,
         PokemonAbility.ability_id == Ability.id,
         PokemonAbility.is_dream == True
     ),
+    order_by=Pokemon.order,
     back_populates='dream_ability',
 )
 
@@ -1379,11 +1422,6 @@ EncounterConditionValueMap.condition_value = relation(EncounterConditionValue,
 EncounterSlot.terrain = relation(EncounterTerrain, backref='slots')
 EncounterSlot.version_group = relation(VersionGroup)
 
-EncounterSlot.condition_map = relation(EncounterSlotCondition, backref='slot')
-EncounterSlot.conditions = association_proxy('condition_map', 'condition')
-EncounterSlotCondition.condition = relation(EncounterCondition,
-                                            backref='slot_map')
-
 EvolutionChain.growth_rate = relation(GrowthRate, backref='evolution_chains')
 EvolutionChain.baby_trigger_item = relation(Item, backref='evolution_chains')
 EvolutionChain.pokemon = relation(Pokemon, order_by=Pokemon.order, back_populates='evolution_chain')
@@ -1442,13 +1480,15 @@ Move.flavor_text = relation(MoveFlavorText, order_by=MoveFlavorText.version_grou
 Move.foreign_names = relation(MoveName, backref='move')
 Move.generation = relation(Generation, backref='moves')
 Move.machines = relation(Machine, backref='move')
+Move.meta = relation(MoveMeta, uselist=False, backref='move')
+Move.meta_stat_changes = relation(MoveMetaStatChange)
 Move.move_effect = relation(MoveEffect, backref='moves')
 Move.move_flags = relation(MoveFlag, backref='move')
 Move.super_contest_effect = relation(SuperContestEffect, backref='moves')
 Move.super_contest_combo_next = association_proxy('super_contest_combo_first', 'second')
 Move.super_contest_combo_prev = association_proxy('super_contest_combo_second', 'first')
 Move.target = relation(MoveTarget, backref='moves')
-Move.type = relation(Type, backref='moves')
+Move.type = relation(Type, back_populates='moves')
 
 Move.effect = markdown.MoveEffectProperty('effect')
 Move.short_effect = markdown.MoveEffectProperty('short_effect')
@@ -1462,12 +1502,23 @@ MoveChangelog.short_effect = markdown.MoveEffectProperty('short_effect')
 
 MoveEffect.category_map = relation(MoveEffectCategoryMap)
 MoveEffect.categories = association_proxy('category_map', 'category')
+MoveEffect.changelog = relation(MoveEffectChangelog,
+    order_by=MoveEffectChangelog.changed_in_version_group_id.desc(),
+    backref='move_effect',
+)
 MoveEffectCategoryMap.category = relation(MoveEffectCategory)
 
+MoveEffectChangelog.changed_in = relation(VersionGroup, backref='move_effect_changelog')
+
 MoveFlag.flag = relation(MoveFlagType)
 
 MoveFlavorText.version_group = relation(VersionGroup)
 
+MoveMeta.category = relation(MoveMetaCategory, backref='move_meta')
+MoveMeta.ailment = relation(MoveMetaAilment, backref='move_meta')
+
+MoveMetaStatChange.stat = relation(Stat, backref='move_meta_stat_changes')
+
 MoveName.language = relation(Language)
 
 Nature.foreign_names = relation(NatureName, backref='nature')
@@ -1622,6 +1673,8 @@ Region.version_groups = association_proxy('version_group_regions', 'version_grou
 
 Stat.damage_class = relation(MoveDamageClass, backref='stats')
 
+StatHint.stat = relation(Stat, backref='hints')
+
 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,
@@ -1642,6 +1695,7 @@ Type.foreign_names = relation(TypeName, backref='type')
 Type.pokemon = relation(Pokemon, secondary=PokemonType.__table__,
                                  order_by=Pokemon.order,
                                  back_populates='types')
+Type.moves = relation(Move, back_populates='type', order_by=Move.name)
 
 TypeName.language = relation(Language)