store what snake win the game

This commit is contained in:
2024-04-13 02:37:05 +02:00
parent 0027476c4e
commit 74b1e79a90
2 changed files with 10 additions and 2 deletions
+2 -1
View File
@@ -94,9 +94,10 @@ class Server:
def _end(self, game_state:dict):
if self.store_game_state:
self.game_state_storage.add_end_state(game_state["board"], self.snake.get_history())
self.game_state_storage.set_winner_snake_name(game_state["board"]['snakes'])
self.game_state_storage.save(
f"{self.snake.__class__.__name__}_{datetime.now().strftime('%d.%m.%Y_%H%M%S')}_{game_state['game']['id']}.json",
callback=json.dump, indent=2, ensure_ascii=False
)
print("GAME OVER\n")
print("GAME OVER:\n- Winner is", [ x["name"] for x in game_state["board"]['snakes']])