change load function to use Config stored variables
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ class Map:
|
|||||||
def load_from_file(cls, file_options):
|
def load_from_file(cls, file_options):
|
||||||
LOGGING.debug(f"Loading from file: {file_options}")
|
LOGGING.debug(f"Loading from file: {file_options}")
|
||||||
if os.path.exists(file_options["path"]):
|
if os.path.exists(file_options["path"]):
|
||||||
with open(file_options["path"], "rb") as f:
|
with open(f'{file_options["path"]}/{file_options["name"]}', "rb") as f:
|
||||||
data = my_pickle.load(f, file_options['compression'], None)
|
data = my_pickle.load(f, file_options['compression'], None)
|
||||||
|
|
||||||
new_class = cls(file_options["path"])
|
new_class = cls(file_options["path"])
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class SavedState:
|
|||||||
def load_from_file(cls, file_options):
|
def load_from_file(cls, file_options):
|
||||||
LOGGING.debug(f"Loading from file: {file_options}")
|
LOGGING.debug(f"Loading from file: {file_options}")
|
||||||
if os.path.exists(file_options["path"]):
|
if os.path.exists(file_options["path"]):
|
||||||
with open(file_options["path"], "rb") as f:
|
with open(f'{file_options["path"]}/{file_options["name"]}', "rb") as f:
|
||||||
data = my_pickle.load(f, file_options['compression'], None)
|
data = my_pickle.load(f, file_options['compression'], None)
|
||||||
|
|
||||||
new_class = cls()
|
new_class = cls()
|
||||||
|
|||||||
+8
-4
@@ -1,13 +1,17 @@
|
|||||||
{
|
{
|
||||||
"map_file": {
|
"file": {
|
||||||
|
"map": {
|
||||||
"path": "./GameData",
|
"path": "./GameData",
|
||||||
"filename": "map.pkl.lzma.encrypted",
|
"name": "map",
|
||||||
|
"extension": "pkl.lzma.encrypted",
|
||||||
"encryption_key": ""
|
"encryption_key": ""
|
||||||
},
|
},
|
||||||
"save_file": {
|
"save": {
|
||||||
"path": "./GameData/Save",
|
"path": "./GameData/Save",
|
||||||
"filename": "The-Adventure-AutoSaveGame.pkl.lzma.encrypted",
|
"name": "The-Adventure-AutoSaveGame",
|
||||||
|
"extension": "pkl.lzma.encrypted",
|
||||||
"encryption_key": ""
|
"encryption_key": ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"logging": {
|
"logging": {
|
||||||
|
|||||||
+1
-1
Submodule my_helpers updated: 5a047d7e00...77c5712eda
@@ -13,16 +13,8 @@ if __name__ == '__main__':
|
|||||||
logging.basicConfig(filename=f"{CONFIG['logging']['file']['path']}/{CONFIG['logging']['file']['name']}", encoding='utf-8', level=logging.DEBUG)
|
logging.basicConfig(filename=f"{CONFIG['logging']['file']['path']}/{CONFIG['logging']['file']['name']}", encoding='utf-8', level=logging.DEBUG)
|
||||||
LOGGING = logging.getLogger(__name__)
|
LOGGING = logging.getLogger(__name__)
|
||||||
|
|
||||||
SAVE_STATE_FILE = {
|
SAVE_STATE_FILE = CONFIG.get_file_path("file/save", add_to_dictionary={"compression": lzma, "key": CONFIG['file']["save"]["encryption_key"]})
|
||||||
"path": f"{CONFIG['save_file']['path']}/{CONFIG['save_file']['filename']}",
|
MAP_FILE = CONFIG.get_file_path("file/map", add_to_dictionary={"compression": lzma, "key": CONFIG['file']["map"]["encryption_key"]})
|
||||||
"compression": lzma,
|
|
||||||
"key": CONFIG["save_file"]["encryption_key"]
|
|
||||||
}
|
|
||||||
MAP_FILE = {
|
|
||||||
"path": f"{CONFIG['map_file']['path']}/{CONFIG['map_file']['filename']}",
|
|
||||||
"compression": lzma,
|
|
||||||
"key": CONFIG["map_file"]["encryption_key"]
|
|
||||||
}
|
|
||||||
|
|
||||||
game_board = GameBoard(CONFIG, SAVE_STATE_FILE, MAP_FILE)
|
game_board = GameBoard(CONFIG, SAVE_STATE_FILE, MAP_FILE)
|
||||||
game_board.find_game_state(store_state=not DEBUG)
|
game_board.find_game_state(store_state=not DEBUG)
|
||||||
|
|||||||
Reference in New Issue
Block a user