-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlearn-classes-pokemon-battle
37 lines (29 loc) · 1.27 KB
/
learn-classes-pokemon-battle
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
import random
class Pokemon:
def __init__(self, name, move, moveDamage, healthPoints, element):
self.name = name
self.move = move
self.moveDamage = moveDamage
self.healthPoints = healthPoints
self.element = element
def pmove(self, target):
success = random.randint(0,1)
if success == 1:
print(self.name+" used "+self.move+" on "+target.name+" inflicting "+str(self.moveDamage)+" damage \n")
target.healthPoints -= self.moveDamage
print(self.name+" : "+str(self.healthPoints)+"\n")
print(target.name+" : "+str(target.healthPoints)+"\n")
elif success == 0:
print(self.name+" "+self.move+" failed")
print(self.name+" : "+str(self.healthPoints)+"\n")
print(target.name+" : "+str(target.healthPoints)+"\n")
pk = Pokemon("pikachu", "quick attack", 20, 60, "electic")
cz = Pokemon("charizard", "blast", 130, 160, "fire")
jp = Pokemon("jigglypuff", "rollout", 20, 70, "fairy")
ev = Pokemon("eevee", "scratch", 10, 60, "normal")
pokeList = ["pk", "cz", "jp","ev"]
partner = input("Choose your Pokemon \n")
targetAttack = input("Who do you want to attack? \n")
while partner in pokeList and targetAttack in pokeList:
while locals()[targetAttack].healthPoints > 0:
locals()[partner].pmove(locals()[targetAttack])