package com.zivilon.cinder_loe.character;

import lotr.common.entity.npc.LOTREntityNPC;
import lotr.common.entity.npc.LOTRHireableBase;
import lotr.common.entity.npc.LOTRUnitTradeEntry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

public class MouthOfSauronEntityHandler extends LOTRUnitTradeEntry {

    private final LOTREntityNPC npc;

    public MouthOfSauronEntityHandler(LOTREntityNPC npc, float alignmentRequired) {
        super(npc.getClass(), 0 /*costless*/, alignmentRequired);
        this.npc = npc;
    }

    @Override
    public LOTREntityNPC getOrCreateHiredNPC(World world) {
        // Return the very same NPC, no new spawn.
        return npc;
    }

    @Override
    public boolean hasRequiredCostAndAlignment(EntityPlayer player, LOTRHireableBase trader) {
        // If they're already hired, disallow re-hiring
        if (npc.hiredNPCInfo != null && npc.hiredNPCInfo.isActive) {
            return false;
        }
        return super.hasRequiredCostAndAlignment(player, trader);
    }
}
