mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Add Pokemon.base_stat method.
This commit is contained in:
parent
ce4e45d08f
commit
94f120421c
1 changed files with 13 additions and 0 deletions
|
@ -1554,6 +1554,19 @@ class Pokemon(TableBase):
|
||||||
|
|
||||||
raise KeyError(u'No stat named %s' % stat_identifier)
|
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
|
@property
|
||||||
def better_damage_class(self):
|
def better_damage_class(self):
|
||||||
u"""Returns the MoveDamageClass that this Pokémon is best suited for,
|
u"""Returns the MoveDamageClass that this Pokémon is best suited for,
|
||||||
|
|
Loading…
Reference in a new issue