forked from jbs1/jhack14
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentity.py
More file actions
26 lines (23 loc) · 748 Bytes
/
entity.py
File metadata and controls
26 lines (23 loc) · 748 Bytes
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
class Entity:
"""docstring for entity"""
def __init__(self, name, health=100, hitchance=0.5):
self.name = name
self.health = health
self.hitchance = hitchance
def attack(self, dmg):
self.health = self.health - dmg
print(self.name,"was hit!")
check_health();
def check_health(self):
if self.health == 100:
print(self.name,"is fully healed.")
elif self.health >= 70:
print(self.name,"has minour wounds.")
elif self.health >= 50:
print(self.name,"has bigger wounds.")
elif self.health >= 10:
print(self.name,"has major, life-threatening wounds.")
elif self.health >= 1:
print(self.name,"is nearly dead. Time for the final blow.")
elif self.health <= 0:
print(self.name,"was killed by you. Good job!")