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

import com.zivilon.cinder_loe.CinderLoE;
import lotr.common.LOTRCapes;
import lotr.common.LOTRLevelData;
import lotr.common.LOTRMod;
import lotr.common.entity.npc.LOTRUnitTradeEntries;
import lotr.common.entity.npc.LOTRUnitTradeable;
import lotr.common.world.spawning.LOTRInvasions;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class ArnorCaptain extends ArnorSoldier implements LOTRUnitTradeable  {
    public ArnorCaptain(World world) {
        super(world);
        addTargetTasks(false);
        this.npcCape = LOTRCapes.RANGER;
    }

    public float getAlignmentBonus() {
        return 5.0F;
    }

    public LOTRUnitTradeEntries getUnits() {
        return CinderLoE.ARNOR_CAPTAIN;
    }

    public LOTRInvasions getWarhorn() {
        return LOTRInvasions.RANGER_NORTH;
    }

    public void onUnitTrade(EntityPlayer entityplayer) {
    }

    public boolean canTradeWith(EntityPlayer entityplayer) {
        return (LOTRLevelData.getData(entityplayer).getAlignment(getFaction()) >= 150.0F && isFriendlyAndAligned(entityplayer));
    }
    @Override
    public ItemStack getPickedResult(MovingObjectPosition target) {
        return new ItemStack(CinderLoE.spawnEgg, 1, 18);
    }

    public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) {
        data = super.onSpawnWithEgg(data);
        int i = rand.nextInt(4);
        if (i == 0) {
            this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.swordArnor));
        } else if (i == 1 || i == 2) {
            this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.daggerArnor));
        } else if (i == 3 || i == 4) {
            this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.spearArnor));
        }
        if (rand.nextInt(4) == 0) {
            this.npcItemsInv.setSpearBackup(this.npcItemsInv.getMeleeWeapon());
            this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.spearArnor));
        }
        this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon());
        setCurrentItemOrArmor(1, new ItemStack(LOTRMod.bootsArnor));
        setCurrentItemOrArmor(2, new ItemStack(LOTRMod.legsArnor));
        setCurrentItemOrArmor(3, new ItemStack(LOTRMod.bodyArnor));
        setCurrentItemOrArmor(4, null);
        return data;
    }
    public String getSpeechBank(EntityPlayer entityplayer) {
        if (isFriendlyAndAligned(entityplayer)) {
            return "arnorSoldier/captain/friendly";
        }
        return "arnorSoldier/captain/neutral";
    }
}
