Replace tiles when loading map from a save file

This commit is contained in:
Yohann D'ANELLO 2020-11-18 15:02:30 +01:00
parent 20aeb5fd4a
commit 5a65957574

View File

@ -79,7 +79,7 @@ class Map:
return Map(width, height, tiles, start_y, start_x)
@staticmethod
def load_dungeon_from_string(content: str) -> "Map":
def load_dungeon_from_string(content: str) -> List[List["Tile"]]:
"""
Transforms a string into the list of corresponding tiles
"""
@ -121,7 +121,7 @@ class Map:
def save_state(self) -> dict:
"""
Saves the map's attributes to a dictionnary
Saves the map's attributes to a dictionary
"""
d = dict()
d["width"] = self.width
@ -137,7 +137,7 @@ class Map:
def load_state(self, d: dict) -> None:
"""
Loads the map's attributes from a dictionnary
Loads the map's attributes from a dictionary
"""
self.width = d["width"]
self.height = d["height"]
@ -145,7 +145,7 @@ class Map:
self.start_x = d["start_x"]
self.currentx = d["currentx"]
self.currenty = d["currenty"]
self.map = self.load_dungeon_from_string(d["map"])
self.tiles = self.load_dungeon_from_string(d["map"])
# add entities