package common.enchantment;

import common.item.ItemAxe;
import common.item.ItemStack;


public class EnchantmentDamage extends Enchantment
{
    public EnchantmentDamage(int enchID, String enchName, int enchWeight)
    {
        super(enchID, enchName, enchWeight, EnumEnchantmentType.WEAPON);
        this.setName("Schärfe");
    }

    /**
     * Returns the minimal value of enchantability needed on the enchantment level passed.
     */
    public int getMinEnchantability(int enchantmentLevel)
    {
        return 1 + (enchantmentLevel - 1) * 11;
    }

    /**
     * Returns the maximum value of enchantability nedded on the enchantment level passed.
     */
    public int getMaxEnchantability(int enchantmentLevel)
    {
        return this.getMinEnchantability(enchantmentLevel) + 20;
    }

    /**
     * Returns the maximum level that the enchantment can have.
     */
    public int getMaxLevel()
    {
        return 5;
    }

    /**
     * Calculates the additional damage that will be dealt by an item with this enchantment. This alternative to
     * calcModifierDamage is sensitive to the targets EnumCreatureAttribute.
     */
    public int calcAdditionalDamage(int level)
    {
        return (int)(/*this.damageType == 0 ? */ (float)level * 1.25F); // : (this.damageType == 1 && creatureType == CreatureType.UNDEAD ? (float)level * 2.5F : (this.damageType == 2 && creatureType == CreatureType.ARTHROPOD ? (float)level * 2.5F : 0.0F)));
    }

    /**
     * Determines if the enchantment passed can be applyied together with this enchantment.
     */
    public boolean canApplyTogether(Enchantment ench)
    {
        return !(ench instanceof EnchantmentDamage);
    }

    /**
     * Determines if this enchantment can be applied to a specific ItemStack.
     */
    public boolean canApply(ItemStack stack)
    {
        return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
    }

//    /**
//     * Called whenever a mob is damaged with an item that has this enchantment on it.
//     */
//    public void onEntityDamaged(EntityLivingBase user, Entity target, int level)
//    {
//        if (target instanceof EntityLivingBase)
//        {
//            EntityLivingBase entitylivingbase = (EntityLivingBase)target;
//
//            if (this.damageType == 2 && entitylivingbase.getCreatureType() == CreatureType.ARTHROPOD)
//            {
//                int i = 20 + user.getRNG().zrange(10 * level);
//                entitylivingbase.addEffect(new PotionEffect(Potion.moveSlowdown.id, i, 3));
//            }
//        }
//    }
}
