From b61ffc008ba010e90af01a4aa291877749ef6a49 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sat, 16 May 2020 10:21:37 +0200 Subject: [PATCH] Now uses classifier enum instead of stings --- src/entities/Interactable.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/entities/Interactable.py b/src/entities/Interactable.py index 60a0b5d..bd4f37d 100644 --- a/src/entities/Interactable.py +++ b/src/entities/Interactable.py @@ -1,4 +1,5 @@ from src.entities.Entity import Entity +from src.entities.Enums import Classifiers class Interactable(Entity): @@ -10,12 +11,21 @@ class Interactable(Entity): :param size: Size in px :param pos: A tuple of coords (x,y) :param Statistics: Outcome of the interaction - :param classifier: Type of the entity (food, water, rest) + :param classifier: Type of the entity (food, water, rest) as string """ super().__init__(texture, size, pos) self.Statistics = Statistics - self.classifier = classifier + self.classifier = None + self.setClassifier(classifier) + + def setClassifier(self, classifier): + if classifier == "food": + self.classifier = Classifiers.FOOD + elif classifier == "water": + self.classifier = Classifiers.WATER + elif classifier == "rest": + self.classifier = Classifiers.REST def on_interaction(self, Player): """ @@ -29,4 +39,4 @@ class Interactable(Entity): Player.statistics.set_hunger(self.Statistics.hunger) def __str__(self): - return "Entity - ID:{}, pos:({}x, {}y), {}".format(self.id, self.x, self.y, self.classifier) + return "Entity - ID:{}, pos:({}x, {}y), {}".format(self.id, self.x, self.y, self.classifier.name)