package com.zivilon.cinder_loe.enchants;

import cpw.mods.fml.common.network.simpleimpl.IMessage;
import lotr.common.LOTRDamage;
import lotr.common.enchant.LOTREnchantment;
import lotr.common.enchant.LOTREnchantmentBane;
import lotr.common.enchant.LOTREnchantmentType;
import lotr.common.item.LOTRWeaponStats;
import lotr.common.network.LOTRPacketHandler;
import lotr.common.network.LOTRPacketWeaponFX;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.StatCollector;
import net.minecraft.item.ItemStack;

public class LOTREnchantmentArmorSpecial extends LOTREnchantment {
  private boolean compatibleBane = true;

  private boolean compatibleOtherSpecial = false;

  public LOTREnchantmentArmorSpecial(String s) {
    super(s, new LOTREnchantmentType[] { LOTREnchantmentType.ARMOR, LOTREnchantmentType.ARMOR_FEET, LOTREnchantmentType.ARMOR_LEGS, LOTREnchantmentType.ARMOR_BODY, LOTREnchantmentType.ARMOR_HEAD, });
    setValueModifier(3.0F);
    setBypassAnvilLimit();
  }

  public LOTREnchantmentArmorSpecial setIncompatibleBane() {
    this.compatibleBane = false;
    return this;
  }

  public LOTREnchantmentArmorSpecial setCompatibleOtherSpecial() {
    this.compatibleOtherSpecial = true;
    return this;
  }

  public String getDescription(ItemStack itemstack) {
    return StatCollector.translateToLocalFormatted("lotr.enchant." + this.enchantName + ".desc", new Object[0]);
}

  public boolean isBeneficial() {
    return true;
  }

  public boolean canApply(ItemStack itemstack, boolean considering) {
    if (super.canApply(itemstack, considering)) {
      Item item = itemstack.getItem();
      /*if (item instanceof lotr.common.item.LOTRItemBalrogWhip && (this == LOTREnchantment.fire || this == LOTREnchantment.chill))*/
      return true;
    } 
    return false;
  }

  public boolean isCompatibleWith(LOTREnchantment other) {
    if (!this.compatibleBane)
      if (other instanceof LOTREnchantmentBane)
        return false;
    if (!this.compatibleOtherSpecial)
      if (other instanceof LOTREnchantmentArmorSpecial && !((LOTREnchantmentArmorSpecial)other).compatibleOtherSpecial)
        return false;
    return true;
  }

  public static int getFireAmount() {
    return 2;
  }

  /*public static void doChillAttack(EntityLivingBase entity) {
    if (entity instanceof EntityPlayerMP)
      LOTRDamage.doFrostDamage((EntityPlayerMP)entity); 
    int duration = 5;
    entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, duration * 20, 1));
    LOTRPacketWeaponFX packet = new LOTRPacketWeaponFX(LOTRPacketWeaponFX.Type.CHILLING, (Entity)entity);
    LOTRPacketHandler.networkWrapper.sendToAllAround((IMessage)packet, LOTRPacketHandler.nearEntity((Entity)entity, 64.0D));*/
  }