#!/usr/bin/env python3
"""Verify unattended and poorly maintained campfire risk state exists."""

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: [
        "float FireRiskScore",
        "float LitDurationSeconds",
        "float SecondsSinceMaintenance",
        "bool bFireAreaCleared",
        "bool bFireContained",
        "float UnmaintainedRiskDelaySeconds",
        "float PoorMaintenanceRiskPerSecond",
        "float HighFuelRiskThresholdSeconds",
        "void MaintainFire(bool bClearArea, bool bContainFire);",
        "float GetFireRiskRatio() const;",
        "void UpdateFireRisk(float DeltaSeconds);",
        "float GetFireRiskGrowthPerSecond() const;",
    ],
    FIRE_CPP: [
        "DOREPLIFETIME(AAgrarianCampfire, FireRiskScore)",
        "DOREPLIFETIME(AAgrarianCampfire, LitDurationSeconds)",
        "DOREPLIFETIME(AAgrarianCampfire, SecondsSinceMaintenance)",
        "DOREPLIFETIME(AAgrarianCampfire, bFireAreaCleared)",
        "DOREPLIFETIME(AAgrarianCampfire, bFireContained)",
        "UpdateFireRisk(DeltaSeconds);",
        "AAgrarianCampfire::MaintainFire",
        "AAgrarianCampfire::GetFireRiskGrowthPerSecond",
        "SecondsSinceMaintenance >= UnmaintainedRiskDelaySeconds",
        "FuelSeconds >= HighFuelRiskThresholdSeconds",
        "IsWetWeatherActive()",
        "fire_risk_score",
        "seconds_since_maintenance",
    ],
    TDD: [
        "unattended and poorly maintained fire risk",
        "`FireRiskScore`",
        "Risk grows after a fire has been left unattended",
    ],
    ROADMAP: [
        "[x] Add unattended and poorly maintained fire 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: unattended campfire risk state is implemented and replicated.")


if __name__ == "__main__":
    main()
