Require docutils.
[zzz-pokedex.git] / pokedex / formulae.py
1 # encoding: utf8
2 """Faithful translations of calculations the games make."""
3
4 def calculated_stat(base_stat, level, iv, effort):
5 """Returns the calculated stat -- i.e. the value actually shown in the game
6 on a Pokémon's status tab.
7 """
8
9 # Remember: this is from C; use floor division!
10 return (base_stat * 2 + iv + effort // 4) * level // 100 + 5
11
12 def calculated_hp(base_hp, level, iv, effort):
13 """Similar to `calculated_stat`, except with a slightly different formula
14 used specifically for HP.
15 """
16
17 # Shedinja's base stat of 1 is special; its HP is always 1
18 if base_hp == 1:
19 return 1
20
21 return (base_hp * 2 + iv + effort // 4) * level // 100 + 10 + level
22
23 def earned_exp(base_exp, level):
24 """Returns the amount of EXP earned when defeating a Pokémon at the given
25 level.
26 """
27
28 return base_exp * level // 7