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:
    controller = ROOT / "Source" / "AgrarianGame" / "AgrarianGamePlayerController.cpp"
    item_setup = ROOT / "Scripts" / "setup_item_definitions.py"
    item_verify = ROOT / "Scripts" / "verify_item_definitions.py"
    item_use_verify = ROOT / "Scripts" / "verify_item_use.py"
    tech_doc = ROOT / "Docs" / "TechnicalDesignDocument.md"
    roadmap = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"

    require(item_setup, '"item_id": "bandage"')
    require(item_setup, "unreal.AgrarianItemType.MEDICINE")
    require(item_verify, '"DA_Item_Bandage": ("bandage", unreal.AgrarianItemType.MEDICINE)')
    require(controller, 'ItemId == TEXT("bandage")')
    require(controller, "SurvivalComponent->ReduceInjury(18.0f * Quantity);")
    require(controller, "SurvivalComponent->ReduceBleeding(28.0f * Quantity);")
    require(controller, "SurvivalComponent->ReduceSprain(10.0f * Quantity);")
    require(controller, "SurvivalComponent->RestoreHealth(4.0f * Quantity);")
    require(item_use_verify, "SurvivalComponent->ReduceBleeding(28.0f * Quantity);")
    require(item_use_verify, "SurvivalComponent->ReduceSprain(10.0f * Quantity);")
    require(tech_doc, "MVP treatment")
    require(tech_doc, "reduces injury, bleeding, and sprain severity")
    require(roadmap, "[x] Add treatment item.")

    print("PASS: MVP treatment item is present.")


if __name__ == "__main__":
    main()
