add path to GameStorage and add option to enable store game state (default its disabled)

This commit is contained in:
2024-04-13 01:09:26 +02:00
parent 91e0d8fd1b
commit b3d98dbdeb
2 changed files with 23 additions and 8 deletions
+4 -2
View File
@@ -1,8 +1,10 @@
from server.Files import save_file
import os
class GameStorage:
def __init__(self, snake:str):
def __init__(self, snake:str, path:str):
self.snake_type = snake
self.folder = path
def start_new_game(self, game_type:dict, game_board:dict, snake:dict):
self.game_type = game_type
@@ -19,7 +21,7 @@ class GameStorage:
self.snake_history = snake_history_state
def save(self, path:str, callback=None, **kwargs):
save_file(path, {
save_file(os.path.join(self.folder, path), {
"snake": {
"type": self.snake_type,
"choices": self.snake_history,