projects
/
zzz-pokedex.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make Pokemon.form an actual relation
[zzz-pokedex.git]
/
pokedex
/
formulae.py
diff --git
a/pokedex/formulae.py
b/pokedex/formulae.py
index
19ed568
..
62271f1
100644
(file)
--- a/
pokedex/formulae.py
+++ b/
pokedex/formulae.py
@@
-18,24
+18,29
@@
def nCr(n, r):
1)
1)
-def calculated_stat(base_stat, level, iv, effort):
+def calculated_stat(base_stat, level, iv, effort
, nature=None
):
"""Returns the calculated stat -- i.e. the value actually shown in the game
on a Pokémon's status tab.
"""
# Remember: this is from C; use floor division!
"""Returns the calculated stat -- i.e. the value actually shown in the game
on a Pokémon's status tab.
"""
# Remember: this is from C; use floor division!
-
return
(base_stat * 2 + iv + effort // 4) * level // 100 + 5
+
stat =
(base_stat * 2 + iv + effort // 4) * level // 100 + 5
-def calculated_hp(base_hp, level, iv, effort):
+ if nature:
+ stat = int(stat * nature)
+
+ return stat
+
+def calculated_hp(base_stat, level, iv, effort, nature=None):
"""Similar to `calculated_stat`, except with a slightly different formula
used specifically for HP.
"""
# Shedinja's base stat of 1 is special; its HP is always 1
"""Similar to `calculated_stat`, except with a slightly different formula
used specifically for HP.
"""
# Shedinja's base stat of 1 is special; its HP is always 1
- if base_
hp
== 1:
+ if base_
stat
== 1:
return 1
return 1
- return (base_
hp
* 2 + iv + effort // 4) * level // 100 + 10 + level
+ return (base_
stat
* 2 + iv + effort // 4) * level // 100 + 10 + level
def earned_exp(base_exp, level):
"""Returns the amount of EXP earned when defeating a Pokémon at the given
def earned_exp(base_exp, level):
"""Returns the amount of EXP earned when defeating a Pokémon at the given