From b6f30bf22db8ef0cfc13ed4fbbd1d88c4ec67e17 Mon Sep 17 00:00:00 2001 From: Eevee Date: Sun, 22 Mar 2009 22:07:31 -0400 Subject: [PATCH] Added Python versions of stat formulae. --- pokedex/formulae.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pokedex/formulae.py diff --git a/pokedex/formulae.py b/pokedex/formulae.py new file mode 100644 index 0000000..2059db7 --- /dev/null +++ b/pokedex/formulae.py @@ -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 -- 2.7.4