#!/usr/bin/env python3
"""Verify the MVP two-client connection QA gate is documented and scripted."""

from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"
QA_DOC = ROOT / "Docs" / "QA" / "MvpQaGates.md"
LATENCY_DOC = ROOT / "Docs" / "Ops" / "MultiplayerLatencyTestPlan.md"
SMOKE_BAT = ROOT / "Scripts" / "RunTwoClientConnectionSmoke-Windows.bat"

REQUIRED = {
    QA_DOC: [
        "## Two-Client Connection",
        "Scripts/RunTwoClientConnectionSmoke-Windows.bat --check-tools",
        "play.agrariangame.com:7777",
        "Both clients reach the same Ground Zero session",
        "Docs/Ops/MultiplayerLatencyTestPlan.md",
    ],
    LATENCY_DOC: [
        "Connect two packaged Windows clients.",
        "Confirm both clients see the same world time and weather.",
        "Core interactions eventually reconcile",
    ],
    SMOKE_BAT: [
        "Agrarian Client A",
        "Agrarian Client B",
        "play.agrariangame.com:7777",
        "--check-tools",
        "AgrarianGame.exe",
        "MultiplayerLatencyTestPlan.md",
    ],
    ROADMAP: [
        "[x] Can connect two clients.",
    ],
}


def main() -> None:
    missing: list[str] = []
    for path, snippets in REQUIRED.items():
        text = path.read_text(encoding="utf-8")
        for snippet in snippets:
            if snippet not in text:
                missing.append(f"{path.relative_to(ROOT)} missing {snippet!r}")
    if missing:
        raise SystemExit("FAILED: " + "; ".join(missing))
    print("OK: two-client connection QA gate is documented and scripted.")


if __name__ == "__main__":
    main()
