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

import com.zivilon.cinder_loe.CinderLoE;
import lotr.common.LOTRLevelData;
import lotr.common.LOTRMod;
import lotr.common.LOTRShields;
import lotr.common.entity.npc.LOTREntityAngmarHillmanWarrior;
import lotr.common.entity.npc.LOTREntityGundabadUruk;
import lotr.common.fac.LOTRFaction;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;


public class NorthernOrc extends LOTREntityGundabadUruk {

    private static ItemStack[] weapons = new ItemStack[]{new ItemStack(LOTRMod.swordAngmar), new ItemStack(LOTRMod.battleaxeAngmar), new ItemStack(LOTRMod.hammerGundabadUruk), new ItemStack(LOTRMod.polearmAngmar), new ItemStack(LOTRMod.spearAngmar), new ItemStack(LOTRMod.swordGundabadUruk)};
    private static ItemStack[] helmets = new ItemStack[]{new ItemStack(LOTRMod.helmetAngmar), new ItemStack(LOTRMod.helmetGundabadUruk), new ItemStack(LOTRMod.helmetBone)};
    private static ItemStack[] bodies = new ItemStack[]{new ItemStack(LOTRMod.bodyAngmar), new ItemStack(LOTRMod.bodyGundabadUruk), new ItemStack(LOTRMod.bodyUruk)};
    private static ItemStack[] legs = new ItemStack[]{new ItemStack(LOTRMod.legsAngmar), new ItemStack(LOTRMod.legsGundabadUruk), new ItemStack(LOTRMod.legsUruk)};
    private static ItemStack[] boots = new ItemStack[]{new ItemStack(LOTRMod.bootsAngmar), new ItemStack(LOTRMod.bootsGundabadUruk), new ItemStack(LOTRMod.bootsUruk)};

    public NorthernOrc(World world) {
        super(world);
        this.setSize(0.6f, 1.8f);
        this.isWeakOrc = false;
        this.npcShield = LOTRShields.ALIGNMENT_ANGMAR;
    }

    @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 LOTRFaction getFaction() {
        return LOTRFaction.ANGMAR;
    }

    @Override
    public String getSpeechBank(EntityPlayer entityplayer) {
        if (this.isFriendlyAndAligned(entityplayer)) {
            if (this.hiredNPCInfo.getHiringPlayer() == entityplayer) {
                return "angmar/orc/hired";
            }
            if (LOTRLevelData.getData(entityplayer).getAlignment(this.getFaction()) >= 100.0f) {
                return "angmar/orc/friendly";
            }
            return "angmar/orc/neutral";
        }
        return "angmar/orc/hostile";
    }

    @Override
    public boolean canOrcSkirmish() {
        return false;
    }

}
