diff --git a/doc/main-tables.rst b/doc/main-tables.rst index bd1d3be..adadff1 100644 --- a/doc/main-tables.rst +++ b/doc/main-tables.rst @@ -36,7 +36,7 @@ Pokémon .. dex-table:: PokemonSpecies .. dex-table:: Pokemon .. dex-table:: PokemonForm -.. dex-table:: EvolutionChain +.. dex-table:: PokemonFamily .. dex-table:: PokemonEvolution Moves @@ -103,7 +103,6 @@ Enum tables .. dex-table:: BerryFirmness .. dex-table:: ContestType .. dex-table:: EggGroup -.. dex-table:: EvolutionTrigger .. dex-table:: GrowthRate .. dex-table:: ItemCategory .. dex-table:: ItemFlingEffect @@ -116,6 +115,7 @@ Enum tables .. dex-table:: Nature .. dex-table:: PalParkArea .. dex-table:: PokemonColor +.. dex-table:: PokemonEvolutionTrigger .. dex-table:: PokemonMoveMethod .. dex-table:: PokemonShape .. dex-table:: Stat diff --git a/pokedex/data/csv/evolution_trigger_prose.csv b/pokedex/data/csv/evolution_trigger_prose.csv deleted file mode 100644 index 330894b..0000000 --- a/pokedex/data/csv/evolution_trigger_prose.csv +++ /dev/null @@ -1,5 +0,0 @@ -evolution_trigger_id,local_language_id,name -1,9,Level up -2,9,Trade -3,9,Use item -4,9,Shed diff --git a/pokedex/data/csv/pokemon_evolution.csv b/pokedex/data/csv/pokemon_evolution.csv index c9b1b64..65f8da8 100644 --- a/pokedex/data/csv/pokemon_evolution.csv +++ b/pokedex/data/csv/pokemon_evolution.csv @@ -1,4 +1,4 @@ -id,evolved_species_id,evolution_trigger_id,trigger_item_id,minimum_level,gender,location_id,held_item_id,time_of_day,known_move_id,minimum_happiness,minimum_beauty,relative_physical_stats,party_species_id,trade_species_id +id,evolved_species_id,trigger_id,trigger_item_id,minimum_level,gender,location_id,held_item_id,time_of_day,known_move_id,minimum_happiness,minimum_beauty,relative_physical_stats,party_species_id,trade_species_id 1,2,1,,16,,,,,,,,,, 2,3,1,,32,,,,,,,,,, 3,5,1,,16,,,,,,,,,, diff --git a/pokedex/data/csv/pokemon_evolution_trigger_prose.csv b/pokedex/data/csv/pokemon_evolution_trigger_prose.csv new file mode 100644 index 0000000..4838a67 --- /dev/null +++ b/pokedex/data/csv/pokemon_evolution_trigger_prose.csv @@ -0,0 +1,5 @@ +pokemon_evolution_trigger_id,local_language_id,name +1,9,Level up +2,9,Trade +3,9,Use item +4,9,Shed diff --git a/pokedex/data/csv/evolution_triggers.csv b/pokedex/data/csv/pokemon_evolution_triggers.csv similarity index 100% rename from pokedex/data/csv/evolution_triggers.csv rename to pokedex/data/csv/pokemon_evolution_triggers.csv diff --git a/pokedex/data/csv/evolution_chains.csv b/pokedex/data/csv/pokemon_families.csv similarity index 100% rename from pokedex/data/csv/evolution_chains.csv rename to pokedex/data/csv/pokemon_families.csv diff --git a/pokedex/data/csv/pokemon_species.csv b/pokedex/data/csv/pokemon_species.csv index 7eede21..597e13c 100644 --- a/pokedex/data/csv/pokemon_species.csv +++ b/pokedex/data/csv/pokemon_species.csv @@ -1,4 +1,4 @@ -id,identifier,generation_id,evolves_from_species_id,evolution_chain_id,color_id,shape_id,habitat_id,gender_rate,capture_rate,base_happiness,is_baby,hatch_counter,has_gender_differences,growth_rate_id,forms_switchable +id,identifier,generation_id,evolves_from_species_id,family_id,color_id,shape_id,habitat_id,gender_rate,capture_rate,base_happiness,is_baby,hatch_counter,has_gender_differences,growth_rate_id,forms_switchable 1,bulbasaur,1,,1,5,8,3,1,45,70,0,20,0,4,0 2,ivysaur,1,1,1,5,8,3,1,45,70,0,20,0,4,0 3,venusaur,1,2,1,5,8,3,1,45,70,0,20,1,4,0 diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index f49ec91..ebd0ffb 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -403,30 +403,6 @@ class EncounterSlot(TableBase): rarity = Column(Integer, nullable=True, info=dict(description="The chance of the encounter as a percentage")) -class EvolutionChain(TableBase): - u"""A family of Pokémon that are linked by evolution - """ - __tablename__ = 'evolution_chains' - id = Column(Integer, primary_key=True, nullable=False, - info=dict(description="A numeric ID")) - baby_trigger_item_id = Column(Integer, ForeignKey('items.id'), nullable=True, - info=dict(description="Item that a parent must hold while breeding to produce a baby")) - -class EvolutionTrigger(TableBase): - u"""An evolution type, such as "level" or "trade". - """ - __tablename__ = 'evolution_triggers' - __singlename__ = 'evolution_trigger' - id = Column(Integer, primary_key=True, nullable=False, - info=dict(description="A numeric ID")) - identifier = Column(Unicode(16), nullable=False, - info=dict(description="An identifier", format='identifier')) - -create_translation_table('evolution_trigger_prose', EvolutionTrigger, 'prose', - name = Column(Unicode(16), nullable=False, index=True, - info=dict(description="The name", format='plaintext', official=False)), -) - class Experience(TableBase): u"""EXP needed for a certain level with a certain growth rate """ @@ -1220,7 +1196,7 @@ class PokemonEvolution(TableBase): info=dict(description=u"A numeric ID")) evolved_species_id = Column(Integer, ForeignKey('pokemon_species.id'), nullable=False, info=dict(description=u"The ID of the post-evolution species.")) - evolution_trigger_id = Column(Integer, ForeignKey('evolution_triggers.id'), nullable=False, + trigger_id = Column(Integer, ForeignKey('pokemon_evolution_triggers.id'), nullable=False, info=dict(description=u"The ID of the evolution trigger.")) trigger_item_id = Column(Integer, ForeignKey('items.id'), nullable=True, info=dict(description=u"The ID of the item that must be used on the Pokémon.")) @@ -1247,6 +1223,31 @@ class PokemonEvolution(TableBase): trade_species_id = Column(Integer, ForeignKey('pokemon_species.id'), nullable=True, info=dict(description=u"The ID of the species for which this one must be traded.")) +class PokemonEvolutionTrigger(TableBase): + u"""An evolution type, such as "level" or "trade". + """ + __tablename__ = 'pokemon_evolution_triggers' + __singlename__ = 'pokemon_evolution_trigger' + id = Column(Integer, primary_key=True, nullable=False, + info=dict(description="A numeric ID")) + identifier = Column(Unicode(16), nullable=False, + info=dict(description="An identifier", format='identifier')) + +create_translation_table('pokemon_evolution_trigger_prose', PokemonEvolutionTrigger, 'prose', + name = Column(Unicode(16), nullable=False, index=True, + info=dict(description="The name", format='plaintext', official=False)), +) + +class PokemonFamily(TableBase): + u"""A group of Pokémon that are linked by evolution or breeding + """ + __tablename__ = 'pokemon_families' + __singlename__ = 'pokemon_family' + id = Column(Integer, primary_key=True, nullable=False, + info=dict(description="A numeric ID")) + baby_trigger_item_id = Column(Integer, ForeignKey('items.id'), nullable=True, + info=dict(description="Item that a parent must hold while breeding to produce a baby")) + class PokemonForm(TableBase): u"""An individual form of a Pokémon. This includes *every* variant (except color differences) of every Pokémon, regardless of how the games treat @@ -1419,8 +1420,8 @@ class PokemonSpecies(TableBase): info=dict(description=u"ID of the generation this species first appeared in")) evolves_from_species_id = Column(Integer, ForeignKey('pokemon_species.id'), nullable=True, info=dict(description=u"The species from which this one evolves")) - evolution_chain_id = Column(Integer, ForeignKey('evolution_chains.id'), - info=dict(description=u"ID of the species' evolution chain (a.k.a. family)")) + family_id = Column(Integer, ForeignKey('pokemon_families.id'), + info=dict(description=u"ID of the species' evolution family")) color_id = Column(Integer, ForeignKey('pokemon_colors.id'), nullable=False, info=dict(description=u"ID of this Pokémon's Pokédex color, as used for a gimmick search function in the games.")) shape_id = Column(Integer, ForeignKey('pokemon_shapes.id'), nullable=False, @@ -1440,7 +1441,7 @@ class PokemonSpecies(TableBase): 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.")) growth_rate_id = Column(Integer, ForeignKey('growth_rates.id'), nullable=False, - info=dict(description="ID of the growth rate for this family")) + info=dict(description="ID of the growth rate for this species")) forms_switchable = Column(Boolean, nullable=False, info=dict(description=u"True iff a particular individual of this species can switch beween its different forms.")) @@ -1735,10 +1736,6 @@ EncounterSlot.method = relationship(EncounterMethod, EncounterSlot.version_group = relationship(VersionGroup, innerjoin=True) -EvolutionChain.baby_trigger_item = relationship(Item, - backref='evolution_chains') - - Experience.growth_rate = relationship(GrowthRate, innerjoin=True, lazy='joined', backref='experience_table') @@ -2004,7 +2001,7 @@ Pokemon.types = relationship(Type, PokemonDexNumber.pokedex = relationship(Pokedex, innerjoin=True, lazy='joined') -PokemonEvolution.trigger = relationship(EvolutionTrigger, +PokemonEvolution.trigger = relationship(PokemonEvolutionTrigger, innerjoin=True, lazy='joined', backref='evolutions') PokemonEvolution.trigger_item = relationship(Item, @@ -2023,6 +2020,9 @@ PokemonEvolution.party_species = relationship(PokemonSpecies, PokemonEvolution.trade_species = relationship(PokemonSpecies, primaryjoin=PokemonEvolution.trade_species_id==PokemonSpecies.id) +PokemonFamily.baby_trigger_item = relationship(Item, + backref='pokemon_families') + PokemonForm.pokemon = relationship(Pokemon, primaryjoin=PokemonForm.pokemon_id==Pokemon.id, innerjoin=True, lazy='joined') @@ -2084,7 +2084,7 @@ PokemonSpecies.flavor_text = relationship(PokemonSpeciesFlavorText, backref='species') PokemonSpecies.growth_rate = relationship(GrowthRate, innerjoin=True, - backref='evolution_chains') + backref='species') PokemonSpecies.habitat = relationship(PokemonHabitat, backref='species') PokemonSpecies.color = relationship(PokemonColor, @@ -2113,7 +2113,7 @@ PokemonSpecies.default_pokemon = relationship(Pokemon, PokemonSpecies.id==Pokemon.species_id, Pokemon.is_default==True), uselist=False, lazy='joined') -PokemonSpecies.evolution_chain = relationship(EvolutionChain, +PokemonSpecies.family = relationship(PokemonFamily, innerjoin=True, backref=backref('species', order_by=PokemonSpecies.id.asc())) PokemonSpecies.dex_numbers = relationship(PokemonDexNumber,