make new LocalStorage Class and move save functions into it

This commit is contained in:
2024-05-05 17:02:18 +02:00
parent ef4dca447f
commit 83bcf4f194
3 changed files with 69 additions and 53 deletions
+3 -1
View File
@@ -2,6 +2,8 @@ from server.Files import read_file
from server.GameBoard import GameBoard
from server.SnakeBuilder import SnakeBuilder
from statestorage.LocalStorage import LocalStorage
from flask import Flask
from flask import request
import logging, json, os, re
@@ -133,8 +135,8 @@ class Server:
game_board = self._get_game_board(game_state, end=True)
if not game_board.get_winner() == "me" and not game_board.get_turn() <= self.store_game_when_win_and_moves_are_bigger_as:
game_board.save(
LocalStorage,
file_path=os.path.join(self.data_path, 'data'),
callback=json.dump, indent=2, ensure_ascii=False
)
print("GAME ENDED: Winner is", [ x["name"] for x in game_state["board"]['snakes']])