package cz.jzitnik.game;

import cz.jzitnik.game.sprites.*;
import cz.jzitnik.tui.Sprite;
import cz.jzitnik.tui.SpriteList;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;

@Slf4j
public class SpriteLoader {
    public enum SPRITES {
        // BLOCKS

        // Blocks
        AIR,
        WATER,
        LAVA,
        DIRT,
        FARMLAND,
        GRASS,
        STONE,
        BEDROCK,
        COBBLESTONE,
        WOOL,
        OAK_LOG,
        OAK_LEAF,
        OAK_PLANKS,
        OAK_DOOR,
        OBSIDIAN,
        SAND,
        HAYBALE,
        GRAVEL,

        // Flowers etc
        GRASS_BUSH,
        POPPY,
        PINK_TULIP,
        RED_TULIP,
        ORANGE_TULIP,
        WHITE_TULIP,
        DANDELION,
        CORNFLOWER,
        ALLIUM,
        BLUE_ORCHID,
        OXEYE_DAISY,
        AZURE_BLUET,
        LILY_OF_THE_VALLEY,
        LILAC,
        PEONY,
        ROSE_BUSH,
        SUNFLOWER,

        // Ores
        COAL_ORE,
        IRON_ORE,
        GOLD_ORE,
        DIAMOND_ORE,

        COAL_BLOCK,
        IRON_BLOCK,
        GOLD_BLOCK,
        DIAMOND_BLOCK,

        // Work
        FURNACE,
        CHEST,
        CRAFTING_TABLE,
        BED,

        // Saplings
        OAK_SAPLING,

        // ENTITIES
        STEVE,
        PIG,
        SHEEP,
        COW,
        ZOMBIE,

        // UI
        BREAKING,
        HEART,
        HUNGER,

        // Seeds
        WHEAT,

        // ITEMS

        // Items
        ITEM_STICK,
        ITEM_LEATHER,
        ITEM_DYE,
        ITEM_FLINT,

        // Block Items
        ITEM_DIRT,
        ITEM_GRASS,
        ITEM_OAK_LOG,
        ITEM_OAK_LEAF,
        ITEM_OAK_PLANKS,
        ITEM_COBBLESTONE,
        ITEM_STONE,
        ITEM_OAK_DOOR,
        ITEM_WOOL,
        ITEM_OBSIDIAN,
        ITEM_SAND,
        ITEM_HAYBALE,
        ITEM_GRAVEL,

        // Tall Flowers
        ITEM_LILAC,
        ITEM_PEONY,
        ITEM_ROSE_BUSH,
        ITEM_SUNFLOWER,

        // Ore Items
        ITEM_COAL_ORE,
        ITEM_IRON_ORE,
        ITEM_GOLD_ORE,
        ITEM_DIAMOND_ORE,

        ITEM_COAL_BLOCK,
        ITEM_IRON_BLOCK,
        ITEM_GOLD_BLOCK,
        ITEM_DIAMOND_BLOCK,

        COAL,
        ITEM_IRON_INGOT,
        ITEM_GOLD_INGOT,
        DIAMOND,

        // Work Items
        ITEM_CRAFTING_TABLE,
        ITEM_CHEST,
        ITEM_FURNACE,
        ITEM_BED,

        // Tools
        WOODEN_SWORD,
        WOODEN_PICKAXE,
        WOODEN_AXE,
        WOODEN_SHOVEL,
        WOODEN_HOE,

        STONE_SWORD,
        STONE_PICKAXE,
        STONE_AXE,
        STONE_SHOVEL,
        STONE_HOE,

        IRON_SWORD,
        IRON_PICKAXE,
        IRON_AXE,
        IRON_SHOVEL,
        IRON_HOE,

        GOLDEN_SWORD,
        GOLDEN_PICKAXE,
        GOLDEN_AXE,
        GOLDEN_SHOVEL,
        GOLDEN_HOE,

