From 5e1e08901585a2be7da21a0ad45bd65165210d99 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sat, 16 May 2020 11:41:51 +0200 Subject: [PATCH] getInteractablesByClassifier's classifier param is now optional --- src/game/Map.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/game/Map.py b/src/game/Map.py index f8fda77..66ae654 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -90,17 +90,21 @@ class Map: print("Failed to load entity " + entity) return actualEntities - def getInteractablesByClassifier(self, classifier: Classifiers): + def getInteractablesByClassifier(self, classifier=None): """ Return a list of all Interactable entities by a given classifier. + If the classifier is None, returns all interactables. :type classifier: Classifiers :param classifier: Classifier """ result = [] for entity in self.entities.sprites(): - if isinstance(entity, Interactable) and entity.classifier.value == classifier.value: - result.append(entity) + if isinstance(entity, Interactable): + if classifier is None: + result.append(entity) + elif entity.classifier.value == classifier.value: + result.append(entity) return result def getEntitiesByType(self, type):