Marked sprite forms with what version group introduced them.
[zzz-pokedex.git] / pokedex / db / tables.py
index eb521e1..3e8f988 100644 (file)
@@ -25,7 +25,7 @@ class ContestEffect(TableBase):
     id = Column(Integer, primary_key=True, nullable=False)
     appeal = Column(SmallInteger, nullable=False)
     jam = Column(SmallInteger, nullable=False)
-    flavor = Column(Unicode(255), nullable=False)
+    flavor_text = Column(Unicode(64), nullable=False)
     effect = Column(Unicode(255), nullable=False)
 
 class EggGroup(TableBase):
@@ -198,6 +198,12 @@ class MoveFlagType(TableBase):
     name = Column(Unicode(32), nullable=False)
     description = Column(rst.RstTextColumn(128), nullable=False)
 
+class MoveFlavorText(TableBase):
+    __tablename__ = 'move_flavor_text'
+    move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
+    generation_id = Column(Integer, ForeignKey('generations.id'), primary_key=True, nullable=False, autoincrement=False)
+    flavor_text = Column(Unicode(255), nullable=False)
+
 class MoveName(TableBase):
     __tablename__ = 'move_names'
     move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
@@ -226,7 +232,7 @@ class Move(TableBase):
     effect_chance = Column(Integer)
     contest_type = Column(Unicode(8), nullable=False)
     contest_effect_id = Column(Integer, ForeignKey('contest_effects.id'), nullable=True)
-    super_contest_effect_id = Column(Integer, nullable=False)
+    super_contest_effect_id = Column(Integer, ForeignKey('super_contest_effects.id'), nullable=False)
 
 class Pokemon(TableBase):
     """The core to this whole mess.
@@ -326,6 +332,7 @@ 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)
+    introduced_in_version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False, autoincrement=False)
     name = Column(Unicode(16), nullable=True)
 
 class PokemonItem(TableBase):
@@ -380,6 +387,12 @@ class Stat(TableBase):
     id = Column(Integer, primary_key=True, nullable=False)
     name = Column(Unicode(16), nullable=False)
 
+class SuperContestEffect(TableBase):
+    __tablename__ = 'super_contest_effects'
+    id = Column(Integer, primary_key=True, nullable=False)
+    appeal = Column(SmallInteger, nullable=False)
+    flavor_text = Column(Unicode(64), nullable=False)
+
 class TypeEfficacy(TableBase):
     __tablename__ = 'type_efficacy'
     damage_type_id = Column(Integer, ForeignKey('types.id'), primary_key=True, nullable=False, autoincrement=False)
@@ -425,13 +438,16 @@ LocationArea.location = relation(Location, backref='areas')
 
 Machine.generation = relation(Generation)
 
+Move.contest_effect = relation(ContestEffect, backref='moves')
 Move.damage_class = relation(MoveDamageClass, backref='moves')
 Move.flags = association_proxy('move_flags', 'flag')
+Move.flavor_text = relation(MoveFlavorText, order_by=MoveFlavorText.generation_id, backref='move')
 Move.foreign_names = relation(MoveName, backref='pokemon')
 Move.generation = relation(Generation, backref='moves')
 Move.machines = relation(Machine, backref='move')
 Move.move_effect = relation(MoveEffect, backref='moves')
 Move.move_flags = relation(MoveFlag, backref='move')
+Move.super_contest_effect = relation(SuperContestEffect, backref='moves')
 Move.target = relation(MoveTarget, backref='moves')
 Move.type = relation(Type, backref='moves')
 
@@ -441,6 +457,8 @@ Move.short_effect = rst.MoveEffectProperty('short_effect')
 
 MoveFlag.flag = relation(MoveFlagType)
 
+MoveFlavorText.generation = relation(Generation)
+
 MoveName.language = relation(Language)
 
 Pokemon.abilities = relation(Ability, secondary=PokemonAbility.__table__,
@@ -458,7 +476,7 @@ Pokemon.evolution_method = relation(EvolutionMethod)
 Pokemon.evolution_children = relation(Pokemon, primaryjoin=Pokemon.id==Pokemon.evolution_parent_pokemon_id,
                                                backref=backref('evolution_parent',
                                                                remote_side=[Pokemon.id]))
-Pokemon.flavor_text = relation(PokemonFlavorText, backref='pokemon')
+Pokemon.flavor_text = relation(PokemonFlavorText, order_by=PokemonFlavorText.pokemon_id, backref='pokemon')
 Pokemon.foreign_names = relation(PokemonName, backref='pokemon')
 Pokemon.items = relation(PokemonItem)
 Pokemon.generation = relation(Generation, backref='pokemon')
@@ -476,6 +494,7 @@ PokemonItem.version = relation(Version)
 PokemonFormGroup.pokemon = relation(Pokemon, backref=backref('form_group',
                                                              uselist=False))
 PokemonFormSprite.pokemon = relation(Pokemon, backref='form_sprites')
+PokemonFormSprite.introduced_in = relation(VersionGroup)
 
 PokemonMove.pokemon = relation(Pokemon, backref='pokemon_moves')
 PokemonMove.version_group = relation(VersionGroup)