"""Service-specific test fixtures for Mantimon TCG.

This module extends the shared fixtures from tests/conftest.py with
service-test-specific helpers like GameState factories.

The db_session and redis_client fixtures are inherited from the parent conftest.
"""

from uuid import uuid4

import pytest

from app.core.config import RulesConfig
from app.core.enums import TurnPhase
from app.core.models.game_state import GameState, PlayerState

# =============================================================================
# GameState Factory
# =============================================================================


def create_test_game_state(
    game_id: str | None = None,
    turn_number: int = 1,
    phase: TurnPhase = TurnPhase.MAIN,
) -> GameState:
    """Create a minimal GameState for testing.

    Args:
        game_id: Optional game ID. Generated if not provided.
        turn_number: Turn number (default 1).
        phase: Turn phase (default MAIN).

    Returns:
        A minimal valid GameState for testing.
    """
    if game_id is None:
        game_id = str(uuid4())

    return GameState(
        game_id=game_id,
        rules=RulesConfig(),
        card_registry={},
        players={
            "player1": PlayerState(player_id="player1"),
            "player2": PlayerState(player_id="player2"),
        },
        current_player_id="player1",
        turn_number=turn_number,
        phase=phase,
        turn_order=["player1", "player2"],
    )


@pytest.fixture
def game_state() -> GameState:
    """Provide a test GameState."""
    return create_test_game_state()
