#!/usr/bin/env python3
"""Verify fire maintenance gameplay hooks reduce fire risk."""

from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
FIRE_H = ROOT / "Source" / "AgrarianGame" / "AgrarianCampfire.h"
FIRE_CPP = ROOT / "Source" / "AgrarianGame" / "AgrarianCampfire.cpp"
TDD = ROOT / "Docs" / "TechnicalDesignDocument.md"
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"

REQUIRED = {
    FIRE_H: [
        "WatchedMaintenanceRiskReduction",
        "ClearedAreaRiskReduction",
        "ContainedFireRiskReduction",
        "void MaintainFire(bool bClearArea, bool bContainFire);",
        "void WatchFire();",
        "void ClearAreaAroundFire();",
        "void ContainFire();",
        "void ReduceFireRisks(float Amount);",
    ],
    FIRE_CPP: [
        "FText::FromString(TEXT(\"Maintain fire\"))",
        "WatchFire();",
        "AAgrarianCampfire::WatchFire",
        "AAgrarianCampfire::ClearAreaAroundFire",
        "AAgrarianCampfire::ContainFire",
        "AAgrarianCampfire::ReduceFireRisks",
        "FireRiskScore = FMath::Clamp(FireRiskScore - SafeAmount",
        "GrassIgnitionRiskScore = FMath::Clamp",
        "StructureIgnitionRiskScore = FMath::Clamp",
        "FireRiskScore = 0.0f;",
    ],
    TDD: [
        "Fire maintenance gameplay uses the same authority path",
        "clear the fire area",
        "contain the fire",
        "neglected fires continue accumulating",
    ],
    ROADMAP: [
        "[x] Add fire maintenance gameplay",
    ],
}


def main() -> None:
    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("FAILED: " + "; ".join(missing))
    print("OK: fire maintenance gameplay hooks reduce risk.")


if __name__ == "__main__":
    main()
