from pathlib import Path


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


EXPECTED = {
    HEADER: [
        "bEnableDeterministicFallbackWeather",
        "ApplyDeterministicFallbackWeather",
        "BuildDeterministicFallbackSnapshot",
        "GetDeterministicWeatherNoise",
    ],
    CPP: [
        "return ApplyDeterministicFallbackWeather(TileId, Latitude, Longitude, GameState);",
        "Provider = TEXT(\"deterministic-fallback\")",
        "GetDeterministicWeatherNoise(TileId, SafeDay",
        "Snapshot.PrecipitationMm",
        "Snapshot.VisibilityMeters",
        "CacheSnapshot(Snapshot, WeatherSnapshotCacheTtlSeconds);",
        "ApplyDeterministicFallbackWeather(TileId, Latitude, Longitude",
    ],
    TDD: [
        "Deterministic fallback weather",
        "tile ID and Agrarian day",
        "provider `deterministic-fallback`",
    ],
    ROADMAP: [
        "[x] Add deterministic fallback weather simulation when external weather data is unavailable.",
    ],
}


def main() -> None:
    missing = []
    for path, snippets in EXPECTED.items():
        text = path.read_text(encoding="utf-8")
        for snippet in snippets:
            if snippet not in text:
                missing.append(f"{path.relative_to(ROOT)}: {snippet}")
    if missing:
        raise RuntimeError("Deterministic weather fallback verification failed: " + "; ".join(missing))
    print("Agrarian deterministic weather fallback verification complete.")


if __name__ == "__main__":
    main()
