-
Notifications
You must be signed in to change notification settings - Fork 0
/
pkb_stats.py
96 lines (53 loc) · 2.4 KB
/
pkb_stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from pkb_types import *
def CalcPokemonStats(pk:Pokemon, cpMax):
# level and stats of each pokemon
# Initial stats are preserved in cases where stat changing attacks may change the stats during battle.
valAttack = int(pk.tupleData[pkData_Attack] + pk.ivs.attack)
valDefense = int(pk.tupleData[pkData_Defense] + pk.ivs.defense)
valStamina = int(pk.tupleData[pkData_Stamina] + pk.ivs.stamina)
bstat = BattleStats()
bstat.level = pk.ivs.levelMax
while bstat.level >= 1.5:
bstat.cp = CpAtLevelFromStats(bstat.level, valAttack, valDefense, valStamina)
if bstat.cp <= cpMax:
break
bstat.level -= 0.5
statMult = StatMultiplier(bstat.level)
bstat.attCMP = statMult * valAttack
bstat.attInit = bstat.attCMP
bstat.defInit = statMult * valDefense
if pk.fShadow:
bstat.attInit = (6 / 5) * bstat.attInit
bstat.defInit = (5 / 6) * bstat.defInit
bstat.attack = bstat.attInit
bstat.defense = bstat.defInit
bstat.hp = RoundDown(statMult * valStamina)
pk.bstat = bstat
def StatMultiplier(level):
tupleRow= TupleFromTable(xlf.tableStatMultiplier, level)
return ValFromTuple(tupleRow, 1, 1)
def CpAtLevelFromStats(level, valAttack, valDefense, valStamina):
# ' see https://gamepress.gg/pokemongo/pokemon-stats-advanced
# valAttack, valDefense, valStamina are the pokemon's base stat plus the related IV of the pokemon.
# For a perfect pokemon, add 15 to each base stat.
mult = StatMultiplier(level)
return RoundDown((valAttack * math.sqrt(valDefense) * math.sqrt(valStamina) * mult * mult) / 10)
class BattleLeague:
def __init__(self, strBattleLeague):
self.strBattleLeague = strBattleLeague
tupleData = TupleFromTable(xlf.tableBattleLeagues, strBattleLeague)
self.strBattleLeague = StrFromTuple(tupleData, 0)
self.cpMax = ValFromTuple(tupleData, 1)
self.strRestriction = StrFromTuple(tupleData, 2)
def QualifyPokemon(pk: Pokemon, bl: BattleLeague):
if pk.fInvalid:
return
pk.fQualified = True
# Qualified unless the League has restrictions
if bl.strRestriction == "Premier":
if pk.fLegendaryOrMythical:
pk.fQualified = False
elif bl.strRestriction == "Flying":
if pk.strType1 != "Flying" and pk.strType2 != "Flying":
pk.fQualified = False
CalcPokemonStats(pk, bl.cpMax)