Fix broken game test

This commit is contained in:
Yohann D'ANELLO
2020-11-10 22:44:53 +01:00
parent d26b66f337
commit 12ee436f4d
4 changed files with 23 additions and 3 deletions

View File

@ -33,6 +33,12 @@ class Map:
self.entities.append(entity)
entity.map = self
def remove_entity(self, entity: "Entity") -> None:
"""
Unregister an entity from the map.
"""
self.entities.remove(entity)
def is_free(self, y: int, x: int) -> bool:
"""
Indicates that the case at the coordinates (y, x) is empty.
@ -138,9 +144,10 @@ class Entity:
self.move(y, x)
return free
def move(self, y: int, x: int) -> None:
def move(self, y: int, x: int) -> bool:
self.y = y
self.x = x
return True
def move_up(self, force: bool = False) -> bool:
return self.move(self.y - 1, self.x) if force else \
@ -192,3 +199,4 @@ class FightingEntity(Entity):
def die(self) -> None:
self.dead = True
self.map.remove_entity(self)