X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/d9d5acdcc6a5c647fcc419f3bf1b3d48227543cf..fce3e52afba0e48be30c7e3b77439f81efe4c75f:/pokedex/db/tables.py?ds=sidebyside diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index 5a4c5b4..49d9c17 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -205,6 +205,26 @@ class Pokemon(TableBase): has_gen4_fem_sprite = Column(Boolean, nullable=False) has_gen4_fem_back_sprite = Column(Boolean, nullable=False) + ### Stuff to handle alternate Pokémon forms + + @property + def national_id(self): + """Returns the National Pokédex number for this Pokémon. Use this + instead of the id directly; alternate formes may make the id incorrect. + """ + + if self.forme_base_pokemon_id: + return self.forme_base_pokemon_id + return self.id + + @property + def full_name(self): + """Returns the name of this Pokémon, including its Forme, if any.""" + + if self.forme_name: + return "%s %s" % (self.forme_name.capitalize(), self.name) + return self.name + class PokemonAbility(TableBase): __tablename__ = 'pokemon_abilities' pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)