From 94f120421c5f8ba4d2c4e4edec8f0704114a3083 Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Thu, 31 Oct 2013 16:08:32 -0700 Subject: [PATCH] Add Pokemon.base_stat method. --- pokedex/db/tables.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index c91dd21..a0ff8fe 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -1554,6 +1554,19 @@ class Pokemon(TableBase): raise KeyError(u'No stat named %s' % stat_identifier) + def base_stat(self, stat_identifier, default=0): + u"""Return this Pokemon's base stat value for the given stat identifier, + or default if missing.""" + + if isinstance(stat_identifier, Stat): + stat_identifier = stat_identifier.identifier + + for pokemon_stat in self.stats: + if pokemon_stat.stat.identifier == stat_identifier: + return pokemon_stat.base_stat + + return default + @property def better_damage_class(self): u"""Returns the MoveDamageClass that this Pokémon is best suited for,