forked from bredeson/PnP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
combatfunction.py
69 lines (63 loc) · 2.9 KB
/
combatfunction.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
def combat(self, monster = None):
while monster.hp > 0:
if self.hp <= 0:
print('You have died to a',monster.name)
break
elif monster.hp > 0:
combat_query=input('[attack], [risky] attack, or [magic]?\n')
if combat_query == 'attack':
new_user_attack = random.randint(1,self.attack)
new_mon_attack = random.randint(1,monster.attack)
print(combatResponses.combatResponse_player(self.attack, new_user_attack),'You deal',new_user_attack, 'damage to', monster.name)
time.sleep(3)
monster.hp -= new_user_attack
if monster.hp > 0:
print('The',monster.name, 'has', monster.hp, 'health remaining')
time.sleep(3)
self.hp -= new_mon_attack
print(combatResponses.combatResponse_monster(monster.attack, new_mon_attack), monster.name, 'does', new_mon_attack, 'damage. You health is now', self.hp)
time.sleep(3)
else:
print('The', monster.name, 'is dead')
break
if combat_query == 'risky':
chance = random.randint(1,20)
min = 0.5*self.attack
max = 2*self.attack
new_user_attack = random.randint(min,max)
if chance > 10:
print('You hit for', new_user_attack, 'damage')
monster.hp -= new_user_attack
if monster.hp > 0:
print('The',monster.name, 'has', monster.hp, 'health remaining')
time.sleep(3)
self.hp -= new_mon_attack
print(combatResponses.combatResponse_monster(monster.attack, new_mon_attack), monster.name, 'does', new_mon_attack, 'damage. Your health is now', self.hp)
time.sleep(3)
else:
print('The, monster.name, 'is dead')
break
else:
print('You missed!')
print(combatResponses.combatResponse_monster(monster.attack, new_mon_attack), monster.name, 'does', new_mon_attack, 'damage. Your health is now', self.hp)
self.hp -= new_mon_attack
if combat_query = 'magic':
if self.mana > 0:
new_user_attack = self.attack
print('You do magic stuff for', new_user_attack,'damage')
monster.hp -= new_user_attack
self.mana -= 1
print('You have',self.mana,'mana left')
if monster.hp > 0:
print('The',monster.name, 'has', monster.hp, 'health remaining')
time.sleep(3)
self.hp -=new_mon_attack
print(combatResponses.combatResponse_monster(monster.attack, new_mon_attack), monster.name, 'does', new_mon_attack, 'damage. Your health is now', self.hp)
time.sleep(3)
else:
print('The, monster.name, 'is dead')
break
else:
print('You have no mana left!')
else:
break