From 738d6ff0da1f9bb0f573a9713af24cc9fbd7c2ab Mon Sep 17 00:00:00 2001 From: "Lynn \"Zhorken\" Vaughan" Date: Mon, 24 Jan 2011 15:33:18 -0500 Subject: [PATCH] Add properties for getting a Pokemon from a PokemonForm, and vice-versa. --- pokedex/db/tables.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index cdddd30..4eab271 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -848,6 +848,12 @@ class Pokemon(TableBase): ### 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. @@ -1039,6 +1045,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".""" -- 2.7.4