package common.enchantment;

import common.attributes.UsageSlot;
import common.item.Item;
import common.item.tool.ItemArmor;
import common.item.tool.ItemBow;
import common.item.tool.ItemFishingRod;
import common.item.tool.ItemSword;
import common.item.tool.ItemTool;

public enum EnchantmentType
{
    ALL,
    ARMOR,
    ARMOR_FEET,
    ARMOR_LEGS,
    ARMOR_TORSO,
    ARMOR_HEAD,
    WEAPON,
    DIGGER,
    FISHING_ROD,
    BREAKABLE,
    BOW;

    public boolean canEnchantItem(Item item)
    {
        if (this == ALL)
        {
            return true;
        }
        else if (this == BREAKABLE && item.isDamageable())
        {
            return true;
        }
        else if (item instanceof ItemArmor)
        {
            if (this == ARMOR)
            {
                return true;
            }
            else
            {
                ItemArmor armor = (ItemArmor)item;
                return armor.armorType == UsageSlot.HEAD ? this == ARMOR_HEAD : (armor.armorType == UsageSlot.LEGS ? this == ARMOR_LEGS : (armor.armorType == UsageSlot.BODY ? this == ARMOR_TORSO : (armor.armorType == UsageSlot.FEET ? this == ARMOR_FEET : false)));
            }
        }
        else
        {
            return item instanceof ItemSword ? this == WEAPON : (item instanceof ItemTool ? this == DIGGER : (item instanceof ItemBow ? this == BOW : (item instanceof ItemFishingRod ? this == FISHING_ROD : false)));
        }
    }
}
