from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]


def require(path: Path, snippet: str) -> None:
    text = path.read_text(encoding="utf-8")
    if snippet not in text:
        raise SystemExit(f"{path.relative_to(ROOT)} missing {snippet!r}")


def main() -> None:
    header = ROOT / "Source" / "AgrarianGame" / "AgrarianGamePlayerController.h"
    source = ROOT / "Source" / "AgrarianGame" / "AgrarianGamePlayerController.cpp"
    roadmap = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"

    require(header, "void AgrarianRespawn();")
    require(header, "void ServerAgrarianRespawn();")
    require(source, "void AAgrarianGamePlayerController::AgrarianRespawn()")
    require(source, "void AAgrarianGamePlayerController::ServerAgrarianRespawn_Implementation()")
    require(source, "if (!SurvivalComponent->IsDead())")
    require(source, "AgrarianRespawn is only available after death")
    require(source, "StopMovementImmediately();")
    require(source, "SetActorLocation(GroundZeroDeveloperTravelHomeLocation")
    require(source, "SurvivalComponent->Revive(60.0f);")
    require(source, "SurvivalComponent->ReduceBleeding(100.0f);")
    require(source, "SurvivalComponent->ReduceSprain(100.0f);")
    require(source, "Agrarian MVP respawn complete")
    require(roadmap, "[x] Add respawn rules for MVP.")

    print("PASS: MVP respawn rules are present.")


if __name__ == "__main__":
    main()
