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

import com.zivilon.cinder_loe.CinderLoE;
import com.zivilon.cinder_loe.entity.npc.evil_human.Limwaith;
import lotr.common.LOTRAchievement;
import lotr.common.LOTRLevelData;
import lotr.common.LOTRMod;
import lotr.common.entity.npc.*;
import lotr.common.entity.npc.LOTRTradeEntries.TradeType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class AngmarOrcButcher extends LOTREntityAngmarOrc implements LOTRTradeable {
    public static LOTRTradeEntries ANGMAR_BUTCHER_BUY;
    public static LOTRTradeEntries ANGMAR_BUTCHER_SELL;

    public AngmarOrcButcher(World world) {
        super(world);
    }

    public LOTRTradeEntries getBuyPool() {
        return ANGMAR_BUTCHER_BUY;
    }

    public LOTRTradeEntries getSellPool() {
        return ANGMAR_BUTCHER_SELL;
    }

    public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) {
        data = super.onSpawnWithEgg(data);
        this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.axeAngmar));
        this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon());
        this.setCurrentItemOrArmor(1, new ItemStack(LOTRMod.bootsFur));
        this.setCurrentItemOrArmor(2, new ItemStack(LOTRMod.legsFur));
        this.setCurrentItemOrArmor(3, new ItemStack(LOTRMod.bodyBone));
        this.setCurrentItemOrArmor(4, new ItemStack(LOTRMod.helmetBone));
        return data;
    }

    public float getAlignmentBonus() {
        return 2.0F;
    }


    static {
        ANGMAR_BUTCHER_BUY = new LOTRTradeEntries(TradeType.BUY,
                new LOTRTradeEntry(new ItemStack(CinderLoE.flatbread), 2),
                new LOTRTradeEntry(new ItemStack(CinderLoE.maggotlessbread), 3),
                new LOTRTradeEntry(new ItemStack(CinderLoE.spiceIngredient, 1, 0), 500),
                new LOTRTradeEntry(new ItemStack(Items.bread), 2),
                new LOTRTradeEntry(new ItemStack(LOTRMod.axeAngmar), 10),
                new LOTRTradeEntry(new ItemStack(Items.cooked_chicken), 5),
                new LOTRTradeEntry(new ItemStack(Items.cooked_beef), 5),
                new LOTRTradeEntry(new ItemStack(Items.cooked_porkchop), 5),
                new LOTRTradeEntry(new ItemStack(Items.cooked_fished), 4),
                new LOTRTradeEntry(new ItemStack(Items.cooked_fished, 1), 4),
                new LOTRTradeEntry(new ItemStack(LOTRMod.rabbitCooked), 5),
                new LOTRTradeEntry(new ItemStack(LOTRMod.deerCooked), 5),
                new LOTRTradeEntry(new ItemStack(LOTRMod.muttonCooked), 5),
                new LOTRTradeEntry(new ItemStack(LOTRMod.manFlesh), 5));

        ANGMAR_BUTCHER_SELL = new LOTRTradeEntries(TradeType.SELL,
                new LOTRTradeEntry(new ItemStack(Items.string, 3), 1),
                new LOTRTradeEntry(new ItemStack(Items.feather, 1), 2),
                new LOTRTradeEntry(new ItemStack(Items.wheat, 2), 1),
                new LOTRTradeEntry(new ItemStack(LOTRMod.elfBone), 1),
                new LOTRTradeEntry(new ItemStack(LOTRMod.dwarfBone), 1),
                new LOTRTradeEntry(new ItemStack(Items.bone), 1),
                new LOTRTradeEntry(new ItemStack(LOTRMod.hobbitBone), 1),
                new LOTRTradeEntry(new ItemStack(LOTRMod.maggotyBread, 2), 2),
                new LOTRTradeEntry(new ItemStack(Items.bread, 1), 2),
                new LOTRTradeEntry(new ItemStack(Items.rotten_flesh, 2), 2),
                new LOTRTradeEntry(new ItemStack(Items.chicken), 3),
                new LOTRTradeEntry(new ItemStack(Items.beef), 3),
                new LOTRTradeEntry(new ItemStack(Items.porkchop), 3),
                new LOTRTradeEntry(new ItemStack(Items.fish), 2),
                new LOTRTradeEntry(new ItemStack(Items.fish, 1), 2),
                new LOTRTradeEntry(new ItemStack(LOTRMod.rabbitRaw), 3),
                new LOTRTradeEntry(new ItemStack(LOTRMod.deerRaw), 3),
                new LOTRTradeEntry(new ItemStack(LOTRMod.muttonRaw), 3),
                new LOTRTradeEntry(new ItemStack(LOTRMod.manFlesh), 3));
    }


    @Override
    public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) {

    }
    @Override
    public String getSpeechBank(EntityPlayer entityplayer) {
        if (this.isFriendlyAndAligned(entityplayer)) {
            if (this.canTradeWith(entityplayer)) {
                return "angmar/trader/friendly";
            }
            return "angmar/trader/neutral";
        }
        return "angmar/orc/hostile";
    }
    public boolean canTradeWith(EntityPlayer entityplayer) {
        return (LOTRLevelData.getData(entityplayer).getAlignment(getFaction()) >= 100.0F && isFriendlyAndAligned(entityplayer));
    }

    @Override
    public void onPlayerTrade(EntityPlayer entityplayer, LOTRTradeEntries.TradeType type, ItemStack itemstack) {
        LOTRLevelData.getData(entityplayer).addAchievement(LOTRAchievement.tradeAngmarTrader);
    }
    @Override
    public ItemStack getPickedResult(MovingObjectPosition target) {
        return null;
    }
}
