Files
board-mate/rpi/services/game_service.py
2025-12-31 17:11:43 +01:00

28 lines
867 B
Python

from services.clock_service import ClockService
from services.detection_service import DetectionService
class GameService:
detection_service : DetectionService
clock_service : ClockService
def __init__(self):
self.detection_service = DetectionService()
self.clock_service = ClockService()
def start(self, white_name, back_name, time_control : int, increment : int ) -> None:
self.clock_service.start(time_control, increment)
self.clock_service.set_on_terminated(self.stop)
def stop(self):
self.clock_service.stop()
self.detection_service.stop()
def make_move(self) -> tuple[bytes, str] | None:
try :
self.clock_service.switch()
return self.detection_service.analyze_single_frame()
except Exception as e:
print(e)
return None