projects
/
zzz-pokedex.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ac23f56
)
Added Pokemon.stat() accessor.
author
Eevee
<git@veekun.com>
Fri, 16 Apr 2010 03:05:03 +0000
(20:05 -0700)
committer
Eevee
<git@veekun.com>
Sat, 17 Apr 2010 06:09:32 +0000
(23:09 -0700)
pokedex/db/tables.py
patch
|
blob
|
history
diff --git
a/pokedex/db/tables.py
b/pokedex/db/tables.py
index
508556f
..
3e10259
100644
(file)
--- a/
pokedex/db/tables.py
+++ b/
pokedex/db/tables.py
@@
-350,6
+350,22
@@
class Pokemon(TableBase):
return self
return self
+ ### Not forms!
+
+ def stat(self, stat_name):
+ """Returns a PokemonStat record for the given stat name (or Stat row
+ object). Uses the normal has-many machinery, so all the stats are
+ effectively cached.
+ """
+ if isinstance(stat_name, Stat):
+ stat_name = stat_name.name
+
+ for pokemon_stat in self.stats:
+ if pokemon_stat.stat.name == stat_name:
+ return pokemon_stat
+
+ return None
+
class PokemonAbility(TableBase):
__tablename__ = 'pokemon_abilities'
pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
class PokemonAbility(TableBase):
__tablename__ = 'pokemon_abilities'
pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)