// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
//      Magicbane Emulator Project © 2013 - 2022
//                www.magicbane.com


package engine.objects;

import engine.mbEnums;

import java.util.HashMap;

public enum MineProduction {

    LUMBER("Lumber Camp", new HashMap<>(), mbEnums.ResourceType.WORMWOOD, 1618637196, 1663491950),
    ORE("Ore Mine", new HashMap<>(), mbEnums.ResourceType.OBSIDIAN, 518103023, -788976428),
    GOLD("Gold Mine", new HashMap<>(), mbEnums.ResourceType.GALVOR, -662193002, -1227205358),
    MAGIC("Magic Mine", new HashMap<>(), mbEnums.ResourceType.BLOODSTONE, 504746863, -1753567069);

    public final String name;
    public final HashMap<Integer, mbEnums.ResourceType> resources;
    public final mbEnums.ResourceType xpac;
    public final int hash;
    public final int xpacHash;

    MineProduction(String name, HashMap<Integer, mbEnums.ResourceType> resources, mbEnums.ResourceType xpac, int hash, int xpacHash) {
        this.name = name;
        this.resources = resources;
        this.xpac = xpac;
        this.hash = hash;
        this.xpacHash = xpacHash;
    }

    public static void addResources() {
        if (MineProduction.LUMBER.resources.size() == 0) {
            MineProduction.LUMBER.resources.put(7, mbEnums.ResourceType.GOLD);
            MineProduction.LUMBER.resources.put(1580004, mbEnums.ResourceType.LUMBER);
            MineProduction.LUMBER.resources.put(1580005, mbEnums.ResourceType.OAK);
            MineProduction.LUMBER.resources.put(1580006, mbEnums.ResourceType.BRONZEWOOD);
            MineProduction.LUMBER.resources.put(1580007, mbEnums.ResourceType.MANDRAKE);
        }
        if (MineProduction.ORE.resources.size() == 0) {
            MineProduction.ORE.resources.put(7, mbEnums.ResourceType.GOLD);
            MineProduction.ORE.resources.put(1580000, mbEnums.ResourceType.STONE);
            MineProduction.ORE.resources.put(1580001, mbEnums.ResourceType.TRUESTEEL);
            MineProduction.ORE.resources.put(1580002, mbEnums.ResourceType.IRON);
            MineProduction.ORE.resources.put(1580003, mbEnums.ResourceType.ADAMANT);
        }
        if (MineProduction.GOLD.resources.size() == 0) {
            MineProduction.GOLD.resources.put(7, mbEnums.ResourceType.GOLD);
            MineProduction.GOLD.resources.put(1580000, mbEnums.ResourceType.STONE);
            MineProduction.GOLD.resources.put(1580008, mbEnums.ResourceType.COAL);
            MineProduction.GOLD.resources.put(1580009, mbEnums.ResourceType.AGATE);
            MineProduction.GOLD.resources.put(1580010, mbEnums.ResourceType.DIAMOND);
            MineProduction.GOLD.resources.put(1580011, mbEnums.ResourceType.ONYX);
        }
        if (MineProduction.MAGIC.resources.size() == 0) {
            MineProduction.MAGIC.resources.put(7, mbEnums.ResourceType.GOLD);
            MineProduction.MAGIC.resources.put(1580012, mbEnums.ResourceType.AZOTH);
            MineProduction.MAGIC.resources.put(1580013, mbEnums.ResourceType.ORICHALK);
            MineProduction.MAGIC.resources.put(1580014, mbEnums.ResourceType.ANTIMONY);
            MineProduction.MAGIC.resources.put(1580015, mbEnums.ResourceType.SULFUR);
            MineProduction.MAGIC.resources.put(1580016, mbEnums.ResourceType.QUICKSILVER);
        }
    }

    public static MineProduction getByName(String name) {
        if (name.toLowerCase().equals("lumber"))
            return MineProduction.LUMBER;
        else if (name.toLowerCase().equals("ore"))
            return MineProduction.ORE;
        else if (name.toLowerCase().equals("gold"))
            return MineProduction.GOLD;
        else
            return MineProduction.MAGIC;
    }

    public boolean validForMine(mbEnums.ResourceType r, boolean isXpac) {
        if (r == null)
            return false;
        if (this.resources.containsKey(r.templateID))
            return true;
        else
            return isXpac && r.templateID == this.xpac.templateID;
    }


//Name			Xpac		Resources
//Lumber Camp	Wormwood	Gold, Lumber, Oak, Bronzewood, Mandrake
//Ore Mine		Obsidian	Gold, Stone, Truesteal, Iron, Adamant
//Gold Mine		Galvor		Gold, Coal, Agate, Diamond, Onyx
//Magic Mine	Bloodstone	Gold, Orichalk, Azoth, Antimony, Quicksilver, Sulfer
}
