from pathlib import Path


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

EXPECTED = {
    ROOT / "Source" / "AgrarianGame" / "AgrarianDebugHUD.h": [
        "bool bShowCraftingHUD = true;",
        "int32 MaxCraftingPanelRows = 8;",
        "void DrawCraftingPanel",
    ],
    ROOT / "Source" / "AgrarianGame" / "AgrarianDebugHUD.cpp": [
        "DrawCraftingPanel(AgrarianCharacter",
        "CraftingComponent->GetKnownRecipes(Recipes)",
        "CraftingComponent->CanCraft(Recipe.RecipeId, FailureReason)",
        "InventoryComponent->GetItemCount(Ingredient.ItemId)",
        "CRAFTING  %d recipes",
    ],
    ROOT / "Source" / "AgrarianGame" / "AgrarianCraftingComponent.h": [
        "void GetKnownRecipes(TArray<FAgrarianRecipe>& OutRecipes) const;",
    ],
    ROOT / "Source" / "AgrarianGame" / "AgrarianCraftingComponent.cpp": [
        "void UAgrarianCraftingComponent::GetKnownRecipes",
        "RecipeAsset->Recipe.RecipeId != NAME_None",
        "OutRecipes.Add(RecipeAsset->Recipe)",
    ],
    ROOT / "Scripts" / "setup_agrarian_player_blueprints.py": [
        "KNOWN_RECIPE_ASSETS",
        "DA_Recipe_SimpleContainer",
        "known_recipe_assets",
    ],
    ROOT / "Scripts" / "verify_agrarian_player_blueprints.py": [
        "EXPECTED_RECIPE_IDS",
        "simple_container",
        "known_recipe_assets",
    ],
    ROOT / "Docs" / "TechnicalDesignDocument.md": [
        "The MVP crafting UI is a compact `AAgrarianDebugHUD` crafting panel",
        "`KnownRecipeAssets`",
    ],
    ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
        "- [x] Add crafting UI.",
        "compact crafting HUD panel",
    ],
}


def main():
    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)} missing {snippet!r}")

    if missing:
        raise RuntimeError("Crafting UI verification failed: " + "; ".join(missing))

    print("PASS: crafting UI HUD panel and known recipe wiring are present.")


if __name__ == "__main__":
    main()
