Write and load settings at the start of the game
This commit is contained in:
@ -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:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user