package common.entity;

import common.color.TextColor;
import common.entity.types.EntityLiving;
import common.item.ItemStack;

public class EntityDamageSource extends DamageSource
{
    protected final Entity damageSourceEntity;
    protected final String displayKillItem;

    /**
     * Whether this EntityDamageSource is from an entity wearing Thorns-enchanted armor.
     */
    private boolean isThornsDamage = false;

    public EntityDamageSource(TextColor color, String display, String item, String kill, String killItem, Entity damageSourceEntityIn)
    {
        super(color, display, item, kill);
        this.damageSourceEntity = damageSourceEntityIn;
        this.displayKillItem = killItem;
    }

    public EntityDamageSource(TextColor color, String display, String kill, Entity damageSourceEntityIn)
    {
        this(color, display, display, kill, kill, damageSourceEntityIn);
    }

    /**
     * Sets this EntityDamageSource as originating from Thorns armor
     */
    public EntityDamageSource setIsThornsDamage()
    {
        this.isThornsDamage = true;
        return this;
    }

    public boolean getIsThornsDamage()
    {
        return this.isThornsDamage;
    }

    public Entity getEntity()
    {
        return this.damageSourceEntity;
    }

    /**
     * Gets the death message that is displayed when the player dies
     *  
     * @param victim The EntityLivingBase that died
     */
    public String getDeathMessage(EntityLiving victim)
    {
        ItemStack item = this.damageSourceEntity instanceof EntityLiving ? ((EntityLiving)this.damageSourceEntity).getHeldItem() : null;
//        String s = "death.attack." + this.damageType;
//        String s1 = s + "Item";
        return item != null ? String.format(this.displayExtra, victim.getColoredName(this.color), this.damageSourceEntity.getColoredName(this.color), item.getColoredName(this.color)) : String.format(this.display, victim.getColoredName(this.color), this.damageSourceEntity.getColoredName(this.color));
    }

//    /**
//     * Return whether this damage source will have its damage amount scaled based on the current difficulty.
//     */
//    public boolean isDifficultyScaled()
//    {
//        return this.damageSourceEntity != null && this.damageSourceEntity instanceof EntityLiving && !(this.damageSourceEntity.isPlayer());
//    }
}
