#!/usr/bin/env python3
"""Verify MVP frontend volume sliders are present."""

from pathlib import Path


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

REQUIRED = {
    UI_H: [
        "class USlider;",
        "float MasterVolume",
        "float AmbientVolume",
        "float WeatherVolume",
        "float EffectsVolume",
        "float WildlifeVolume",
        "float UiVolume",
        "USlider* AddVolumeSlider",
        "void HandleMasterVolumeChanged(float Value);",
        "void HandleUiVolumeChanged(float Value);",
    ],
    UI_CPP: [
        "#include \"Components/Slider.h\"",
        "AddVolumeSlider(Panel, FText::FromString(TEXT(\"Master\"))",
        "AddVolumeSlider(Panel, FText::FromString(TEXT(\"Ambient\"))",
        "AddVolumeSlider(Panel, FText::FromString(TEXT(\"Weather\"))",
        "AddVolumeSlider(Panel, FText::FromString(TEXT(\"Effects\"))",
        "AddVolumeSlider(Panel, FText::FromString(TEXT(\"Wildlife\"))",
        "AddVolumeSlider(Panel, FText::FromString(TEXT(\"UI\"))",
        "Slider->OnValueChanged.AddDynamic",
        "UGameplayStatics::PlaySound2D(this, Sound, FMath::Clamp(MasterVolume * UiVolume",
        "UAgrarianMvpFrontendWidget::HandleMasterVolumeChanged",
        "UAgrarianMvpFrontendWidget::HandleUiVolumeChanged",
    ],
    TDD: [
        "volume sliders for master, ambient, weather",
        "apply the UI bus to frontend sounds immediately",
        "SoundClass",
    ],
    ROADMAP: [
        "[x] Add volume sliders.",
    ],
}


def main() -> None:
    missing = []
    for path, snippets in REQUIRED.items():
        text = path.read_text(encoding="utf-8")
        for snippet in snippets:
            if snippet not in text:
                missing.append(f"{path.relative_to(ROOT)} missing {snippet!r}")
    if missing:
        raise SystemExit("FAILED: " + "; ".join(missing))
    print("OK: MVP frontend volume sliders are present.")


if __name__ == "__main__":
    main()
