#!/usr/bin/env python3
"""Verify first MVP male/female playable character proxy setup."""

from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
CONTROLLER_H = ROOT / "Source" / "AgrarianGame" / "AgrarianGamePlayerController.h"
CONTROLLER_CPP = ROOT / "Source" / "AgrarianGame" / "AgrarianGamePlayerController.cpp"
FRONTEND_CPP = ROOT / "Source" / "AgrarianGame" / "AgrarianMvpFrontendWidget.cpp"
CONFIG = ROOT / "Config" / "DefaultGame.ini"
DOC = ROOT / "Docs" / "Characters" / "MvpCharacterProxies.md"
SETUP = ROOT / "Scripts" / "setup_mvp_character_proxies.py"
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"


def require(condition: bool, message: str) -> None:
    if not condition:
        raise SystemExit(f"FAILED: {message}")


def main() -> None:
    controller_h = CONTROLLER_H.read_text(encoding="utf-8")
    controller = CONTROLLER_CPP.read_text(encoding="utf-8")
    frontend = FRONTEND_CPP.read_text(encoding="utf-8")
    config = CONFIG.read_text(encoding="utf-8")
    doc = DOC.read_text(encoding="utf-8")
    setup = SETUP.read_text(encoding="utf-8")
    roadmap = ROADMAP.read_text(encoding="utf-8")

    for token in (
        "ApplyMvpCharacterProxyToPawn",
        "SelectedMvpCharacterProxyId",
    ):
        require(token in controller_h, f"controller header missing {token}")

    for token in (
        "SKM_Manny_Simple",
        "SKM_Quinn_Simple",
        "M_AGR_CharacterProxy_Workwear_Male",
        "M_AGR_CharacterProxy_Workwear_Female",
        "SetSkeletalMesh",
        "SetMaterial",
        "MvpWorkwearTorsoProxy",
        "MvpWorkwearBackpackProxy",
        "MvpWorkwearBedrollProxy",
        "MvpWorkwearBootsProxy",
        "EnsureMvpPresentationComponent",
        "SelectedMvpCharacterProxyId = TEXT(\"male\")",
        "SelectedMvpCharacterProxyId = TEXT(\"female\")",
        "ApplyMvpCharacterProxyToPawn();",
    ):
        require(token in controller, f"controller implementation missing {token}")

    for token in (
        "AgrarianSelectCharacter female",
        "AgrarianSelectCharacter male",
        "practical workwear proxy",
    ):
        require(token in frontend, f"frontend character proxy flow missing {token}")

    for token in (
        "M_AGR_CharacterProxy_Workwear_Male",
        "M_AGR_CharacterProxy_Workwear_Female",
        "MaterialFactoryNew",
        "MP_BASE_COLOR",
        "MP_ROUGHNESS",
    ):
        require(token in setup, f"setup script missing {token}")

    require(
        '+DirectoriesToAlwaysCook=(Path="/Game/Agrarian/Characters")' in config,
        "character proxy folder is not always cooked",
    )

    for token in (
        "SKM_Manny_Simple",
        "SKM_Quinn_Simple",
        "not final production humans",
        "Final character work should replace these proxies",
    ):
        require(token in doc, f"character proxy doc missing {token}")

    require(
        "- [x] Add first realistic playable character proxies for the selected young adult male and female archetypes" in roadmap,
        "0.1.O character proxy roadmap item is not checked off",
    )

    print("OK: MVP male/female playable character proxy flow is wired and documented.")


if __name__ == "__main__":
    main()
