From b6893379cff1f20b3104c8b6be38b0062985792a Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sat, 16 May 2020 10:44:19 +0200 Subject: [PATCH] added getInteractablesByClassifier method --- src/game/Map.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/game/Map.py b/src/game/Map.py index 07fe2c3..f8fda77 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -2,6 +2,7 @@ import json import pygame +from src.entities.Enums import Classifiers from src.entities.Interactable import Interactable from src.game.TerrainTile import TerrainTile from src.game.Screen import Locations @@ -89,6 +90,19 @@ class Map: print("Failed to load entity " + entity) return actualEntities + def getInteractablesByClassifier(self, classifier: Classifiers): + """ + Return a list of all Interactable entities by a given classifier. + + :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) + return result + def getEntitiesByType(self, type): """ Get a list of all entities by their type.