#!/usr/bin/env python3
"""Verify shelter/structure ignition risk is tracked from nearby flammable actors."""

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: [
        "StructureIgnitionRiskScore",
        "bStructureIgnited",
        "StructureIgnitionCheckRadius",
        "StructureIgnitionFuelScoreThreshold",
        "StructureIgnitionRiskPerSecond",
        "UpdateStructureIgnitionRisk",
        "GetStructureFuelScoreNearFire",
    ],
    FIRE_CPP: [
        "#include \"AgrarianResourceNode.h\"",
        "#include \"AgrarianShelterActor.h\"",
        "DOREPLIFETIME(AAgrarianCampfire, StructureIgnitionRiskScore)",
        "DOREPLIFETIME(AAgrarianCampfire, bStructureIgnited)",
        "UpdateStructureIgnitionRisk(DeltaSeconds);",
        "AAgrarianCampfire::UpdateStructureIgnitionRisk",
        "AAgrarianCampfire::GetStructureFuelScoreNearFire",
        "AAgrarianShelterActor::StaticClass()",
        "AAgrarianResourceNode::StaticClass()",
        "YieldId == TEXT(\"wood\") || YieldId == TEXT(\"fiber\")",
        "bFireContained",
        "bStructureIgnited = StructureIgnitionRiskScore >= 100.0f",
        "structure_ignition_risk_score",
        "structure_ignited",
    ],
    TDD: [
        "Structure ignition risk uses the same server-authoritative campfire risk model",
        "primitive shelters",
        "flammable wood/fiber resource",
        "structure ignition flag",
    ],
    ROADMAP: [
        "[x] Add shelter/structure ignition risk",
    ],
}


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: structure ignition risk checks are wired to nearby flammable actors.")


if __name__ == "__main__":
    main()
