This commit is contained in:
Yohann D'ANELLO
2020-11-18 14:56:59 +01:00
parent be6c949b18
commit 958dcdfee0
5 changed files with 20 additions and 16 deletions

View File

@ -146,7 +146,8 @@ class Map:
self.currentx = d["currentx"]
self.currenty = d["currenty"]
self.map = self.load_dungeon_from_string(d["map"])
#add entities
# add entities
class Tile(Enum):
"""
@ -168,7 +169,8 @@ class Tile(Enum):
def char(self, pack: TexturePack) -> str:
"""
Translates a Tile to the corresponding character according to the texture pack
Translates a Tile to the corresponding character according
to the texture pack
"""
return getattr(pack, self.name)
@ -300,7 +302,7 @@ class Entity:
d["y"] = self.y
return d
def recover_state(self, d : dict) -> None:
def recover_state(self, d: dict) -> None:
"""
Loads the coordinates of the entity from a dictionnary
"""
@ -364,18 +366,19 @@ class FightingEntity(Entity):
"""
Returns a fighting entities specific attributes
"""
return ["maxhealth", "health", "level", "dead", "strength", "intelligence", "charisma", "dexterity", "constitution"]
return ["maxhealth", "health", "level", "dead", "strength",
"intelligence", "charisma", "dexterity", "constitution"]
def save_state(self) -> dict:
"""
Saves the state of the entity into a dictionnary
Saves the state of the entity into a dictionary
"""
d = super().save_state()
for name in self.keys():
d[name] = self.__getattribute__(name)
return d
def recover_state(self, d : dict) -> None:
def recover_state(self, d: dict) -> None:
"""
Loads the state of an entity from a dictionary
"""