-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpokeclass.py
174 lines (131 loc) · 4.79 KB
/
pokeclass.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
from math import floor
class Pokemon:
def __init__(self, name, level, sprite_path):
self.name = name
self.level = level
self.sprite_path = sprite_path
self.moves = []
self.stats = {"attack": 0, "defense": 0, "sp_attack": 0, "sp_defense": 0, "speed": 0,
'hp': 0}
def use_move(self, move, target):
if move in self.moves:
attack_stat = self.stats["attack"] if move.category == "Physical" else self.stats["sp_attack"]
defense_stat = target.stats["defense"] if move.category == "Physical" else target.stats["sp_defense"]
damage = (((2 * self.level / 5 + 2) * move.power * attack_stat / defense_stat) / 50) + 2
target.stats["hp"] = max(0, target.stats["hp"] - damage)
else:
print(f"{self.name} does not know {move.name}.")
def pikachu():
pikachu = Pokemon("pikachu", 5, "sprites/pikachu.png")
pikachu.moves = [Thunderbolt(), QuickAttack(), TailWhip(), ThunderWave()]
pikachu.stats = {
"hp": floor(0.5 * (2 * 35) * pikachu.level) + 5,
"attack": 55,
"defense": 40,
"sp_attack": 50,
"sp_defense": 50,
"speed": 90
}
return pikachu
def Squirtle():
squirtle = Pokemon("Squirtle", 5, "sprites/squirtle.png")
squirtle.moves = [Tackle(), TailWhip(), WaterGun(), Bubble()]
squirtle.stats = {
"hp": floor(0.5 * (2 * 44) * squirtle.level) + 5,
"attack": 48,
"defense": 65,
"sp_attack": 50,
"sp_defense": 64,
"speed": 43
}
return squirtle
def Charmander():
charmander = Pokemon("Charmander", 5, "sprites/charmander.png")
charmander.moves = [Scratch(), Growl(), Ember(), MetalClaw()]
charmander.stats = {
"hp": floor(0.5 * (2 * 39) * charmander.level) + 5,
"attack": 52,
"defense": 43,
"sp_attack": 60,
"sp_defense": 50,
"speed": 65
}
return charmander
def Bulbasaur():
bulbasaur = Pokemon("Bulbasaur", 5, "sprites/bulbasaur.png")
bulbasaur.moves = [Tackle(), Growl(), RazorLeaf(), SleepPowder()]
bulbasaur.stats = {
"hp": floor(0.5 * (2 * 45) * bulbasaur.level) + 5,
"attack": 49,
"defense": 49,
"sp_attack": 65,
"sp_defense": 65,
"speed": 45
}
return bulbasaur
def Caterpie():
caterpie = Pokemon("Caterpie", 5, "sprites/caterpie.png")
caterpie.moves = [Tackle(), StringShot()]
caterpie.stats = {
"hp": floor(0.5 * (2 * 45) * caterpie.level) + 5,
"attack": 30,
"defense": 35,
"sp_attack": 20,
"sp_defense": 20,
"speed": 45
}
return caterpie
def Weedle():
weedle = Pokemon("Weedle", 5, "sprites/weedle.png")
weedle.moves = [PoisonSting(), StringShot()]
weedle.stats = {
"hp": floor(0.5 * (2 * 40) * weedle.level) + 5,
"attack": 35,
"defense": 30,
"sp_attack": 20,
"sp_defense": 20,
"speed": 50
}
return weedle
def update(self):
# Update the Pokémon's state or any other game logic here
pass
def is_fainted(self):
return self.stats["hp"] == 0
class Move:
def __init__(self, name, type, category, power, accuracy):
self.name = name
self.type = type
self.category = category # Added category attribute
self.power = power
self.accuracy = accuracy
def Thunderbolt():
return Move("Thunderbolt", "Electric", "Special", 90, 100)
def QuickAttack():
return Move("Quick Attack", "Normal", "Physical", 40, 100)
def TailWhip():
return Move("Tail Whip", "Normal", "Status", 0, 100)
def ThunderWave():
return Move("Thunder Wave", "Electric", "Status", 0, 100)
def Tackle():
return Move("Tackle", "Normal", "Physical", 50, 100)
def WaterGun():
return Move("Water Gun", "Water", "Special", 40, 100)
def Bubble():
return Move("Bubble", "Water", "Special", 40, 100)
def Growl():
return Move("Growl", "Normal", "Status", 0, 100)
def Ember():
return Move("Ember", "Fire", "Special", 40, 100)
def MetalClaw():
return Move("Metal Claw", "Steel", "Physical", 50, 95)
def Scratch():
return Move("Scratch", "Normal", "Physical", 40, 100)
def RazorLeaf():
return Move("Razor Leaf", "Grass", "Physical", 55, 95)
def SleepPowder():
return Move("Sleep Powder", "Grass", "Status", 0, 75)
def StringShot():
return Move("String Shot", "Bug", "Status", 0, 95)
def PoisonSting():
return Move("Poison Sting", "Poison", "Physical", 15, 100)