#!/usr/bin/env python3
"""Verify the packaged investor-demo visual QA evidence gate is documented."""

from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
DOC = ROOT / "Docs" / "Ops" / "PackagedDemoVisualQAEvidence.md"
STARTUP_DOC = ROOT / "Docs" / "Ops" / "PackagedClientGpuStartupVisualTest.md"
BAT = ROOT / "Scripts" / "RunWindowsInvestorVisualQACheck.bat"
STARTUP_BAT = ROOT / "Scripts" / "RunWindowsGpuStartupVisualCheck.bat"
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"

REQUIRED_LABELS = [
    "01-startup-credits",
    "02-character-selection",
    "03-first-spawn",
    "04-terrain",
    "05-vegetation",
    "06-water",
    "07-campfire",
    "08-shelter",
    "09-pause-menu",
    "10-save-quit",
]


def require(condition, message):
    if not condition:
        raise SystemExit(f"FAILED: {message}")


def main():
    doc = DOC.read_text(encoding="utf-8")
    startup_doc = STARTUP_DOC.read_text(encoding="utf-8")
    bat = BAT.read_text(encoding="utf-8")
    startup_bat = STARTUP_BAT.read_text(encoding="utf-8")
    roadmap = ROADMAP.read_text(encoding="utf-8")

    for token in [
        "Sunshine plus Moonlight",
        "Saved\\VisualQA\\InvestorDemo",
        "visual-qa-summary.txt",
        "Do not commit raw captures to Git",
        "Default",
        "investor visual MVP ready",
    ]:
        require(token in doc, f"visual QA evidence doc missing {token!r}")

    for label in REQUIRED_LABELS:
        require(label in doc, f"visual QA evidence doc missing {label!r}")
        require(label in bat, f"Windows visual QA helper missing {label!r}")

    for token in [
        "08-terrain",
        "09-vegetation",
        "10-water",
        "11-campfire",
        "12-shelter",
    ]:
        require(token in startup_doc, f"startup GPU visual doc missing expanded label {token!r}")
        require(token in startup_bat, f"startup GPU visual helper missing expanded label {token!r}")

    require("SunshineService" in bat, "Windows visual QA helper must check SunshineService")
    require("--check-tools" in bat, "Windows visual QA helper must support --check-tools")
    require(
        "[x] Add packaged-demo visual QA screenshots or short clips" in roadmap,
        "0.1.O packaged-demo visual QA evidence roadmap item is not checked off",
    )

    print("OK: packaged investor-demo visual QA evidence gate is documented and scripted.")


if __name__ == "__main__":
    main()
