Add game export

This commit is contained in:
2026-01-05 11:34:00 +01:00
parent 5ec6f5a79c
commit d9e97b0939
4 changed files with 73 additions and 25 deletions

View File

@@ -2,19 +2,23 @@ import base64
import threading
import requests
from flask import jsonify, request
from flask import jsonify, request, Flask
from models.exceptions.ServiceException import ServiceException
from services.game_service import GameService
from services.mqtt_service import MQTTService
class GameController:
_game_service : GameService
_broker_service : MQTTService
_has_started : bool
_auth_token : str
def __init__(self, app):
def __init__(self, app : Flask, broker_service : MQTTService):
self._game_service = GameService()
self._broker_service = broker_service
self._register_routes(app)
self._auth_token = "0eed89e8-7625-4f8d-bf2a-0872aede0efb"
@@ -44,7 +48,12 @@ class GameController:
return jsonify({"status": "error", "message": f"An error occurred : {ex}"}), 500
def stop_game(self):
self._game_service.stop()
try :
game_data = self._game_service.export_game()
self._broker_service.publish("/customer/game/data", game_data, 2)
self._game_service.stop()
except Exception as ex:
print(ex)
def make_move(self):
try: