#!/usr/bin/env python3
"""Verify server-authoritative fire spread 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: [
        "GrassFireIntensity",
        "ForestFireIntensity",
        "StructureFireIntensity",
        "ActiveFireSpreadRadius",
        "BaseFireSpreadRadius",
        "MaxFireSpreadRadius",
        "FireSpreadIntensityPerSecond",
        "FireSuppressionPressure",
        "UpdateServerAuthoritativeFireSpread",
        "GetFireSpreadWeatherMultiplier",
        "GetActiveBurningFuelScore",
    ],
    FIRE_CPP: [
        "DOREPLIFETIME(AAgrarianCampfire, GrassFireIntensity)",
        "DOREPLIFETIME(AAgrarianCampfire, ForestFireIntensity)",
        "DOREPLIFETIME(AAgrarianCampfire, StructureFireIntensity)",
        "DOREPLIFETIME(AAgrarianCampfire, ActiveFireSpreadRadius)",
        "UpdateServerAuthoritativeFireSpread(DeltaSeconds);",
        "AAgrarianCampfire::UpdateServerAuthoritativeFireSpread",
        "if (!HasAuthority())",
        "FireSuppressionPressure",
        "GetFireSpreadWeatherMultiplier()",
        "GetActiveBurningFuelScore()",
        "ActiveFireSpreadRadius = FMath::Clamp",
        "grass_fire_intensity",
        "active_fire_spread_radius",
    ],
    TDD: [
        "Active fire spread is still server-authoritative",
        "replicated fire intensities",
        "active spread radius",
        "suppression-pressure hook",
    ],
    ROADMAP: [
        "[x] Add server-authoritative fire spread rules",
    ],
}


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: server-authoritative fire spread state is implemented.")


if __name__ == "__main__":
    main()
