package net.sf.l2j.gameserver.custom.bot.ai.store;
import java.util.ArrayList;
import java.util.List;
import net.sf.l2j.commons.random.Rnd;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.custom.bot.FakePlayer;
import net.sf.l2j.gameserver.custom.bot.ai.FakePlayerAI;
import net.sf.l2j.gameserver.enums.actors.OperateType;
import net.sf.l2j.gameserver.fakeplayer.util.PhantomPlayerUtils;
import net.sf.l2j.gameserver.network.serverpackets.PrivateStoreMsgBuy;
public class PrivateStoreBuyAI extends FakePlayerAI
{
public PrivateStoreBuyAI(FakePlayer character)
{
super(character);
setup();
}
@Override
public void setup()
{
_fakePlayer.setRunning(true);
}
@Override
public void thinkAndAct()
{
setBusyThinking(true);
handleDeath();
if ((Config.PHANTOM_PRIVATE_STORE))
{
_fakePlayer.addItem(":", 57, 1000000000, _fakePlayer, false);
_fakePlayer.getBuyList().addItemByItemId(getPrivateBuy(), 1, Rnd.get(1000, 24678), 0);
_fakePlayer.getBuyList().setTitle(getPrivateBuy_Title());
_fakePlayer.sitDown();
_fakePlayer.setOperateType(OperateType.BUY);
_fakePlayer.getBuyList().setPackaged(OperateType.BUY == OperateType.BUY_MANAGE);
_fakePlayer.broadcastUserInfo();
_fakePlayer.broadcastPacket(new PrivateStoreMsgBuy(_fakePlayer));
}
if (Rnd.nextInt(80) == 0)
PhantomPlayerUtils.maybeTrade(_fakePlayer);
}
static int getPrivateBuy()
{
return Config.LIST_PRIVATE_BUY.get(Rnd.get(Config.LIST_PRIVATE_BUY.size())).intValue();
}
static final List<String> listMsgBuy = new ArrayList<>();
static String getPrivateBuy_Title()
{
String msg = Config.PHANTOM_PRIVATE_BUY_TITLE.get(Rnd.get(Config.PHANTOM_PRIVATE_BUY_TITLE.size()));
if (listMsgBuy.contains(msg))
{
boolean gerar = true;
while (gerar)
{
msg = Config.PHANTOM_PRIVATE_BUY_TITLE.get(Rnd.get(Config.PHANTOM_PRIVATE_BUY_TITLE.size()));
if (!listMsgBuy.contains(msg))
{
listMsgBuy.add(msg);
gerar = false;
return msg;
}
if (listMsgBuy.size() == Config.PHANTOM_PRIVATE_BUY_TITLE.size())
{
gerar = false;
return "";
}
}
}
else if (!listMsgBuy.contains(msg))
{
listMsgBuy.add(msg);
return msg;
}
return msg;
}
}