From 5c80033a0b2f046cb9fa8b2b88e818a3debbfb1e Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sun, 5 Apr 2020 22:04:40 +0200 Subject: [PATCH] Added getStatistic method & enum --- src/entities/Player.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/entities/Player.py b/src/entities/Player.py index d9a3c0c..a7aba49 100644 --- a/src/entities/Player.py +++ b/src/entities/Player.py @@ -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: @@ -35,4 +47,11 @@ class Rotations(Enum): NORTH = 0 EAST = 1 SOUTH = 2 - WEST = 3 \ No newline at end of file + WEST = 3 + + +class StatisticNames(Enum): + HP = 0 + STAMINA = 1 + HUNGER = 2 + THIRST = 3 \ No newline at end of file