from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
TYPES_H = ROOT / "Source" / "AgrarianGame" / "AgrarianTypes.h"
GAME_STATE_H = ROOT / "Source" / "AgrarianGame" / "AgrarianGameState.h"
GAME_STATE_CPP = ROOT / "Source" / "AgrarianGame" / "AgrarianGameState.cpp"
PROVIDER_H = ROOT / "Source" / "AgrarianGame" / "AgrarianWeatherProviderSubsystem.h"
PROVIDER_CPP = ROOT / "Source" / "AgrarianGame" / "AgrarianWeatherProviderSubsystem.cpp"
TDD = ROOT / "Docs" / "TechnicalDesignDocument.md"
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"


EXPECTED = {
    TYPES_H: [
        "FAgrarianMappedWeatherInputs",
        "TemperatureC",
        "PrecipitationMm",
        "WindSpeedKmh",
        "CloudCoverPercent",
        "RelativeHumidityPercent",
        "PressureMslHpa",
        "VisibilityMeters",
        "ProviderWeatherCode",
    ],
    GAME_STATE_H: [
        "FAgrarianMappedWeatherInputs ActiveWeatherInputs",
        "ApplyMappedWeatherInputs",
    ],
    GAME_STATE_CPP: [
        "DOREPLIFETIME(AAgrarianGameState, ActiveWeatherInputs);",
        "void AAgrarianGameState::ApplyMappedWeatherInputs",
        "SetRegionalTemperatureProfile",
        "SetRegionalObservedTemperature",
        "SetWeather(ActiveWeatherInputs.MappedWeather)",
    ],
    PROVIDER_H: [
        "VisibilityMeters",
        "MapSnapshotToAgrarianWeatherInputs",
    ],
    PROVIDER_CPP: [
        "FAgrarianMappedWeatherInputs UAgrarianWeatherProviderSubsystem::MapSnapshotToAgrarianWeatherInputs",
        "GameState->ApplyMappedWeatherInputs",
        "OutSnapshot.VisibilityMeters",
        "relativeHumidity",
        "skyCover",
        "pressure",
        "visibility",
    ],
    TDD: [
        "Real-weather provider values are mapped into `FAgrarianMappedWeatherInputs`",
        "weather code available alongside the collapsed Agrarian weather state",
    ],
    ROADMAP: [
        "[x] Map real weather inputs into Agrarian weather states: temperature, precipitation, wind, cloud cover, humidity, pressure, visibility, and weather code.",
    ],
}


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 input mapping verification failed: " + "; ".join(missing))
    print("Agrarian weather input mapping verification complete.")


if __name__ == "__main__":
    main()
