from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]

EXPECTED = {
    ROOT / "Source" / "AgrarianGame" / "AgrarianSaveGame.h": [
        "EAgrarianWeatherType Weather = EAgrarianWeatherType::Clear;",
        "FAgrarianMappedWeatherInputs WeatherInputs;",
        "FAgrarianWeatherDebugSnapshot WeatherDebug;",
    ],
    ROOT / "Source" / "AgrarianGame" / "AgrarianPersistenceSubsystem.cpp": [
        "SaveGame->Weather = GameState->Weather;",
        "SaveGame->WeatherInputs = GameState->ActiveWeatherInputs;",
        "SaveGame->WeatherDebug = GameState->GetWeatherDebugSnapshot();",
        "if (SaveGame->WeatherInputs.bHasProviderData)",
        "GameState->ApplyMappedWeatherInputs(SaveGame->WeatherInputs);",
        "GameState->SetWeather(SaveGame->Weather);",
    ],
    ROOT / "Docs" / "PersistenceDesignDocument.md": [
        "`UAgrarianSaveGame::Weather`",
        "`WeatherInputs` and `WeatherDebug` snapshots",
        "reapplies the mapped weather inputs",
    ],
    ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
        "[x] Save weather seed/state.",
        "`UAgrarianSaveGame::Weather`",
        "provider `WeatherInputs`, and `WeatherDebug`",
    ],
}


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("Weather state persistence verification failed: " + "; ".join(missing))

    print("PASS: weather state persists with provider inputs and enum fallback.")


if __name__ == "__main__":
    main()