        DIAMOND_SWORD,
        DIAMOND_PICKAXE,
        DIAMOND_AXE,
        DIAMOND_SHOVEL,
        DIAMOND_HOE,

        SHEARS,
        FLINT_AND_STEEL,

        BUCKET,
        WATER_BUCKET,
        LAVA_BUCKET,
        MILK_BUCKET,

        // Food
        ITEM_PORKCHOP,
        ITEM_COOKED_PORKCHOP,
        ITEM_MUTTON,
        ITEM_COOKED_MUTTON,
        ITEM_BEEF,
        ITEM_STEAK,
        ITEM_APPLE,
        ITEM_BREAD,

        // Seeds
        ITEM_WHEAT_SEEDS,
        ITEM_WHEAT,
    }

    public static final HashMap<SPRITES, Sprite> SPRITES_MAP = new HashMap<>();

    static {
        // BLOCKS

        // Block
        SPRITES_MAP.put(SPRITES.AIR, new Air());
        SPRITES_MAP.put(SPRITES.WATER, new Water());
        SPRITES_MAP.put(SPRITES.LAVA, new Lava());
        SPRITES_MAP.put(SPRITES.DIRT, new SimpleSprite("dirt.ans"));
        SPRITES_MAP.put(SPRITES.FARMLAND, new Farmland());
        SPRITES_MAP.put(SPRITES.GRASS, new SimpleSprite("grass.ans"));
        SPRITES_MAP.put(SPRITES.STONE, new SimpleSprite("stone.ans"));
        SPRITES_MAP.put(SPRITES.BEDROCK, new SimpleSprite("bedrock.ans"));
        SPRITES_MAP.put(SPRITES.OAK_LOG, new SimpleSprite("oak_log.ans"));
        SPRITES_MAP.put(SPRITES.OAK_LEAF, new SimpleSprite("oak_leaf.ans"));
        SPRITES_MAP.put(SPRITES.OAK_PLANKS, new SimpleSprite("oak_planks.ans"));
        SPRITES_MAP.put(SPRITES.OAK_DOOR, new OakDoor());
        SPRITES_MAP.put(SPRITES.WOOL, new Wool());
        SPRITES_MAP.put(SPRITES.COBBLESTONE, new SimpleSprite("cobblestone.ans"));
        SPRITES_MAP.put(SPRITES.OBSIDIAN, new SimpleSprite("obsidian.ans"));
        SPRITES_MAP.put(SPRITES.SAND, new SimpleSprite("sand.ans"));
        SPRITES_MAP.put(SPRITES.HAYBALE, new SimpleSprite("haybale.ans"));
        SPRITES_MAP.put(SPRITES.GRAVEL, new SimpleSprite("gravel.ans"));

        // Ores
        SPRITES_MAP.put(SPRITES.COAL_ORE, new SimpleSprite("coal_ore.ans"));
        SPRITES_MAP.put(SPRITES.IRON_ORE, new SimpleSprite("iron_ore.ans"));
        SPRITES_MAP.put(SPRITES.GOLD_ORE, new SimpleSprite("gold_ore.ans"));
        SPRITES_MAP.put(SPRITES.DIAMOND_ORE, new SimpleSprite("diamond_ore.ans"));

        SPRITES_MAP.put(SPRITES.COAL_BLOCK, new SimpleSprite("coal_block.ans"));
        SPRITES_MAP.put(SPRITES.IRON_BLOCK, new SimpleSprite("iron_block.ans"));
        SPRITES_MAP.put(SPRITES.GOLD_BLOCK, new SimpleSprite("gold_block.ans"));
        SPRITES_MAP.put(SPRITES.DIAMOND_BLOCK, new SimpleSprite("diamond_block.ans")); // NEWW

        // Work
        SPRITES_MAP.put(SPRITES.CRAFTING_TABLE, new SimpleSprite("crafting_table.ans"));
        SPRITES_MAP.put(SPRITES.FURNACE, new Furnace());
        SPRITES_MAP.put(SPRITES.CHEST, new SimpleSprite("chest.ans"));
        SPRITES_MAP.put(SPRITES.BED, new Bed());

        // GRASSY THINGS

        // Saplings
        SPRITES_MAP.put(SPRITES.OAK_SAPLING, new SimpleSprite("oak_sapling.ans"));

        // Flowers
        SPRITES_MAP.put(SPRITES.POPPY, new SimpleSprite("poppy.ans"));
        SPRITES_MAP.put(SPRITES.RED_TULIP, new SimpleSprite("red_tulip.ans"));
        SPRITES_MAP.put(SPRITES.PINK_TULIP, new SimpleSprite("pink_tulip.ans"));
        SPRITES_MAP.put(SPRITES.WHITE_TULIP, new SimpleSprite("white_tulip.ans"));
        SPRITES_MAP.put(SPRITES.ORANGE_TULIP, new SimpleSprite("orange_tulip.ans"));
        SPRITES_MAP.put(SPRITES.DANDELION, new SimpleSprite("dandelion.ans"));
        SPRITES_MAP.put(SPRITES.LILY_OF_THE_VALLEY, new SimpleSprite("lily_of_the_valley.ans"));
        SPRITES_MAP.put(SPRITES.CORNFLOWER, new SimpleSprite("cornflower.ans"));
        SPRITES_MAP.put(SPRITES.ALLIUM, new SimpleSprite("allium.ans"));
        SPRITES_MAP.put(SPRITES.BLUE_ORCHID, new SimpleSprite("blue_orchid.ans"));
        SPRITES_MAP.put(SPRITES.OXEYE_DAISY, new SimpleSprite("oxeye_daisy.ans"));
        SPRITES_MAP.put(SPRITES.AZURE_BLUET, new SimpleSprite("azure_bluet.ans"));
        SPRITES_MAP.put(SPRITES.LILAC, new TwoBlockSprite("lilac_top.ans", "lilac_bottom.ans"));
        SPRITES_MAP.put(SPRITES.PEONY, new TwoBlockSprite("peony_top.ans", "peony_bottom.ans"));
        SPRITES_MAP.put(SPRITES.ROSE_BUSH, new TwoBlockSprite("rose_bush_top.ans", "rose_bush_bottom.ans"));
        SPRITES_MAP.put(SPRITES.SUNFLOWER, new TwoBlockSprite("sunflower_top.ans", "sunflower_bottom.ans"));

        // Grass
        SPRITES_MAP.put(SPRITES.GRASS_BUSH, new SimpleSprite("grass_bush.ans"));

        // Seeds
        SPRITES_MAP.put(SPRITES.ITEM_WHEAT_SEEDS, new SimpleSprite("items/wheat_seeds.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_WHEAT, new SimpleSprite("items/wheat.ans"));

        // ENTITIES
        SPRITES_MAP.put(SPRITES.STEVE, new Steve());
        SPRITES_MAP.put(SPRITES.PIG, new Pig());
        SPRITES_MAP.put(SPRITES.SHEEP, new Sheep());
        SPRITES_MAP.put(SPRITES.COW, new Cow());
        SPRITES_MAP.put(SPRITES.ZOMBIE, new Zombie());

        // UI
        SPRITES_MAP.put(SPRITES.BREAKING, new Breaking());
        SPRITES_MAP.put(SPRITES.HEART, new Heart());
        SPRITES_MAP.put(SPRITES.HUNGER, new Hunger());

        // SEEDS
        SPRITES_MAP.put(SPRITES.WHEAT, new Farmable("wheat_stage1.ans", "wheat_stage2.ans", "wheat_stage3.ans"));

        // ITEMS

        // Items
        SPRITES_MAP.put(SPRITES.ITEM_STICK, new SimpleSprite("items/stick.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_LEATHER, new SimpleSprite("items/leather.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_DYE, new Dye());
        SPRITES_MAP.put(SPRITES.ITEM_FLINT, new SimpleSprite("items/flint.ans"));

        // Block Items
        SPRITES_MAP.put(SPRITES.ITEM_DIRT, new SimpleSprite("items/dirt.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_GRASS, new SimpleSprite("items/grass.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_OAK_LOG, new SimpleSprite("items/oak_log.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_OAK_LEAF, new SimpleSprite("items/oak_leaves.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_OAK_PLANKS, new SimpleSprite("items/oak_planks.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_COBBLESTONE, new SimpleSprite("items/cobblestone.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_STONE, new SimpleSprite("items/stone.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_OAK_DOOR, new SimpleSprite("oak_door/items/oak_door.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_WOOL, new WoolItem());
        SPRITES_MAP.put(SPRITES.ITEM_OBSIDIAN, new SimpleSprite("items/obsidian.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_SAND, new SimpleSprite("items/sand.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_HAYBALE, new SimpleSprite("items/haybale.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_GRAVEL, new SimpleSprite("items/gravel.ans"));

        // Tall flowers
        SPRITES_MAP.put(SPRITES.ITEM_LILAC, new SimpleSprite("items/lilac.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_PEONY, new SimpleSprite("items/peony.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_ROSE_BUSH, new SimpleSprite("items/rose_bush.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_SUNFLOWER, new SimpleSprite("items/sunflower.ans"));

        // Ore Items
        SPRITES_MAP.put(SPRITES.ITEM_COAL_ORE, new SimpleSprite("items/coal_ore.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_IRON_ORE, new SimpleSprite("items/iron_ore.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_GOLD_ORE, new SimpleSprite("items/gold_ore.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_DIAMOND_ORE, new SimpleSprite("items/diamond_ore.ans"));

        SPRITES_MAP.put(SPRITES.ITEM_COAL_BLOCK, new SimpleSprite("items/coal_block.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_IRON_BLOCK, new SimpleSprite("items/iron_block.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_GOLD_BLOCK, new SimpleSprite("items/gold_block.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_DIAMOND_BLOCK, new SimpleSprite("items/diamond_block.ans"));

        SPRITES_MAP.put(SPRITES.COAL, new SimpleSprite("items/coal.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_IRON_INGOT, new SimpleSprite("items/iron_ingot.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_GOLD_INGOT, new SimpleSprite("items/gold_ingot.ans"));
        SPRITES_MAP.put(SPRITES.DIAMOND, new SimpleSprite("items/diamond.ans"));

        // Work Items
        SPRITES_MAP.put(SPRITES.ITEM_CRAFTING_TABLE, new SimpleSprite("items/crafting_table.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_CHEST, new SimpleSprite("items/chest.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_FURNACE, new SimpleSprite("items/furnace.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_BED, new SimpleSprite("items/bed.ans"));

        // Tools
        SPRITES_MAP.put(SPRITES.WOODEN_SWORD, new SimpleSprite("items/wooden_sword.ans"));
        SPRITES_MAP.put(SPRITES.WOODEN_PICKAXE, new SimpleSprite("items/wooden_pickaxe.ans"));
        SPRITES_MAP.put(SPRITES.WOODEN_AXE, new SimpleSprite("items/wooden_axe.ans"));
        SPRITES_MAP.put(SPRITES.WOODEN_SHOVEL, new SimpleSprite("items/wooden_shovel.ans"));
        SPRITES_MAP.put(SPRITES.WOODEN_HOE, new SimpleSprite("items/wooden_hoe.ans"));

        SPRITES_MAP.put(SPRITES.STONE_SWORD, new SimpleSprite("items/stone_sword.ans"));
        SPRITES_MAP.put(SPRITES.STONE_PICKAXE, new SimpleSprite("items/stone_pickaxe.ans"));
        SPRITES_MAP.put(SPRITES.STONE_AXE, new SimpleSprite("items/stone_axe.ans"));
        SPRITES_MAP.put(SPRITES.STONE_SHOVEL, new SimpleSprite("items/stone_shovel.ans"));
        SPRITES_MAP.put(SPRITES.STONE_HOE, new SimpleSprite("items/stone_hoe.ans"));

        SPRITES_MAP.put(SPRITES.IRON_SWORD, new SimpleSprite("items/iron_sword.ans"));
        SPRITES_MAP.put(SPRITES.IRON_PICKAXE, new SimpleSprite("items/iron_pickaxe.ans"));
        SPRITES_MAP.put(SPRITES.IRON_AXE, new SimpleSprite("items/iron_axe.ans"));
        SPRITES_MAP.put(SPRITES.IRON_SHOVEL, new SimpleSprite("items/iron_shovel.ans"));
        SPRITES_MAP.put(SPRITES.IRON_HOE, new SimpleSprite("items/iron_hoe.ans"));

        SPRITES_MAP.put(SPRITES.GOLDEN_SWORD, new SimpleSprite("items/golden_sword.ans"));
        SPRITES_MAP.put(SPRITES.GOLDEN_PICKAXE, new SimpleSprite("items/golden_pickaxe.ans"));
        SPRITES_MAP.put(SPRITES.GOLDEN_AXE, new SimpleSprite("items/golden_axe.ans"));
        SPRITES_MAP.put(SPRITES.GOLDEN_SHOVEL, new SimpleSprite("items/golden_shovel.ans"));
        SPRITES_MAP.put(SPRITES.GOLDEN_HOE, new SimpleSprite("items/golden_hoe.ans"));

        SPRITES_MAP.put(SPRITES.DIAMOND_SWORD, new SimpleSprite("items/diamond_sword.ans"));
        SPRITES_MAP.put(SPRITES.DIAMOND_PICKAXE, new SimpleSprite("items/diamond_pickaxe.ans"));
        SPRITES_MAP.put(SPRITES.DIAMOND_AXE, new SimpleSprite("items/diamond_axe.ans"));
        SPRITES_MAP.put(SPRITES.DIAMOND_SHOVEL, new SimpleSprite("items/diamond_shovel.ans"));
        SPRITES_MAP.put(SPRITES.DIAMOND_HOE, new SimpleSprite("items/diamond_hoe.ans"));

        SPRITES_MAP.put(SPRITES.SHEARS, new SimpleSprite("items/shears.ans"));
        SPRITES_MAP.put(SPRITES.FLINT_AND_STEEL, new SimpleSprite("items/flint_and_steel.ans"));

        SPRITES_MAP.put(SPRITES.BUCKET, new SimpleSprite("items/bucket.ans"));
        SPRITES_MAP.put(SPRITES.WATER_BUCKET, new SimpleSprite("items/water_bucket.ans"));
        SPRITES_MAP.put(SPRITES.LAVA_BUCKET, new SimpleSprite("items/lava_bucket.ans"));
        SPRITES_MAP.put(SPRITES.MILK_BUCKET, new SimpleSprite("items/milk_bucket.ans"));

        // Food
        SPRITES_MAP.put(SPRITES.ITEM_PORKCHOP, new SimpleSprite("items/porkchop.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_COOKED_PORKCHOP, new SimpleSprite("items/cooked_porkchop.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_MUTTON, new SimpleSprite("items/mutton.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_COOKED_MUTTON, new SimpleSprite("items/cooked_mutton.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_BEEF, new SimpleSprite("items/beef.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_STEAK, new SimpleSprite("items/steak.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_APPLE, new SimpleSprite("items/apple.ans"));
        SPRITES_MAP.put(SPRITES.ITEM_BREAD, new SimpleSprite("items/bread.ans"));
    }

    public static SpriteList<SPRITES> load() {
        log.info("Loading sprites");
        return new SpriteList<>(SPRITES.class, SPRITES_MAP);
    }
}
