from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]


def require(path: Path, snippet: str) -> None:
    text = path.read_text(encoding="utf-8")
    if snippet not in text:
        raise SystemExit(f"{path.relative_to(ROOT)} missing {snippet!r}")


def main() -> None:
    types = ROOT / "Source" / "AgrarianGame" / "AgrarianTypes.h"
    survival_h = ROOT / "Source" / "AgrarianGame" / "AgrarianSurvivalComponent.h"
    survival_cpp = ROOT / "Source" / "AgrarianGame" / "AgrarianSurvivalComponent.cpp"
    character_cpp = ROOT / "Source" / "AgrarianGame" / "AgrarianGameCharacter.cpp"
    hud = ROOT / "Source" / "AgrarianGame" / "AgrarianDebugHUD.cpp"
    controller = ROOT / "Source" / "AgrarianGame" / "AgrarianGamePlayerController.cpp"
    roadmap = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"

    require(types, "float SprainSeverity = 0.0f;")
    require(survival_h, "float SprainExhaustionPerSecond = 0.03f;")
    require(survival_h, "void AddSprain(float Severity);")
    require(survival_h, "void ReduceSprain(float Amount);")
    require(survival_cpp, "Survival.SprainSeverity += PositiveSeverity * 0.20f;")
    require(survival_cpp, "Survival.Exhaustion += SprainExhaustionPerSecond * SprainRatio * DeltaTime;")
    require(survival_cpp, "void UAgrarianSurvivalComponent::AddSprain")
    require(survival_cpp, "void UAgrarianSurvivalComponent::ReduceSprain")
    require(survival_cpp, "Survival.SprainSeverity = FMath::Clamp(Survival.SprainSeverity, 0.0f, 100.0f);")
    require(character_cpp, "const float SprainMultiplier = FMath::GetMappedRangeValueClamped")
    require(character_cpp, "InjuryMultiplier * SprainMultiplier * SicknessMultiplier")
    require(hud, "Sprain")
    require(controller, "Sprain %.1f")
    require(roadmap, "[x] Add sprain or movement penalty placeholder.")

    print("PASS: sprain movement placeholder is present.")


if __name__ == "__main__":
    main()
