-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.py
34 lines (27 loc) · 780 Bytes
/
player.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
class Player(object):
def __init__(self, val=10):
#temp is here to fix player instanciation issue
self.maxH = val
self.currentH = val
@property
def maxH(self):
return self._maxH
@maxH.setter
def maxH(self, val):
if (val > 0):
self._maxH = val
@property
def currentH(self):
return self._currentH
@currentH.setter
def currentH(self, val):
if (val <= 0):
self._currentH = 0
elif (val >= self.maxH):
self._currentH = self.maxH
else:
self._currentH = val
def getHealthPercent(self):
return (float(self.currentH) / self.maxH) * 100
def __str__(self):
return "{}/{}".format(self.currentH, self.maxH)