X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/23cb236c2aa004effae360e84d6bc7454660286f..7b13e5278b68d365cece0b0515894fe6b13625d9:/pokedex/db/tables.py diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index cdddd30..812fdc2 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -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): @@ -674,8 +665,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, @@ -838,16 +829,20 @@ class Pokemon(TableBase): info=dict(description=u"True iff the Pokémon is a baby, i.e. a lowest-stage Pokémon that cannot breed but whose evolved form can.")) hatch_counter = Column(Integer, nullable=False, info=dict(description=u"Initial hatch counter: one must walk 255 × (hatch_counter + 1) steps before this Pokémon's egg hatches, unless utilizing bonuses like Flame Body's")) - has_gen4_fem_sprite = Column(Boolean, nullable=False, - info=dict(description=u"Set iff the species' female front sprite is different from the male's in generation IV")) - has_gen4_fem_back_sprite = Column(Boolean, nullable=False, - info=dict(description=u"Set iff the species' female back sprite is different from the male's in generation IV")) + has_gender_differences = Column(Boolean, nullable=False, + info=dict(description=u"Set iff the species exhibits enough sexual dimorphism to have separate sets of sprites in Gen IV and beyond.")) order = Column(Integer, nullable=False, index=True, info=dict(description=u"Order for sorting. Almost national order, except families and forms are grouped together.")) ### Stuff to handle alternate Pokémon forms @property + def form(self): + u"""Returns the Pokémon's form, using its default form as fallback.""" + + return self.unique_form or self.default_form + + @property def is_base_form(self): u"""Returns True iff the Pokémon is the base form for its species, e.g. Land Shaymin. @@ -989,7 +984,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.")) @@ -1039,6 +1034,13 @@ class PokemonForm(TableBase): 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.')) @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".""" @@ -1262,8 +1264,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.""" @@ -1316,6 +1318,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, @@ -1324,6 +1327,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, @@ -1332,6 +1336,7 @@ Ability.dream_pokemon = relation(Pokemon, PokemonAbility.ability_id == Ability.id, PokemonAbility.is_dream == True ), + order_by=Pokemon.order, back_populates='dream_ability', ) @@ -1366,11 +1371,7 @@ EncounterConditionValueMap.condition_value = relation(EncounterConditionValue, backref='encounter_map') EncounterSlot.terrain = relation(EncounterTerrain, backref='slots') - -EncounterSlot.condition_map = relation(EncounterSlotCondition, backref='slot') -EncounterSlot.conditions = association_proxy('condition_map', 'condition') -EncounterSlotCondition.condition = relation(EncounterCondition, - backref='slot_map') +EncounterSlot.version_group = relation(VersionGroup) EvolutionChain.growth_rate = relation(GrowthRate, backref='evolution_chains') EvolutionChain.baby_trigger_item = relation(Item, backref='evolution_chains') @@ -1436,7 +1437,7 @@ 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') @@ -1450,8 +1451,14 @@ 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) @@ -1630,6 +1637,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)