Write and load settings at the start of the game

This commit is contained in:
Yohann D'ANELLO
2020-11-06 14:59:27 +01:00
parent af363dabfe
commit 5ca2827706
2 changed files with 9 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import json
import os
from typing import Any, Generator
@ -64,14 +65,15 @@ class Settings:
d = dict()
for key in self.settings_keys:
d[key] = getattr(self, key)
return json.dumps(d)
return json.dumps(d, indent=4)
def load_settings(self) -> None:
"""
Loads the settings from a file
"""
with open("settings.json", "r") as f:
self.loads_from_string(f.read())
if os.path.isfile("settings.json"):
with open("settings.json", "r") as f:
self.loads_from_string(f.read())
def write_settings(self) -> None:
"""