from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
FILES = {
    "AgrarianItemPickup.h": ROOT / "Source" / "AgrarianGame" / "AgrarianItemPickup.h",
    "AgrarianItemPickup.cpp": ROOT / "Source" / "AgrarianGame" / "AgrarianItemPickup.cpp",
    "InventoryDataModel.md": ROOT / "Docs" / "InventoryDataModel.md",
    "TechnicalDesignDocument.md": ROOT / "Docs" / "TechnicalDesignDocument.md",
    "AGRARIAN_DEVELOPMENT_ROADMAP.md": ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md",
}

EXPECTED = {
    "AgrarianItemPickup.h": [
        "class AGRARIANGAME_API AAgrarianItemPickup : public AActor, public IAgrarianInteractable",
        "TObjectPtr<UStaticMeshComponent> Mesh;",
        "FAgrarianItemStack PickupStack;",
        "TObjectPtr<UAgrarianItemDefinitionAsset> ItemDefinition;",
        "int32 Quantity = 1;",
        "virtual FText GetInteractionText_Implementation",
        "virtual bool CanInteract_Implementation",
        "virtual void Interact_Implementation",
        "FAgrarianItemStack MakePickupStack() const;",
    ],
    "AgrarianItemPickup.cpp": [
        "bReplicates = true;",
        "Mesh->SetCollisionProfileName(TEXT(\"BlockAll\"));",
        "ItemDefinition->MakeStack(Quantity)",
        "MakePickupStack().IsValidStack()",
        "if (!HasAuthority() || !Interactor)",
        "Interactor->GetInventoryComponent()",
        "Inventory->AddItem(Stack)",
        "Destroy();",
    ],
    "InventoryDataModel.md": [
        "Pickup:",
        "world item validates range, authority, stack data, and available",
    ],
    "TechnicalDesignDocument.md": [
        "`AAgrarianItemPickup`",
        "definition-backed or inline `FAgrarianItemStack`",
        "destroying the world pickup actor",
    ],
    "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
        "[x] Add item pickup.",
    ],
}


def main():
    missing = []
    for label, path in FILES.items():
        text = path.read_text(encoding="utf-8")
        for snippet in EXPECTED[label]:
            if snippet not in text:
                missing.append(f"{label}: {snippet}")

    if missing:
        raise RuntimeError("Item pickup verification failed: " + "; ".join(missing))

    print("Agrarian item pickup verification complete.")


if __name__ == "__main__":
    main()
