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

import lotr.common.entity.ai.LOTREntityAIAttackOnCollide;
import lotr.common.entity.npc.LOTREntityDunedain;
import lotr.common.entity.npc.LOTREntityDwarfWarrior;
import lotr.common.LOTRMod;
import lotr.common.LOTRShields;
import lotr.common.entity.npc.LOTREntityGondorSoldier;
import lotr.common.fac.LOTRFaction;
import lotr.common.quest.LOTRMiniQuest;
import lotr.common.quest.LOTRMiniQuestFactory;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

import com.zivilon.cinder_loe.CinderLoE;

public class ArnorSoldier extends LOTREntityDunedain {
    public ArnorSoldier(World world) {
        super(world);
        this.npcShield = LOTRShields.ALIGNMENT_RANGER;
    }

    @Override
    public void setupNPCGender() {
        this.familyInfo.setMale(true);
    }

    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.swordArnor));
        } 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, new ItemStack(LOTRMod.helmetArnor));
        return data;
    }

    @Override
    public LOTRFaction getFaction() {
        return LOTRFaction.RANGER_NORTH;
    }

    @Override
    public float getAlignmentBonus() {
        return 2.0f;
    }

    public String getSpeechBank(EntityPlayer entityplayer) {
        if (isFriendlyAndAligned(entityplayer)) {
            if (this.hiredNPCInfo.getHiringPlayer() == entityplayer)
                return "arnorSoldier/soldier/hired";
            return "arnorSoldier/soldier/friendly";
        }
        return "arnorSoldier/soldier/hostile";
    }

    @Override
    public LOTRMiniQuest createMiniQuest() {
        if (rand.nextInt(8) == 0) {
            return LOTRMiniQuestFactory.RANGER_NORTH_ARNOR_RELIC.createQuest(this);
        }
        return LOTRMiniQuestFactory.RANGER_NORTH.createQuest(this);
    }

    @Override
    public LOTRMiniQuestFactory getBountyHelpSpeechDir() {
        return LOTRMiniQuestFactory.RANGER_NORTH;
    }
    @Override
    public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) {
    }

    @Override
    public ItemStack getPickedResult(MovingObjectPosition target) {
        return new ItemStack(CinderLoE.spawnEgg, 1, 14);
    }
}
