#!/usr/bin/env python3
"""Verify MVP fire sound hooks follow authoritative campfire state."""

from pathlib import Path


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

REQUIRED = {
    FIRE_H: [
        "TObjectPtr<UAudioComponent> FireLoopAudioComponent;",
        "TObjectPtr<UAudioComponent> FireEventAudioComponent;",
        "TObjectPtr<USoundBase> FireLoopSound;",
        "TObjectPtr<USoundBase> IgniteSound;",
        "TObjectPtr<USoundBase> ExtinguishSound;",
        "UFUNCTION(NetMulticast, Unreliable)",
        "void MulticastPlayFireEventSound(bool bIgnited);",
    ],
    FIRE_CPP: [
        "#include \"Components/AudioComponent.h\"",
        "FireLoopAudioComponent = CreateDefaultSubobject<UAudioComponent>",
        "FireEventAudioComponent = CreateDefaultSubobject<UAudioComponent>",
        "FireLoopAudioComponent->bAllowSpatialization = true",
        "FireEventAudioComponent->bAllowSpatialization = true",
        "AAgrarianCampfire::MulticastPlayFireEventSound_Implementation",
        "MulticastPlayFireEventSound(bLit);",
        "FireLoopAudioComponent->Play();",
        "FireLoopAudioComponent->Stop();",
    ],
    TDD: [
        "Campfire audio is split between a persistent spatialized loop",
        "`FireLoopSound`",
        "`IgniteSound`",
        "`ExtinguishSound`",
    ],
    ROADMAP: [
        "[x] Add fire sounds.",
    ],
}


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: fire sound hooks follow authoritative campfire state.")


if __name__ == "__main__":
    main()
