package cz.jzitnik.game.crafting;

import cz.jzitnik.game.entities.items.ItemBlockSupplier;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.*;

class CraftingRecipeListTest {
    @Test
    @DisplayName("Verify that all items in the crafting recipe list are actual items")
    void verifyAllItems() {
        for (CraftingRecipe craftingRecipe : CraftingRecipeList.recipes) {
            if (!craftingRecipe.isUsingRegex()) {
                for (String[] arr : craftingRecipe.getRecipe()) {
                    for (String item : arr) {
                        if (item == null) {
                            continue;
                        }
                        assertDoesNotThrow(() -> ItemBlockSupplier.getItem(item),
                                "Item " + item + " does not exist but is present as source in crafting recipe list.");
                    }
                }
            }

            assertDoesNotThrow(craftingRecipe.getItemSupplier()::get,
                    "Output item does not exist for recipe: " + Arrays.deepToString(craftingRecipe.getRecipe()) + ".");
        }
    }
}
