int tax = 0;
// Check for buylist validity and calculates summary values
int slots = 0;
int weight = 0;
L2ManorManagerInstance manor = (target != null && target instanceof L2ManorManagerInstance) ? (L2ManorManagerInstance)target : null;
for (int i = 0; i < _count; i++)
{
int itemId = _items[i * 2 + 0];
int count = _items[i * 2 + 1];
int price = 0;
if (count > Integer.MAX_VALUE)
{
Util.handleIllegalPlayerAction(player,"Warning!! Character "+player.getName()+" of account "+player.getAccountName()+" tried to purchase over "+Integer.MAX_VALUE+" items at the same time.", Config.DEFAULT_PUNISH);
SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED);
sendPacket(sm);
return;
}
L2Item template = ItemTable.getInstance().getTemplate(L2Manor.getInstance().getRewardItem(
itemId,manor.getCastle().getCrop(itemId,CastleManorManager.PERIOD_CURRENT).getReward()));
weight += count * template.getWeight();
if (!template.isStackable()) slots += count;
else if (player.getInventory().getItemByItemId(itemId) == null) slots++;
}
if (!player.getInventory().validateWeight(weight))
{
sendPacket(new SystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
return;
}
if (!player.getInventory().validateCapacity(slots))
{
sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
return;
}
// Proceed the purchase
InventoryUpdate playerIU = new InventoryUpdate();
_procureList = manor.getCastle().getCropProcure(CastleManorManager.PERIOD_CURRENT);
for (int i=0; i < _count; i++)
{
int itemId = _items[i * 2 + 0];
int count = _items[i * 2 + 1];
if (count < 0) count = 0;
int rewradItemId=L2Manor.getInstance().getRewardItem(
itemId,manor.getCastle().getCrop(itemId, CastleManorManager.PERIOD_CURRENT).getReward());
int rewradItemCount = 1; //L2Manor.getInstance().getRewardAmount(itemId, manor.getCastle().getCropReward(itemId));
rewradItemCount = count / rewradItemCount;