from pathlib import Path


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


EXPECTED = {
    GAME_STATE_H: [
        "RegionalDailyLowTemperatureC",
        "RegionalDailyHighTemperatureC",
        "RegionalObservedTemperatureC",
        "ObservedTemperatureBlend",
        "bHasRegionalObservedTemperature",
        "SetRegionalTemperatureProfile",
        "SetRegionalObservedTemperature",
        "GetClearSkyTemperatureForHour",
    ],
    GAME_STATE_CPP: [
        "GetWrappedHourDelta",
        "DOREPLIFETIME(AAgrarianGameState, RegionalDailyLowTemperatureC);",
        "DOREPLIFETIME(AAgrarianGameState, RegionalWeatherSource);",
        "void AAgrarianGameState::SetRegionalTemperatureProfile",
        "void AAgrarianGameState::SetRegionalObservedTemperature",
        "float AAgrarianGameState::GetClearSkyTemperatureForHour",
        "const float LowHour = bHasActiveTileSolarData ? SunriseHourLocal : 6.0f;",
        "const float HighHour = bHasActiveTileSolarData ? FMath::Fmod(SolarNoonHourLocal + 3.0f, 24.0f) : 14.0f;",
        "AmbientTemperatureC = FMath::Clamp(BaseTemperatureC + WeatherModifier, -80.0f, 70.0f);",
    ],
    TDD: [
        "Temperature is authoritative on `AAgrarianGameState`",
        "server-side weather adapter",
        "deterministic fallback",
    ],
    ROADMAP: [
        "[x] Add temperature curve by time of day.",
        "observed regional temperature blending",
    ],
}


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("Temperature curve verification failed: " + "; ".join(missing))
    print("Agrarian temperature curve verification complete.")


if __name__ == "__main__":
    main()
