refactor(gameplay): delegate host transition events from service
All checks were successful
CI / test-and-quality (push) Successful in 3m35s
CI / test-and-quality (pull_request) Successful in 3m35s

This commit is contained in:
2026-03-17 13:43:44 +00:00
parent a102a72a77
commit 94f940e5d8
3 changed files with 185 additions and 15 deletions

View File

@@ -10,13 +10,11 @@ from django.views.decorators.http import require_GET, require_POST
from fupogfakta.models import Category, GameSession, Guess, LieAnswer, Player, Question, RoundConfig, RoundQuestion, ScoreEvent
from fupogfakta.payloads import (
build_finish_game_phase_event as _build_finish_game_phase_event,
build_finish_game_response as _build_finish_game_response,
build_leaderboard as _build_leaderboard,
build_lie_started_payload as _build_lie_started_payload,
build_reveal_payload as _build_reveal_payload,
build_scoreboard_phase_event as _build_scoreboard_phase_event,
build_start_next_round_phase_event as _build_start_next_round_phase_event,
build_start_next_round_response as _build_start_next_round_response,
)
from fupogfakta.services import (
@@ -917,15 +915,10 @@ def start_next_round(request: HttpRequest, code: str) -> JsonResponse:
return api_error(request, code=str(exc), status=400)
if transition.should_broadcast:
phase_event = _build_start_next_round_phase_event(
transition.session,
transition.round_config,
transition.round_question,
)
sync_broadcast_phase_event(
transition.session.code,
phase_event["name"],
phase_event["payload"],
transition.phase_event_name,
transition.phase_event_payload,
)
return JsonResponse(
@@ -955,11 +948,10 @@ def finish_game(request: HttpRequest, code: str) -> JsonResponse:
return api_error(request, code=str(exc), status=400)
if transition.should_broadcast:
phase_event = _build_finish_game_phase_event(transition.session)
sync_broadcast_phase_event(
transition.session.code,
phase_event["name"],
phase_event["payload"],
transition.phase_event_name,
transition.phase_event_payload,
)
return JsonResponse(_build_finish_game_response(transition.session))