-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpokemon.py
149 lines (116 loc) · 5.21 KB
/
pokemon.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import math
import pandas
class Pokemon:
def __init__(self, pokemonData):
self.name = pokemonData['Name']
self.level = 100
#Lookup from sheet
self.types = [pokemonData['Type 1']]
if not pandas.isna(pokemonData['Type 2']):
self.types.append(pokemonData['Type 2'])
#Should be a better way to do this?
self.possibleAbilities = [pokemonData['Ability 1']]
if not pandas.isna(pokemonData['Ability 2']):
self.possibleAbilities.append(pokemonData['Ability 2'])
if not pandas.isna(pokemonData['Hidden Ability']):
self.possibleAbilities.append(pokemonData['Hidden Ability'])
self.ability = self.possibleAbilities[0]
self.nature = "Serious"
self.baseHP = pokemonData['HP']
self.baseAttack = pokemonData['Attack']
self.baseDefense = pokemonData['Defense']
self.baseSpAttack = pokemonData['Special Attack']
self.baseSpDefense = pokemonData['Special Defense']
self.baseSpeed = pokemonData['Speed']
self.IVs = [31, 31, 31, 31, 31, 31]
self.EVs = [0, 0, 0, 0, 0, 0]
self.calculateAllStats()
self.currentHP = self.maxHP
self.fainted = False
self.gender = "Genderless"
self.level = 100
self.moves = []
def calculateAllStats(self):
self.maxHP = self.calculateMaxHP(self.baseHP, self.level, self.IVs[0], self.EVs[0])
self.Attack = self.calculateStat(self.baseAttack, "Attack", self.level, self.IVs[1], self.EVs[1], self.nature)
self.Defense = self.calculateStat(self.baseDefense, "Defense", self.level, self.IVs[2], self.EVs[2], self.nature)
self.SpecialAttack = self.calculateStat(self.baseSpAttack, "Special Attack", self.level, self.IVs[3], self.EVs[3], self.nature)
self.SpecialDefense = self.calculateStat(self.baseSpDefense, "Special Defense", self.level, self.IVs[4], self.EVs[4], self.nature)
self.Speed = self.calculateStat(self.baseSpeed, "Speed", self.level, self.IVs[5], self.EVs[5], self.nature)
def getNatureModifier(self, nature, statType):
if statType == "Attack":
if nature in ("Lonely", "Brave", "Adamant", "Naughty"):
return 1.1
if nature in ("Bold", "Timid", "Modest", "Calm"):
return 0.9
return 1
if statType == "Defense":
if nature in ("Bold", "Relaxed", "Impish", "Lax"):
return 1.1
if nature in ("Lonely", "Hasty", "Mild", "Gentle"):
return 0.9
return 1
if statType == "Special Attack":
if nature in ("Modest", "Mild", "Quiet", "Rash"):
return 1.1
if nature in ("Adamant", "Impish", "Jolly", "Careful"):
return 0.9
return 1
if statType == "Special Defense":
if nature in ("Calm", "Gentle", "Sassy", "Careful"):
return 1.1
if nature in ("Naughty", "Lax", "Naive", "Rash"):
return 0.9
return 1
if statType == "Speed":
if nature in ("Timid", "Hasty", "Jolly", "Naive"):
return 1.1
if nature in ("Brave", "Relaxed", "Quiet", "Sassy"):
return 0.9
return 1
return 1
def calculateMaxHP(self, baseHP, level, IV, EV):
maxHP = math.floor(0.01 * (2 * baseHP + IV + math.floor(0.25 * EV)) * level) + level + 10
return maxHP
def calculateStat(self, baseStat, statType, level, IV, EV, nature):
natureModifier = self.getNatureModifier(nature, statType)
stat = (math.floor(0.01 * (2 * baseStat + IV + math.floor(0.25 * EV)) * level) + 5) * natureModifier
return math.floor(stat)
def addMove(self, moveName):
if len(self.moves) >= 4:
print(f"Could not add {moveName}, as the Pokemon already knows 4 moves.")
return
self.moves.append(moveName)
print(self.moves)
def getHealthPercent(self):
return round(self.currentHP * 100 / self.maxHP, 1)
def printBasic(self):
print("=========================")
print(self.name)
print(*self.types, sep=", ")
print("HP: " + self.getHealthPercent() + "%")
def printDetailed(self):
print("=========================")
print(self.name)
print(*self.types, sep=", ")
print(f"HP: {self.getHealthPercent()}% ({self.currentHP}/{self.maxHP})")
print(f"Ability: {self.ability}")
print(f"Atk {self.Attack} / Def {self.Defense} / SpA {self.SpecialAttack} / SpD {self.SpecialDefense} / Spe {self.Speed}")
def printMoves(self):
moveString = ""
for num in range(4):
if num < len(self.moves):
moveString += f"{num+1}. {self.moves[num]}"
else:
moveString += f"{num+1}. None"
if num < 3:
moveString += " | "
print(moveString)
def takeDamage(self, damageNum):
if damageNum > self.currentHP:
self.currentHP = 0
self.fainted = True
else:
self.currentHP -= damageNum
#def method():
# print("Pokemon")