from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
AUDIO_H = ROOT / "Source" / "AgrarianGame" / "AgrarianWeatherAudioController.h"
AUDIO_CPP = ROOT / "Source" / "AgrarianGame" / "AgrarianWeatherAudioController.cpp"
MAP_SETUP = ROOT / "Scripts" / "setup_ground_zero_demo_map.py"
TDD = ROOT / "Docs" / "TechnicalDesignDocument.md"
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"


EXPECTED = {
    AUDIO_H: [
        "class AAgrarianWeatherAudioController : public AActor",
        "TObjectPtr<UAudioComponent> AmbientAudio;",
        "TObjectPtr<UAudioComponent> RainAudio;",
        "TObjectPtr<UAudioComponent> WindAudio;",
        "TObjectPtr<UAudioComponent> StormAudio;",
        "TObjectPtr<USoundBase> RainLoopSound;",
        "void RefreshWeatherAudio(float DeltaSeconds);",
    ],
    AUDIO_CPP: [
        "#include \"AgrarianGameState.h\"",
        "#include \"Components/AudioComponent.h\"",
        "AmbientAudio = CreateDefaultSubobject<UAudioComponent>",
        "RainAudio = CreateDefaultSubobject<UAudioComponent>",
        "WindAudio = CreateDefaultSubobject<UAudioComponent>",
        "StormAudio = CreateDefaultSubobject<UAudioComponent>",
        "GameState->Weather",
        "GameState->ActiveWeatherInputs.WindSpeedKmh",
        "GameState->IsNight()",
        "ApplyComponentVolume(RainAudio, CurrentRainVolume);",
        "AudioComponent->SetVolumeMultiplier",
    ],
    MAP_SETUP: [
        "AGR_DemoWeatherAudioController",
        "unreal.AgrarianWeatherAudioController",
    ],
    TDD: [
        "`AAgrarianWeatherAudioController`",
        "ambient, rain, wind, and storm audio components",
    ],
    ROADMAP: [
        "[x] Add audio cues for weather.",
    ],
}


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


if __name__ == "__main__":
    main()
