from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
SURVIVAL_H = ROOT / "Source" / "AgrarianGame" / "AgrarianSurvivalComponent.h"
SURVIVAL_CPP = ROOT / "Source" / "AgrarianGame" / "AgrarianSurvivalComponent.cpp"
SHELTER_H = ROOT / "Source" / "AgrarianGame" / "AgrarianShelterActor.h"
SHELTER_CPP = ROOT / "Source" / "AgrarianGame" / "AgrarianShelterActor.cpp"
DEBUG_HUD_CPP = ROOT / "Source" / "AgrarianGame" / "AgrarianDebugHUD.cpp"
TDD = ROOT / "Docs" / "TechnicalDesignDocument.md"
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"


EXPECTED = {
    SHELTER_H: [
        "TObjectPtr<UBoxComponent> ProtectionVolume;",
        "float WeatherProtection = 0.65f;",
    ],
    SHELTER_CPP: [
        "ProtectionVolume->SetBoxExtent",
        "ProtectionVolume->SetCollisionProfileName(TEXT(\"OverlapAllDynamic\"))",
    ],
    SURVIVAL_H: [
        "float CurrentWeatherProtection = 0.0f;",
        "float CalculateCurrentWeatherProtection() const;",
    ],
    SURVIVAL_CPP: [
        "#include \"AgrarianShelterActor.h\"",
        "DOREPLIFETIME(UAgrarianSurvivalComponent, CurrentWeatherProtection);",
        "CurrentWeatherProtection = CalculateCurrentWeatherProtection();",
        "CareHistory.ShelterQuality = FMath::FInterpTo",
        "ExposureProtectionMultiplier",
        "ColdDamagePerMinute * Minutes * (1.0f - FMath::Clamp(CurrentWeatherProtection",
        "Owner->GetOverlappingActors(OverlappingShelterActors, AAgrarianShelterActor::StaticClass());",
        "Shelter->ProtectionVolume->IsOverlappingActor(Owner)",
    ],
    DEBUG_HUD_CPP: [
        "Shelter   %3.0f%%",
        "Shelter: %.0f%%",
    ],
    TDD: [
        "Primitive shelters expose a replicated protection volume",
        "reduce ambient weather exposure and cold damage",
    ],
    ROADMAP: [
        "[x] Connect shelter to weather protection.",
    ],
}


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


if __name__ == "__main__":
    main()
