-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpokemon_world.py
57 lines (45 loc) · 1.5 KB
/
pokemon_world.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
# Author: Zarif Aziz
from random import randint
from random import choice
import time
import math
class Pokemon(object):
# state variable that needs to be seen my the other class
defending = 0
def __init__(self, name):
self.name = name
# Pokemon has an attack function
def attack(self, target, action):
user.defending = 0
damage = 0
time.sleep(1)
# If your opponent is defending
if target.defending == 1:
print "%s attacks %s with %s, but it's defending!" % (self.name, target.name, action)
# Inflict relatively smaller damage
damage = int(self.moves[action]) - randint(1,5)
target.hp = target.hp - damage
else:
print "%s attacks %s with %s, it's very effective!" % (self.name, target.name, action)
# Inflict relatively higher damage
damage = int(self.moves[action]) + randint(6,15)
target.hp = target.hp - damage
time.sleep(1)
print "%s's HP decreases by %s points" % (target.name, damage)
# Pokemon has a defend function
def defend(self):
self.defending = 1
print "%s is trying to defend" % (self.name)
# 1) Pikachu
# 2) Lapras
# 3) Gengar
# 4) Charizard
arsenal ={
'1' : 'Pikachu',
'2' : 'Lapras',
'3' : 'Gengar',
'4' : 'Charizard'
}
# Learn how to make a dictionary to obtain pokemon
def choose(self, number):
return Pokemon.arsenal.get(number)