-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonsters.py
75 lines (65 loc) · 2.78 KB
/
monsters.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
#!/usr/bin/python2
#
#~~monsters.py~~
from time import sleep
#from random import randint
import actions
class CreateMonster(object):
def __init__(self, health, damage_dealt, name):
self.health = health
self.damage_dealt = damage_dealt
self.name = name
def __str__(self):
return "\nName: %s\nDamage Dealt: %d\nHealth: %d" % (self.name,self.damage_dealt,self.health)
def attack (self, Player):
actions.clearscreen()
print "\nYou were attacked by a %s!" % self.name
Player.take_damage(self.damage_dealt)
choice = raw_input("\nDo you F)ight it or R)un away? ").lower()
if choice == "f":
actions.clearscreen()
print "\nYou decided to fight it. Bad idea!"
#TODO: add a check to make sure the player is using the best weapon in their inventory
while self.health > 0:
print "\n***********************************************************"
Player.deal_damage(self)
sleep(1)
#monster still attacks after being killed unless health is checked beforehand
if self.health > 0:
self.deal_damage(Player)
sleep(1)
Player.low_health() #gives the player a chance to use a potion when health is at 60 or below
return Player
else:
actions.clearscreen()
print "\nYou decided to run away like a scared child!"
sleep(2)
Player.run_away += 1
return Player
def boss_attack (self,Player):
actions.clearscreen()
print "\nA %s blocks your path! There looks to be no way around it.\n\nPrepare to fight!" % self.name
sleep(2)
Player.take_damage(self.damage_dealt)
while self.health > 0:
print "\n***********************************************************"
Player.deal_damage(self)
sleep(1)
#monster still attacks after being killed unless health is checked beforehand
if self.health > 0:
self.deal_damage(Player)
sleep(1)
Player.low_health()
return Player
def take_damage(self, damage_taken, Player):
self.health -= damage_taken
print "\nThe %s took %d damage! Its health is now at %d" % (self.name,damage_taken,self.health)
if self.health <= 0:
print "\nYou killed the %s!" % self.name
Player.gain_xp(self.name)
sleep(2)
return Player
def deal_damage(self, Player):
print "\nThe %s attacked and dealt %d damage!" % (self.name, self.damage_dealt)
Player.take_damage(self.damage_dealt)
return Player