package common.enchantment;

import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.types.EntityLiving;
import common.item.ItemAxe;
import common.item.ItemStack;


public class EnchantmentDraining extends Enchantment {
	public EnchantmentDraining(int enchID, String enchName, int enchWeight) {
		super(enchID, enchName, enchWeight, EnumEnchantmentType.WEAPON);
		this.setName("Seelenentzug");
	}

	public int getMinEnchantability(int enchantmentLevel) {
		return 2 + (enchantmentLevel - 1) * 11;
	}

	public int getMaxEnchantability(int enchantmentLevel) {
		return this.getMinEnchantability(enchantmentLevel) + 20;
	}

	public int getMaxLevel() {
		return 16;
	}

//    public boolean canApplyTogether(Enchantment ench)
//    {
//        return !(ench instanceof EnchantmentDraining);
//    }

	public boolean canApply(ItemStack stack) {
		return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
	}

	public void onEntityDamaged(EntityLiving user, Entity target, int level) {
		if(target instanceof EntityLiving) {
			EntityLiving entity = (EntityLiving)target;
			entity.attackEntityFrom(DamageSource.causeIndirectMagicDamage(user, user), (int)((float)level * 1.25F));
			user.heal((int)((entity.arePotionsInverted() ? 0.2f : 1.0f) * (float)level));
		}
	}
}
