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

import com.zivilon.cinder_loe.CinderLoE;

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

import static lotr.common.entity.npc.LOTRTradeEntries.HARAD_FISHMONGER_BUY;
import static lotr.common.entity.npc.LOTRTradeEntries.HARAD_FISHMONGER_SELL;

public class LimwaithFishmonger extends Limwaith implements LOTRTradeable {

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

    public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) {
        data = super.onSpawnWithEgg(data);
        this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.tridentLimwaith));
        this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon());
        return data;
    }

    public LOTRTradeEntries getBuyPool() {
        return HARAD_FISHMONGER_BUY;
    }

    public LOTRTradeEntries getSellPool() {
        return HARAD_FISHMONGER_SELL;
    }

    public float getAlignmentBonus() {
        return 2.0F;
    }

    protected void dropFewItems(boolean flag, int i) {
        super.dropFewItems(flag, i);
        dropItem(getLimwaithTraderDrop(), 1 + rand.nextInt(3) + rand.nextInt(i + 1));
    }
    protected Item getLimwaithTraderDrop() {
        return LOTRMod.pearl;
    }

    public boolean canTradeWith(EntityPlayer entityplayer) {
        return (LOTRLevelData.getData(entityplayer).getAlignment(getFaction()) >= 100.0F && isFriendlyAndAligned(entityplayer));
    }

    @Override
    public void onPlayerTrade(EntityPlayer entityplayer, TradeType type, ItemStack itemstack) {
    }

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

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