package projectzombie.init;

import java.util.ArrayList;

import projectzombie.inventory.Crafting;
import projectzombie.inventory.recipe.Recipe;
import projectzombie.inventory.recipe.RecipeBasic;
import projectzombie.items.modifier.ItemModifierDamage;
import projectzombie.items.modifier.ItemModifierMeta;
import projectzombie.util.ItemStack;

public class Recipes
{
	public static ArrayList<Recipe> recipies;
	
	public static Recipe[] getCraftableRecipies(Crafting tool)
	{
		int size = 0;
		
		for(Recipe recipe : recipies) {
			size += recipe.canCraft(tool) ? 1 : 0;
		}
		
		int upto = 0;
		Recipe[] craftable_recipies = new Recipe[size];
		
		for(Recipe recipe : recipies)
		{
			if(recipe.canCraft(tool)) {
				craftable_recipies[upto] = recipe;
				upto += 1;
			}
		}
		
		return craftable_recipies;
	}
	
	public static void init()
	{
		recipies = new ArrayList<Recipe>();
		
		// Basic crafting items
		
		recipies.add(new RecipeBasic(
				new ItemStack[] {
						new ItemStack(Items.FLINT, 2),
						new ItemStack(Items.PLANT_FIBRE, 5),
				}, new Crafting[] {
						Crafting.BASIC,
				}, new ItemStack(Items.FLINT_HATCHET, 1)));
		
		recipies.add(new RecipeBasic(
				new ItemStack[] {
						new ItemStack(Items.LOG, 12),
						new ItemStack(Items.ROCK, 8, new ItemModifierMeta(0)),
				}, new Crafting[] {
						Crafting.BASIC,
				}, new ItemStack(Items.CAMPFIRE, 1)));
		
		recipies.add(new RecipeBasic(
				new ItemStack[] {
						new ItemStack(Items.LOG, 16),
						new ItemStack(Items.ROCK, 4, new ItemModifierMeta(0)),
						new ItemStack(Items.PLANT_FIBRE, 8),
				}, new Crafting[] {
						Crafting.BASIC,
				}, new ItemStack(Items.WORKBENCH, 1)));
		
		recipies.add(new RecipeBasic(
				new ItemStack[] {
						new ItemStack(Items.LOG, 1),
						new ItemStack(Items.COAL, 1),
						new ItemStack(Items.PLANT_FIBRE, 2),
				}, new Crafting[] {
						Crafting.BASIC,
				}, new ItemStack(Items.TORCH, 1)));
		
		
		// Workbench items
		
		recipies.add(new RecipeBasic(
				new ItemStack[] {
						new ItemStack(Items.LOG, 4),
						new ItemStack(Items.ROCK, 3, new ItemModifierMeta(0)),
						new ItemStack(Items.PLANT_FIBRE, 3),
				}, new Crafting[] {
						Crafting.WOODEN_WORKBENCH,
				}, new ItemStack(Items.STONE_PICK, 1)));
		
		recipies.add(new RecipeBasic(
				new ItemStack[] {
						new ItemStack(Items.LOG, 4),
						new ItemStack(Items.ROCK, 2, new ItemModifierMeta(0)),
						new ItemStack(Items.PLANT_FIBRE, 3),
				}, new Crafting[] {
						Crafting.WOODEN_WORKBENCH,
				}, new ItemStack(Items.STONE_SHOVEL, 1)));
		
		recipies.add(new RecipeBasic(
				new ItemStack[] {
						new ItemStack(Items.LOG, 4),
						new ItemStack(Items.ROCK, 3, new ItemModifierMeta(0)),
						new ItemStack(Items.PLANT_FIBRE, 3),
				}, new Crafting[] {
						Crafting.WOODEN_WORKBENCH,
				}, new ItemStack(Items.STONE_HATCHET, 1)));
		
		recipies.add(new RecipeBasic(
				new ItemStack[] {
						new ItemStack(Items.ROCK, 8, new ItemModifierMeta(3)),
				}, new Crafting[] {
						Crafting.WOODEN_WORKBENCH,
				}, new ItemStack(Items.CLAY_POT_WET, 1)));
		
		recipies.add(new RecipeBasic(
				new ItemStack[] {
						new ItemStack(Items.ROCK, 32, new ItemModifierMeta(3)),
				}, new Crafting[] {
						Crafting.WOODEN_WORKBENCH,
				}, new ItemStack(Items.BLAST_FURNACE, 1)));
		
		
	}
}
