From f9391b409afa5f95ec1985d3a4f30c72aee35424 Mon Sep 17 00:00:00 2001 From: Eevee Date: Mon, 15 Jun 2009 20:48:27 -0700 Subject: [PATCH] =?UTF-8?q?Added=20some=20Pok=C3=A9mon=20methods=20to=20hi?= =?UTF-8?q?de=20form=20weirdness.=20=20#5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pokedex/db/tables.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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)