Package l2p.gameserver.model.instances

Examples of l2p.gameserver.model.instances.L2ManorManagerInstance


    long subTotal = 0;
    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 = (int) _items[i * 2 + 0];
      long count = _items[i * 2 + 1];
      int price = 0;
      if(count < 0)
      {
        sendPacket(Msg.INCORRECT_ITEM_COUNT);
        return;
      }
      Castle castle = manor.getCastle();
      if(castle == null)
      {
        return;
      }
      CropProcure crop = castle.getCrop(itemId, CastleManorManager.PERIOD_CURRENT);
      if(crop == null)
      {
        return;
      }
      int rewardId = L2Manor.getInstance().getRewardItem(itemId, crop.getReward());
      L2Item template = ItemTable.getInstance().getTemplate(rewardId);
      weight += count * template.getWeight();
      long add_slot = 0;
      if(!template.isStackable())
      {
        add_slot = count;
      }
      else if(player.getInventory().getItemByItemId(itemId) == null)
      {
        add_slot = 1;
      }
      if(add_slot > 0)
      {
        try
        {
          slots = SafeMath.safeAddInt(slots, add_slot);
        }
        catch(ArithmeticException e)
        {
          sendPacket(Msg.INCORRECT_ITEM_COUNT);
          return;
        }
      }
    }
    if(!player.getInventory().validateWeight(weight))
    {
      sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
      return;
    }
    if(!player.getInventory().validateCapacity(slots))
    {
      sendPacket(Msg.YOUR_INVENTORY_IS_FULL);
      return;
    }
    // Proceed the purchase
    _procureList = manor.getCastle().getCropProcure(CastleManorManager.PERIOD_CURRENT);
    for(int i = 0; i < _count; i++)
    {
      int itemId = (int) _items[i * 2 + 0];
      long count = _items[i * 2 + 1];
      if(count < 0)
      {
        count = 0;
      }
      int rewradItemId = L2Manor.getInstance().getRewardItem(itemId, manor.getCastle().getCrop(itemId, CastleManorManager.PERIOD_CURRENT).getReward());
      long rewradItemCount = L2Manor.getInstance().getRewardAmountPerCrop(manor.getCastle().getId(), itemId, manor.getCastle().getCropRewardType(itemId));
      rewradItemCount = count * rewradItemCount;
      // Add item to Inventory and adjust update packet
      L2ItemInstance item = player.getInventory().addItem(rewradItemId, rewradItemCount);
      L2ItemInstance iteme = player.getInventory().destroyItemByItemId(itemId, count, true);
      if(item == null || iteme == null)
View Full Code Here


    }
    if(!player.isGM() && (target == null || !(target instanceof L2ManorManagerInstance) || !player.isInRange(target, L2Character.INTERACTION_DISTANCE)))
    {
      return;
    }
    L2ManorManagerInstance manorManager = (L2ManorManagerInstance) target;
    int currentManorId = manorManager.getCastle().getId();
    // Calculate summary values
    int slots = 0;
    int weight = 0;
    for(int i = 0; i < _size; i++)
    {
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.instances.L2ManorManagerInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.