diff --git a/pokedex/data/csv/special_encounter_type_names.csv b/pokedex/data/csv/special_encounter_type_names.csv new file mode 100644 index 0000000..36aa796 --- /dev/null +++ b/pokedex/data/csv/special_encounter_type_names.csv @@ -0,0 +1,9 @@ +special_encounter_type_id,local_language_id,name +1,9,Starting Pokémon +2,9,Gift +3,9,Fossil +4,9,Overworld +5,9,Purchase +6,9,Trade +7,9,Prize +8,9,Snag diff --git a/pokedex/data/csv/special_encounter_types.csv b/pokedex/data/csv/special_encounter_types.csv new file mode 100644 index 0000000..6fdb07d --- /dev/null +++ b/pokedex/data/csv/special_encounter_types.csv @@ -0,0 +1,9 @@ +id,identifier +1,starter +2,gift +3,fossil +4,overworld +5,purchase +6,trade +7,prize +8,snag diff --git a/pokedex/data/csv/special_encounter_versions.csv b/pokedex/data/csv/special_encounter_versions.csv new file mode 100644 index 0000000..7781355 --- /dev/null +++ b/pokedex/data/csv/special_encounter_versions.csv @@ -0,0 +1 @@ +special_encounter_id,version_id diff --git a/pokedex/data/csv/special_encounters.csv b/pokedex/data/csv/special_encounters.csv new file mode 100644 index 0000000..b8542b4 --- /dev/null +++ b/pokedex/data/csv/special_encounters.csv @@ -0,0 +1 @@ +id,type_id,event_pokemon_id,location_area_id,roam_region_id,cost,traded_species_id,traded_gender_id diff --git a/pokedex/data/csv/trainer_names.csv b/pokedex/data/csv/trainer_names.csv new file mode 100644 index 0000000..9ad6925 --- /dev/null +++ b/pokedex/data/csv/trainer_names.csv @@ -0,0 +1 @@ +trainer_id,local_language_id,name diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index c000d43..5dbf169 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -1516,6 +1516,56 @@ create_translation_table('region_names', Region, 'names', info=dict(description="The name", format='plaintext', official=True)), ) + +class SpecialEncounter(TableBase): + u"""Special in-game encounters with pokémon: trades, prizes, fossils, etc. + """ + __tablename__ = 'special_encounters' + id = Column(Integer, primary_key=True, nullable=False, + info=dict(description=u"A numeric ID")) + type_id = Column(Integer, ForeignKey('special_encounter_types.id'), nullable=False, + info=dict(description=u"Type of the encounter")) + event_pokemon_id = Column(Integer, ForeignKey('event_pokemon.id'), nullable=False, + info=dict(description=u"The pokémon encountered")) + location_area_id = Column(Integer, ForeignKey('location_areas.id'), nullable=True, + info=dict(description=u"The location of the encounter, if specific")) + roam_region_id = Column(Integer, ForeignKey('regions.id'), nullable=True, + info=dict(description=u"The region, if roaming")) + cost = Column(Integer, nullable=True, + info=dict(description=u"The cost, in game money or coints, if applicable")) + traded_species_id = Column(Integer, ForeignKey('pokemon_species.id'), nullable=True, + info=dict(description=u"The species the player needs to offer in trade, if applicable")) + traded_gender_id = Column(Integer, ForeignKey('genders.id'), nullable=True, + info=dict(description=u"The gender of the pokémon the player needs to offer in trade, if applicable")) + + +class SpecialEncounterType(TableBase): + u"""Type of a special in-game encounter + """ + __tablename__ = 'special_encounter_types' + __singlename__ = 'special_encounter_type' + id = Column(Integer, primary_key=True, nullable=False, + info=dict(description=u"A numeric ID")) + identifier = Column(Unicode(16), nullable=False, + info=dict(description=u"An identifier", format='identifier')) + +create_translation_table('special_encounter_type_names', SpecialEncounterType, 'names', + relation_lazy='joined', + name = Column(Unicode(16), nullable=False, index=True, + info=dict(description="The name", format='plaintext', official=False)), +) + + +class SpecialEncounterVersion(TableBase): + u"""Maps special encounters to the versions they occur in + """ + __tablename__ = 'special_encounter_versions' + special_encounter_id = Column(Integer, ForeignKey('special_encounters.id'), primary_key=True, nullable=False, autoincrement=False, + info=dict(description=u"The encounter")) + version_id = Column(Integer, ForeignKey('versions.id'), primary_key=True, nullable=False, autoincrement=False, + info=dict(description=u"The version")) + + class Stat(TableBase): u"""A Stat, such as Attack or Speed """ @@ -2147,9 +2197,32 @@ Region.version_group_regions = relationship(VersionGroupRegion, Region.version_groups = association_proxy('version_group_regions', 'version_group') +SpecialEncounter.type = relationship(SpecialEncounterType, + backref='encounters') +SpecialEncounter.event_pokemon = relationship(EventPokemon, + backref='encounters') +SpecialEncounter.location_area = relationship(LocationArea, + backref='special_encounters') +SpecialEncounter.roam_region = relationship(Region, + backref='roam_encounters') +SpecialEncounter.traded_species = relationship(PokemonSpecies, + backref='possible_in_game_trades') +SpecialEncounter.traded_gender = relationship(Gender) +SpecialEncounter.versions = relationship(Version, + secondary=SpecialEncounterVersion.__table__, + primaryjoin=SpecialEncounterVersion.special_encounter_id == SpecialEncounter.id, + secondaryjoin=SpecialEncounterVersion.version_id == Version.id, + backref='special_encounters') + + +SpecialEncounterVersion.encounter = relationship(SpecialEncounter) +SpecialEncounterVersion.version = relationship(Version) + + Stat.damage_class = relationship(MoveDamageClass, backref='stats') + StatHint.stat = relationship(Stat, innerjoin=True, backref='hints')