#!/usr/bin/env python3
"""Verify the MVP packaged-client launch 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"
PACKAGE_BAT = ROOT / "Scripts" / "PackageWindowsDevelopment.bat"
LAUNCHERS_BAT = ROOT / "Scripts" / "InstallWindowsDemoLaunchers.bat"
VISUAL_QA_BAT = ROOT / "Scripts" / "RunWindowsInvestorVisualQACheck.bat"

REQUIRED = {
    QA_DOC: [
        "## Packaged Client Launch",
        "Scripts/PackageWindowsDevelopment.bat",
        "Builds/WindowsDevelopment/AgrarianGame.exe",
        "Start Agrarian Demo.cmd",
        "Start Agrarian Demo - DX12.cmd",
        "Start Agrarian Demo - Compatibility DX11.cmd",
        "Scripts/RunWindowsInvestorVisualQACheck.bat --check-tools",
        "client-only",
    ],
    PACKAGE_BAT: [
        "Builds\\WindowsDevelopment",
        "InstallWindowsDemoLaunchers.bat",
        "BuildCookRun",
    ],
    LAUNCHERS_BAT: [
        "Start Agrarian Demo.cmd",
        "Start Agrarian Demo - DX12.cmd",
        "Start Agrarian Demo - Compatibility DX11.cmd",
    ],
    VISUAL_QA_BAT: [
        "AgrarianGame.exe",
        "SunshineService",
        "--check-tools",
        "READY: packaged demo exists and SunshineService is running.",
    ],
    ROADMAP: [
        "[x] Can launch packaged client.",
    ],
}


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: packaged-client launch QA gate is documented and scripted.")


if __name__ == "__main__":
    main()
