from pathlib import Path


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

REQUIRED = {
    ROOT / "Source" / "AgrarianGame" / "AgrarianCampfire.h": [
        "bool bCookingPlaceholderEnabled = true;",
        "float CookingSecondsRequired = 30.0f;",
        "float CookingProgressSeconds = 0.0f;",
        "bool CanCook() const;",
        "float GetCookingProgressRatio() const;",
    ],
    ROOT / "Source" / "AgrarianGame" / "AgrarianCampfire.cpp": [
        "DOREPLIFETIME(AAgrarianCampfire, bCookingPlaceholderEnabled);",
        "DOREPLIFETIME(AAgrarianCampfire, CookingSecondsRequired);",
        "DOREPLIFETIME(AAgrarianCampfire, CookingProgressSeconds);",
        "CookingProgressSeconds = FMath::Min(CookingSecondsRequired, CookingProgressSeconds + DeltaSeconds);",
        "bool AAgrarianCampfire::CanCook() const",
        "float AAgrarianCampfire::GetCookingProgressRatio() const",
    ],
    ROOT / "Scripts" / "setup_playable_blueprints.py": [
        "def set_default_property(cdo, property_name, value):",
        "property_names.append(f\"b_{property_name}\")",
        "property_names.append(\"b\" + \"\".join(part.capitalize() for part in property_name.split(\"_\")))",
    ],
    ROOT / "Scripts" / "verify_playable_blueprints.py": [
        "def get_property(cdo, property_name, expected_value):",
        "property_names.append(f\"b_{property_name}\")",
        "property_names.append(\"b\" + \"\".join(part.capitalize() for part in property_name.split(\"_\")))",
    ],
    ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
        "- [x] Add cooking placeholder if needed.",
    ],
    ROOT / "Docs" / "TechnicalDesignDocument.md": [
        "minimal replicated cooking placeholder",
    ],
}


def main():
    missing = []
    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("Campfire cooking placeholder verification failed:\n" + "\n".join(missing))

    print("PASS: campfire cooking placeholder is implemented and documented.")


if __name__ == "__main__":
    main()
