Fix broken game test
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user