"""TES3MP world adapter — stub for Morrowind multiplayer via TES3MP.

This adapter will eventually connect to a TES3MP server and translate
the WorldInterface contract into TES3MP commands.  For now every method
raises ``NotImplementedError`` with guidance on what needs wiring up.

Once PR #864 merges, import PerceptionOutput and CommandInput directly
from ``infrastructure.morrowind.schemas`` if their shapes differ from
the canonical types in ``infrastructure.world.types``.
"""

from __future__ import annotations

import logging

from infrastructure.world.interface import WorldInterface
from infrastructure.world.types import ActionResult, CommandInput, PerceptionOutput

logger = logging.getLogger(__name__)


class TES3MPWorldAdapter(WorldInterface):
    """Stub adapter for TES3MP (Morrowind multiplayer).

    All core methods raise ``NotImplementedError``.
    Implement ``connect()`` first — it should open a socket to the
    TES3MP server and authenticate.
    """

    def __init__(self, *, host: str = "localhost", port: int = 25565) -> None:
        self._host = host
        self._port = port
        self._connected = False

    # -- lifecycle ---------------------------------------------------------

    def connect(self) -> None:
        raise NotImplementedError("TES3MPWorldAdapter.connect() — wire up TES3MP server socket")

    def disconnect(self) -> None:
        raise NotImplementedError("TES3MPWorldAdapter.disconnect() — close TES3MP server socket")

    @property
    def is_connected(self) -> bool:
        return self._connected

    # -- core contract (stubs) ---------------------------------------------

    def observe(self) -> PerceptionOutput:
        raise NotImplementedError("TES3MPWorldAdapter.observe() — poll TES3MP for player/NPC state")

    def act(self, command: CommandInput) -> ActionResult:
        raise NotImplementedError(
            "TES3MPWorldAdapter.act() — translate CommandInput to TES3MP packet"
        )

    def speak(self, message: str, target: str | None = None) -> None:
        raise NotImplementedError("TES3MPWorldAdapter.speak() — send chat message via TES3MP")
