Added getStatistic method & enum

This commit is contained in:
Marcin Kostrzewski 2020-04-05 22:04:40 +02:00
parent dc7023adfa
commit 5c80033a0b

View File

@ -24,6 +24,18 @@ class Player(Entity):
elif rotation.value == Rotations.WEST.value:
self.rect.x -= self.rect.w
# Returns given statistic
def getStatistic(self, stat):
if stat.value == StatisticNames.HP:
return self.statistics.hp
elif stat.value == StatisticNames.HUNGER:
return self.statistics.hunger
elif stat.value == StatisticNames.THIRST:
return self.statistics.thirst
elif stat.value == StatisticNames.STAMINA:
return self.statistics.stamina
return None
def rotate(self, rotation):
# If the player is not facing given direction, it will not move the first time, it will only get rotated
if self.rotation.value != rotation.value:
@ -36,3 +48,10 @@ class Rotations(Enum):
EAST = 1
SOUTH = 2
WEST = 3
class StatisticNames(Enum):
HP = 0
STAMINA = 1
HUNGER = 2
THIRST = 3