mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Added Python versions of stat formulae.
This commit is contained in:
parent
ed83e318fd
commit
15eae9ed6c
1 changed files with 21 additions and 0 deletions
21
pokedex/formulae.py
Normal file
21
pokedex/formulae.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# encoding: utf8
|
||||
"""Faithful translations of calculations the games make."""
|
||||
|
||||
def calculated_stat(base_stat, level, iv, effort):
|
||||
"""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
|
||||
|
||||
def calculated_hp(base_hp, level, iv, effort):
|
||||
"""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:
|
||||
return 1
|
||||
|
||||
return (base_hp * 2 + iv + effort // 4) * level // 100 + 10 + level
|
Loading…
Reference in a new issue