package com.zivilon.cinder_loe.entity.npc.evil_human;

import com.zivilon.cinder_loe.CinderLoE;
import lotr.common.LOTRMod;
import lotr.common.LOTRShields;
import lotr.common.entity.npc.LOTREntityAngmarHillmanWarrior;
import lotr.common.entity.npc.LOTREntityUmbarWarrior;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;


public class UmbarUsurper extends LOTREntityUmbarWarrior {

    private static ItemStack[] weapons = new ItemStack[]{new ItemStack(LOTRMod.poleaxeNearHarad), new ItemStack(LOTRMod.scimitarNearHarad), new ItemStack(LOTRMod.polearmRhun)};
    private static ItemStack[] helmets = new ItemStack[]{new ItemStack(CinderLoE.helmetUsurper)};
    private static ItemStack[] bodies = new ItemStack[]{new ItemStack(CinderLoE.bodyUsurper)};
    private static ItemStack[] legs = new ItemStack[]{new ItemStack(CinderLoE.legsUsurper)};
    private static ItemStack[] boots = new ItemStack[]{new ItemStack(CinderLoE.bootsUsurper)};

    public UmbarUsurper(World world) {
        super(world);
        this.npcShield = LOTRShields.ALIGNMENT_UMBAR;
    }

    @Override
    public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) {
        data = super.onSpawnWithEgg(data);
        int i = this.rand.nextInt(weapons.length);
        this.npcItemsInv.setMeleeWeapon(weapons[i].copy());
        this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon());
        i = this.rand.nextInt(boots.length);
        this.setCurrentItemOrArmor(1, boots[i].copy());
        i = this.rand.nextInt(legs.length);
        this.setCurrentItemOrArmor(2, legs[i].copy());
        i = this.rand.nextInt(bodies.length);
        this.setCurrentItemOrArmor(3, bodies[i].copy());
        if (this.rand.nextInt(5) != 0) {
            i = this.rand.nextInt(helmets.length);
            this.setCurrentItemOrArmor(4, helmets[i].copy());
        }
        return data;
    }

    @Override
    public String getSpeechBank(EntityPlayer entityplayer) {
        if (this.isFriendlyAndAligned(entityplayer)) {
            if (this.hiredNPCInfo.getHiringPlayer() == entityplayer) {
                return "nearHarad/umbar/warrior/hired";
            }
            return "nearHarad/umbar/warrior/friendly";
        }
        return "nearHarad/umbar/warrior/hostile";
    }

    @Override
    protected void applyEntityAttributes() {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(26.0);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2);
    }
}
