Package l2p.gameserver.TradeController

Examples of l2p.gameserver.TradeController.NpcTradeList


          {
            player.sendPacket(Msg._HERE_YOU_CAN_BUY_ONLY_SEEDS_OF_S1_MANOR);
          }
          else
          {
            NpcTradeList tradeList = new NpcTradeList(0);
            GArray<SeedProduction> seeds = castle.getSeedProduction(CastleManorManager.PERIOD_CURRENT);
            for(SeedProduction s : seeds)
            {
              TradeItem item = new TradeItem();
              item.setItemId(s.getId());
              item.setOwnersPrice(s.getPrice());
              item.setCount(s.getCanProduce());
              if(item.getCount() > 0 && item.getOwnersPrice() > 0)
              {
                tradeList.addItem(item);
              }
            }
            BuyListSeed bl = new BuyListSeed(tradeList, castleId, player.getAdena());
            player.sendPacket(bl);
          }
View Full Code Here


    if(!player.getPlayerAccess().UseShop)
    {
      return;
    }
    player.tempInventoryDisable();
    NpcTradeList list = TradeController.getInstance().getBuyList(val);
    if(list != null)
    {
      ShopPreviewList bl = new ShopPreviewList(list, player.getAdena(), player.getExpertiseIndex());
      player.sendPacket(bl);
    }
View Full Code Here

      {
        taxRate = castle.getTaxRate();
      }
    }
    player.tempInventoryDisable();
    NpcTradeList list = TradeController.getInstance().getBuyList(listId);
    if(list == null || list.getNpcId() == getNpcId())
    {
      player.sendPacket(new ExBuySellList(list, player, taxRate));
    }
    else
    {
      _log.warning("[L2MerchantInstance] possible client hacker: " + player.getName() + " attempting to buy from GM shop! < Ban him!");
      _log.warning("buylist id:" + listId + " / list_npc = " + list.getNpcId() + " / npc = " + getNpcId());
    }
  }
View Full Code Here

    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
    NpcTradeList list = TradeController.getInstance().getBuyList(val);
    if(list != null)
    {
      activeChar.sendPacket(new ExBuySellList(list, activeChar, 0));
    }
    activeChar.sendActionFailed();
View Full Code Here

        if(activeChar.getInventory().getItemByItemId(itemId) != null)
        {
          needsSpace = 0;
        }
      }
      NpcTradeList list = TradeController.getInstance().getBuyList(_listId);
      if(list == null)
      {
        Log.add("tried to buy from non-exist list " + _listId, "errors", activeChar);
        activeChar.sendActionFailed();
        return;
      }
      TradeItem ti = getItemByItemId(itemId, list);
      price = ti == null ? 0 : ti.getOwnersPrice();
      if(itemId >= 3960 && itemId <= 4921)
      {
        price *= Config.RATE_SIEGE_GUARDS_PRICE;
      }
      if(price == 0 && !activeChar.getPlayerAccess().UseGMShop)
      {
        Util.handleIllegalPlayerAction(activeChar, "RequestBuyItem[191]", "Tried to buy zero price item, list " + _listId + " item " + itemId, 0);
        for(L2ItemInstance item : items)
        {
          item.deleteMe();
        }
        activeChar.sendMessage("Error: zero-price item! Please notify GM.");
        activeChar.sendActionFailed();
        return;
      }
      weight = items.get(i).getItem().getWeight();
      if(price < 0)
      {
        _log.warning("ERROR, no price found. Wrong buylist?");
        for(L2ItemInstance item : items)
        {
          item.deleteMe();
        }
        activeChar.sendActionFailed();
        return;
      }
      try
      {
        if(cnt < 0)
        {
          throw new ArithmeticException("cnt < 0");
        }
        subTotal = SafeMath.safeAddLong(subTotal, SafeMath.safeMulLong(cnt, price)); // Before tax
        tax = SafeMath.safeMulLong(subTotal, taxRate);
        totalCost = SafeMath.safeAddLong(subTotal, tax);
        if(totalCost < 0)
        {
          throw new ArithmeticException("213: Tried to purchase negative " + totalCost + " adena worth of goods.");
        }
        finalLoad = SafeMath.safeAddLong(finalLoad, SafeMath.safeMulLong(cnt, weight));
        if(finalLoad < 0)
        {
          throw new ArithmeticException("254: Tried to purchase negative " + finalLoad + " adena worth of goods.");
        }
      }
      catch(ArithmeticException e)
      {
        Util.handleIllegalPlayerAction(activeChar, "RequestBuyItem[157]", "merchant: " + merchant + ": " + e.getMessage(), 1);
        for(L2ItemInstance item : items)
        {
          item.deleteMe();
        }
        sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED, Msg.ActionFail);
        return;
      }
      if(needsSpace == 2)
      {
        finalCount += cnt;
      }
      else if(needsSpace == 1)
      {
        finalCount += 1;
      }
    }
    if(totalCost > currentMoney || subTotal < 0 || currentMoney <= 0)
    {
      for(L2ItemInstance item : items)
      {
        item.deleteMe();
      }
      sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA, Msg.ActionFail);
      return;
    }
    if(!activeChar.getInventory().validateWeight(finalLoad))
    {
      for(L2ItemInstance item : items)
      {
        item.deleteMe();
      }
      sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT, Msg.ActionFail);
      return;
    }
    if(!activeChar.getInventory().validateCapacity(finalCount))
    {
      for(L2ItemInstance item : items)
      {
        item.deleteMe();
      }
      sendPacket(Msg.YOUR_INVENTORY_IS_FULL, Msg.ActionFail);
      return;
    }
    // Для магазинов с ограниченным количеством товара число продаваемых предметов уменьшаем после всех проверок
    NpcTradeList list = TradeController.getInstance().getBuyList(_listId);
    for(int i = 0; i < items.size(); i++)
    {
      itemId = items.get(i).getItemId();
      cnt = items.get(i).getCount();
      TradeItem ic = getItemByItemId(itemId, list);
View Full Code Here

TOP

Related Classes of l2p.gameserver.TradeController.NpcTradeList

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.