Fix for loading game in progress, there remains to change all entities __init__ to allow being initialized by a dictionnary (work in progress, breaks the game)
This commit is contained in:
@ -37,6 +37,13 @@ class Item(Entity):
|
||||
self.map.remove_entity(self)
|
||||
player.inventory.append(self)
|
||||
|
||||
def save_state(self) -> None:
|
||||
"""
|
||||
Saves the state of the entity into a dictionary
|
||||
"""
|
||||
d = super().save_state()
|
||||
d["held"] = self.held
|
||||
|
||||
|
||||
class Heart(Item):
|
||||
"""
|
||||
@ -55,6 +62,13 @@ class Heart(Item):
|
||||
player.health = min(player.maxhealth, player.health + self.healing)
|
||||
self.map.remove_entity(self)
|
||||
|
||||
def save_state(self) -> None:
|
||||
"""
|
||||
Saves the state of the entity into a dictionary
|
||||
"""
|
||||
d = super().save_state()
|
||||
d["type"] = "Heart"
|
||||
|
||||
|
||||
class Bomb(Item):
|
||||
"""
|
||||
@ -82,3 +96,10 @@ class Bomb(Item):
|
||||
if abs(e.x - self.x) + abs(e.y - self.y) <= 1 and \
|
||||
isinstance(e, FightingEntity):
|
||||
e.take_damage(self, self.damage)
|
||||
|
||||
def save_state(self) -> None:
|
||||
"""
|
||||
Saves the state of the entity into a dictionary
|
||||
"""
|
||||
d = super().save_state()
|
||||
d["type"] = "Bomb"
|
||||
|
Reference in New Issue
Block a user