Replace player instance
This commit is contained in:
		| @@ -122,6 +122,8 @@ class Game: | |||||||
|         Loads the game from a dictionary |         Loads the game from a dictionary | ||||||
|         """ |         """ | ||||||
|         self.map.load_state(d) |         self.map.load_state(d) | ||||||
|  |         # noinspection PyTypeChecker | ||||||
|  |         self.player = self.map.find_entities(Player)[0] | ||||||
|         self.display_actions(DisplayActions.UPDATE) |         self.display_actions(DisplayActions.UPDATE) | ||||||
|  |  | ||||||
|     def load_game(self) -> None: |     def load_game(self) -> None: | ||||||
|   | |||||||
| @@ -45,6 +45,10 @@ class Map: | |||||||
|         """ |         """ | ||||||
|         self.entities.remove(entity) |         self.entities.remove(entity) | ||||||
|  |  | ||||||
|  |     def find_entities(self, entity_class: type) -> list: | ||||||
|  |         return [entity for entity in self.entities | ||||||
|  |                 if isinstance(entity, entity_class)] | ||||||
|  |  | ||||||
|     def is_free(self, y: int, x: int) -> bool: |     def is_free(self, y: int, x: int) -> bool: | ||||||
|         """ |         """ | ||||||
|         Indicates that the case at the coordinates (y, x) is empty. |         Indicates that the case at the coordinates (y, x) is empty. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user