Package l2p.gameserver.model.base

Examples of l2p.gameserver.model.base.MultiSellEntry


    list.setKeepEnchant(false);
    list.setNoKey(true);
    int entId = 1;
    for(String SELLPET : SELLPETS)
    {
      MultiSellEntry e = L2Multisell.parseEntryFromStr(SELLPET);
      if(e != null)
      {
        e.setEntryId(entId++);
        list.addEntry(e);
      }
    }
    if(list.getEntries().size() == 0)
    {
View Full Code Here


      }
      L2Item itm = ItemTable.getInstance().getTemplate(i);
      int price = getSARemovePrice(itm);
      if(item[ItemTable.WEX_SA1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA1], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(i, 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA2], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(i, 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA3], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(i, 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_SA1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA1], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA2], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA3], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE], 1));
        list.addEntry(e1);
      }
    }
  }
View Full Code Here

      {
        continue;
      }
      if(item[ItemTable.WEX_FOUNDATION] > 0 && item[ItemTable.WEX_RARE] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_FOUNDATION], 1));
        if(item[ItemTable.WEX_VARNISH_COUNT] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(12374, item[ItemTable.WEX_VARNISH_COUNT]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE], 1));
        list.addEntry(e1);
      }
    }
    int[][] armors = ItemTable.getInstance().getArmorEx();
    for(int i = 0; i < armors.length; i++)
    {
      int[] item = armors[i];
      if(item == null)
      {
        continue;
      }
      if(item[ItemTable.AEX_FOUNDATION] <= 0)
      {
        continue;
      }
      if(item[ItemTable.AEX_SEALED_RARE_1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
        if(item[ItemTable.AEX_VARNISH] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.AEX_SEALED_RARE_1], 1));
        list.addEntry(e1);
        if(item[ItemTable.AEX_SEALED_RARE_2] > 0)
        {
          MultiSellEntry e2 = new MultiSellEntry(entId++);
          e2.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
          if(item[ItemTable.AEX_VARNISH] > 0)
          {
            e2.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
          }
          e2.addProduct(new MultiSellIngredient(item[ItemTable.AEX_SEALED_RARE_2], 1));
          list.addEntry(e2);
        }
        if(item[ItemTable.AEX_SEALED_RARE_3] > 0)
        {
          MultiSellEntry e3 = new MultiSellEntry(entId++);
          e3.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
          if(item[ItemTable.AEX_VARNISH] > 0)
          {
            e3.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
          }
          e3.addProduct(new MultiSellIngredient(item[ItemTable.AEX_SEALED_RARE_3], 1));
          list.addEntry(e3);
        }
      }
      else if(item[ItemTable.AEX_UNSEALED_RARE_1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
        if(item[ItemTable.AEX_VARNISH] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.AEX_UNSEALED_RARE_1], 1));
        list.addEntry(e1);
        if(item[ItemTable.AEX_UNSEALED_RARE_2] > 0)
        {
          MultiSellEntry e2 = new MultiSellEntry(entId++);
          e2.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
          if(item[ItemTable.AEX_VARNISH] > 0)
          {
            e2.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
          }
          e2.addProduct(new MultiSellIngredient(item[ItemTable.AEX_UNSEALED_RARE_2], 1));
          list.addEntry(e2);
        }
        if(item[ItemTable.AEX_UNSEALED_RARE_3] > 0)
        {
          MultiSellEntry e3 = new MultiSellEntry(entId++);
          e3.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
          if(item[ItemTable.AEX_VARNISH] > 0)
          {
            e3.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
          }
          e3.addProduct(new MultiSellIngredient(item[ItemTable.AEX_UNSEALED_RARE_3], 1));
          list.addEntry(e3);
        }
      }
    }
  }
View Full Code Here

      {
        continue;
      }
      if(item[ItemTable.WEX_PVP1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA1] > 0 ? item[ItemTable.WEX_SA1] : i, 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_PVP1], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_PVP2] > 0 && item[ItemTable.WEX_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA2], 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_PVP2], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_PVP3] > 0 && item[ItemTable.WEX_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA3], 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_PVP3], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP1] > 0 && (item[ItemTable.WEX_RARE_SA1] > 0 || item[ItemTable.WEX_RARE] > 0))
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA1] > 0 ? item[ItemTable.WEX_RARE_SA1] : item[ItemTable.WEX_RARE], 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP1], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP2] > 0 && item[ItemTable.WEX_RARE_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA2], 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP2], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP3] > 0 && item[ItemTable.WEX_RARE_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA3], 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP3], 1));
        list.addEntry(e1);
      }
    }
    int[][] armors = ItemTable.getInstance().getArmorEx();
    for(int i = 0; i < armors.length; i++)
    {
      int[] item = armors[i];
      if(item == null || item[ItemTable.AEX_PvP] <= 0)
      {
        continue;
      }
      L2Item itm = ItemTable.getInstance().getTemplate(item[ItemTable.AEX_UNSEALED_1] > 0 ? item[ItemTable.AEX_UNSEALED_1] : i);
      int[] price = getPvPArmorPrice(itm);
      if(price == null)
      {
        continue;
      }
      if(item[ItemTable.AEX_PvP] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(itm.getItemId(), 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.AEX_PvP], 1));
        list.addEntry(e1);
      }
    }
  }
View Full Code Here

      {
        continue;
      }
      if(item[ItemTable.WEX_PVP1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_PVP1], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_SA1] > 0 ? item[ItemTable.WEX_SA1] : i, 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_PVP2] > 0 && item[ItemTable.WEX_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_PVP2], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_SA2], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_PVP3] > 0 && item[ItemTable.WEX_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_PVP3], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_SA3], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP1], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA1] > 0 ? item[ItemTable.WEX_RARE_SA1] : item[ItemTable.WEX_RARE], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP2] > 0 && item[ItemTable.WEX_RARE_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP2], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA2], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP3] > 0 && item[ItemTable.WEX_RARE_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP3], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA3], 1));
        list.addEntry(e1);
      }
    }
    int[][] armors = ItemTable.getInstance().getArmorEx();
    for(int i = 0; i < armors.length; i++)
    {
      int[] item = armors[i];
      if(item == null)
      {
        continue;
      }
      L2Item itm = ItemTable.getInstance().getTemplate(i);
      int[] price = getPvPArmorPrice(itm);
      if(price == null)
      {
        continue;
      }
      if(item[ItemTable.AEX_PvP] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_PvP], 1));
        if(item[ItemTable.AEX_UNSEALED_1] > 0)
        {
          e1.addProduct(new MultiSellIngredient(item[ItemTable.AEX_UNSEALED_1], 1));
        }
        else
        {
          e1.addProduct(new MultiSellIngredient(i, 1));
        }
        list.addEntry(e1);
      }
    }
  }
View Full Code Here

      {
        for(Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
        {
          if("item".equalsIgnoreCase(d.getNodeName()))
          {
            MultiSellEntry e = parseEntry(d, id);
            if(e != null)
            {
              e.setEntryId(entId++);
              list.addEntry(e);
            }
          }
          else if("config".equalsIgnoreCase(d.getNodeName()))
          {
View Full Code Here

    return list;
  }

  protected MultiSellEntry parseEntry(Node n, int MultiSellId)
  {
    MultiSellEntry entry = new MultiSellEntry();
    l2p.util.Log.add(MultiSellId + " loading new entry", "multiselldebug");
    GArray<String> debuglist = new GArray<String>();
    for(Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
    {
      //l2p.util.Log.add(MultiSellId + " processing node " + d.getNodeName(), "multiselldebug");
      debuglist.add(d.getNodeName() + " " + d.getAttributes() + " " + d.getNodeName().hashCode() + " " + d.getNodeName().length());
      if(NODE_INGRIDIENT.equalsIgnoreCase(d.getNodeName()))
      {
        int id = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
        long count = Long.parseLong(d.getAttributes().getNamedItem("count").getNodeValue());
        int enchant = 0, element = L2Item.ATTRIBUTE_NONE, elementValue = 0;
        if(d.getAttributes().getNamedItem("enchant") != null)
        {
          enchant = Integer.parseInt(d.getAttributes().getNamedItem("enchant").getNodeValue());
        }
        if(d.getAttributes().getNamedItem("element") != null)
        {
          element = Integer.parseInt(d.getAttributes().getNamedItem("element").getNodeValue());
        }
        if(d.getAttributes().getNamedItem("elementValue") != null)
        {
          elementValue = Integer.parseInt(d.getAttributes().getNamedItem("elementValue").getNodeValue());
        }
        l2p.util.Log.add(MultiSellId + " loaded ingredient " + id + " count " + count, "multiselldebug");
        entry.addIngredient(new MultiSellIngredient(id, count, enchant, element, elementValue));
      }
      else if(NODE_PRODUCTION.equalsIgnoreCase(d.getNodeName()))
      {
        int id = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
        long count = Long.parseLong(d.getAttributes().getNamedItem("count").getNodeValue());
        int enchant = 0, element = L2Item.ATTRIBUTE_NONE, elementValue = 0;
        if(d.getAttributes().getNamedItem("enchant") != null)
        {
          enchant = Integer.parseInt(d.getAttributes().getNamedItem("enchant").getNodeValue());
        }
        if(d.getAttributes().getNamedItem("element") != null)
        {
          element = Integer.parseInt(d.getAttributes().getNamedItem("element").getNodeValue());
        }
        if(d.getAttributes().getNamedItem("elementValue") != null)
        {
          elementValue = Integer.parseInt(d.getAttributes().getNamedItem("elementValue").getNodeValue());
        }
        if(!Config.ALT_ALLOW_SHADOW_WEAPONS && id > 0)
        {
          L2Item item = ItemTable.getInstance().getTemplate(id);
          if(item != null && item.isShadowItem() && item.isWeapon() && !Config.ALT_ALLOW_SHADOW_WEAPONS)
          {
            return null;
          }
        }
        l2p.util.Log.add(MultiSellId + " loaded product " + id + " count " + count, "multiselldebug");
        entry.addProduct(new MultiSellIngredient(id, count, enchant, element, elementValue));
      }
      else
      {
        l2p.util.Log.add(MultiSellId + " skipping node " + d.getNodeName(), "multiselldebug");
      }
    }
    if(entry.getIngredients().isEmpty() || entry.getProduction().isEmpty())
    {
      l2p.util.Log.add(MultiSellId + " wrong node", "multiselldebug");
      l2p.util.Log.add(MultiSellId + " LIST: " + debuglist.toString(), "multiselldebug");
      for(Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
      {
        l2p.util.Log.add(d.getNodeName() + " " + d.getAttributes() + " " + d.getNodeName().hashCode() + " " + d.getNodeName().length() + " IsProduction: " + NODE_PRODUCTION.equalsIgnoreCase(d.getNodeName()), "multiselldebug");
      }
      return null;
    }
    if(entry.getIngredients().size() == 1 && entry.getProduction().size() == 1 && entry.getIngredients().get(0).getItemId() == 57)
    {
      L2Item item = ItemTable.getInstance().getTemplate(entry.getProduction().get(0).getItemId());
      if(item == null)
      {
        _log.warning("WARNING!!! MultiSell [" + MultiSellId + "] Production [" + entry.getProduction().get(0).getItemId() + "] is null");
        return null;
      }
      if(MultiSellId < 70000 || MultiSellId > 70010) // Все кроме GM Shop
      {
        if(item.getReferencePrice() > entry.getIngredients().get(0).getItemCount())
        {
          _log.warning("WARNING!!! MultiSell [" + MultiSellId + "] Production '" + item.getName() + "' [" + entry.getProduction().get(0).getItemId() + "] price is lower than referenced | " + item.getReferencePrice() + " > " + entry.getIngredients().get(0).getItemCount());
        }
      }
      //return null;
    }
    return entry;
View Full Code Here

    long[] ingredient, production;
    if((ingredient = parseItemIdAndCount(a[0])) == null || (production = parseItemIdAndCount(a[1])) == null)
    {
      return null;
    }
    MultiSellEntry entry = new MultiSellEntry();
    entry.addIngredient(new MultiSellIngredient((int) ingredient[0], ingredient[1]));
    entry.addProduct(new MultiSellIngredient((int) production[0], production[1]));
    return entry;
  }
View Full Code Here

          {
            final int entry = new int[]
            {
              itm.getItemId(), i.getItemId(), itm.getEnchantLevel()
            }.hashCode();
            MultiSellEntry possibleEntry = new MultiSellEntry(entry, i.getItemId(), 1, itm.getEnchantLevel());
            possibleEntry.addIngredient(new MultiSellIngredient(itm.getItemId(), 1, itm.getEnchantLevel()));
            list.entries.add(possibleEntry);
          }
        }
      }
    }
    // Hardcoded  - обмен вещей с доплатой за AA
    else if(listId == 9998)
    {
      list.setShowAll(false);
      list.setKeepEnchant(false);
      list.setNoTax(true);
      final Inventory inv = player.getInventory();
      _items = new GArray<L2ItemInstance>();
      for(final L2ItemInstance itm : inv.getItems())
      {
        if(itm.getItem().getAdditionalName().isEmpty() // Менять можно только обычные предметы
           && !itm.getItem().isSa() // SA менять нельзя
           && !itm.getItem().isRare() // Rare менять нельзя
           && !itm.getItem().isCommonItem() // Common менять нельзя
           && !itm.getItem().isPvP() // PvP менять нельзя
           && !itm.getItem().isShadowItem() // Shadow менять нельзя
           && !itm.isTemporalItem() // Temporal менять нельзя
           && !itm.isStackable() //
           && itm.getItem().getType2() == L2Item.TYPE2_WEAPON //
           && itm.getItem().getCrystalType() != Grade.NONE //
           && itm.getReferencePrice() <= Config.ALT_MAMMON_UPGRADE //
           && itm.getItem().getCrystalCount() > 0 //
           && !itm.isEquipped() //
           && itm.getItem().isTradeable() //
           && (itm.getCustomFlags() & L2ItemInstance.FLAG_NO_TRADE) != L2ItemInstance.FLAG_NO_TRADE //
        )
        {
          _items.add(itm);
        }
      }
      for(final L2ItemInstance itemtosell : _items)
      {
        for(final L2Weapon itemtobuy : ItemTable.getInstance().getAllWeapons())
        {
          if(itemtobuy.getAdditionalName().isEmpty() // Менять можно только обычные предметы
             && !itemtobuy.isSa() // На SA менять нельзя
             && !itemtobuy.isRare() // На Rare менять нельзя
             && !itemtobuy.isCommonItem() // На Common менять нельзя
             && !itemtobuy.isPvP() // На PvP менять нельзя
             && !itemtobuy.isShadowItem() // На Shadow менять нельзя
             && itemtobuy.isTradeable() //
             && itemtobuy.getType2() == L2Item.TYPE2_WEAPON //
             && itemtobuy.getItemType() == WeaponType.DUAL == (itemtosell.getItem().getItemType() == WeaponType.DUAL) //
             && itemtobuy.getCrystalType().ordinal() >= itemtosell.getItem().getCrystalType().ordinal() //
             && itemtobuy.getReferencePrice() <= Config.ALT_MAMMON_UPGRADE //
             && itemtosell.getItem().getReferencePrice() < itemtobuy.getReferencePrice() //
             && itemtosell.getReferencePrice() * 1.7 > itemtobuy.getReferencePrice() //
          )
          {
            final int entry = new int[]
            {
              itemtosell.getItemId(), itemtobuy.getItemId(), itemtosell.getEnchantLevel()
            }.hashCode();
            MultiSellEntry possibleEntry = new MultiSellEntry(entry, itemtobuy.getItemId(), 1, 0);
            possibleEntry.addIngredient(new MultiSellIngredient(itemtosell.getItemId(), 1, itemtosell.getEnchantLevel()));
            possibleEntry.addIngredient(new MultiSellIngredient((short) 5575, (int) ((itemtobuy.getReferencePrice() - itemtosell.getReferencePrice()) * 1.2), 0));
            list.entries.add(possibleEntry);
          }
        }
      }
    }
    // Hardcoded  - обмен вещей на кристаллы
    else if(listId == 9997)
    {
      list.setShowAll(false);
      list.setKeepEnchant(true);
      list.setNoTax(false);
      final Inventory inv = player.getInventory();
      for(final L2ItemInstance itm : inv.getItems())
      {
        if(!itm.isStackable() && itm.getItem().isCrystallizable() && itm.getItem().getCrystalType() != Grade.NONE && itm.getItem().getCrystalCount() > 0 && !itm.isShadowItem() && !itm.isTemporalItem() && !itm.isEquipped() && (itm.getCustomFlags() & L2ItemInstance.FLAG_NO_CRYSTALLIZE) != L2ItemInstance.FLAG_NO_CRYSTALLIZE)
        {
          final L2Item crystal = ItemTable.getInstance().getTemplate(itm.getItem().getCrystalType().cry);
          final int entry = new int[]
          {
            itm.getItemId(), itm.getEnchantLevel()
          }.hashCode();
          MultiSellEntry possibleEntry = new MultiSellEntry(entry, crystal.getItemId(), itm.getItem().getCrystalCount(), 0);
          possibleEntry.addIngredient(new MultiSellIngredient(itm.getItemId(), 1, itm.getEnchantLevel()));
          possibleEntry.addIngredient(new MultiSellIngredient((short) 57, (int) (itm.getItem().getCrystalCount() * crystal.getReferencePrice() * 0.05), 0));
          list.entries.add(possibleEntry);
        }
      }
    }
    // Все мультиселлы из датапака
    else
    {
      MultiSellListContainer container = L2Multisell.getInstance().getList(listId);
      if(container == null)
      {
        _log.warning("Not found myltisell " + listId);
        return null;
      }
      else if(container.isEmpty())
      {
        player.sendMessage(new CustomMessage("common.Disabled", player));
        return null;
      }
      boolean enchant = container.isKeepEnchant();
      boolean notax = container.isNoTax();
      boolean showall = container.isShowAll();
      boolean nokey = container.isNoKey();
      list.setShowAll(showall);
      list.setKeepEnchant(enchant);
      list.setNoTax(notax);
      list.setNoKey(nokey);
      final Inventory inv = player.getInventory();
      for(MultiSellEntry origEntry : container.getEntries())
      {
        MultiSellEntry ent = origEntry.clone();
        // Обработка налога, если лист не безналоговый
        // Адены добавляются в лист если отсутствуют или прибавляются к существующим
        GArray<MultiSellIngredient> ingridients;
        if(!notax && taxRate > 0.)
        {
          double tax = 0, adena = 0;
          ingridients = new GArray<MultiSellIngredient>(ent.getIngredients().size() + 1);
          for(MultiSellIngredient i : ent.getIngredients())
          {
            if(i.getItemId() == 57)
            {
              adena += i.getItemCount();
              tax += i.getItemCount() * (taxRate);
              continue;
            }
            ingridients.add(i);
            if(i.getItemId() == L2Item.ITEM_ID_CLAN_REPUTATION_SCORE)
            // hardcoded. Налог на клановую репутацию. Формула проверена на с6 и соответсвует на 100%.
            //TODO: Проверить на корейском(?) оффе налог на банг поинты и fame
            {
              tax += i.getItemCount() / 120 * 1000 * taxRate * 100;
            }
            if(i.getItemId() < 1)
            {
              continue;
            }
            final L2Item item = ItemTable.getInstance().getTemplate(i.getItemId());
            if(item == null)
            {
              System.out.println("Not found template for itemId: " + i.getItemId());
            }
            else if(item.isStackable())
            {
              tax += item.getReferencePrice() * i.getItemCount() * taxRate;
            }
          }
          adena = Math.round(adena + tax);
          if(adena >= 1)
          {
            ingridients.add(new MultiSellIngredient(57, (long) adena));
          }
          tax = Math.round(tax);
          if(tax >= 1)
          {
            ent.setTax((long) tax);
          }
          ent.getIngredients().clear();
          ent.getIngredients().addAll(ingridients);
        }
        else
        {
          ingridients = ent.getIngredients();
        }
        // Если стоит флаг "показывать все" не проверять наличие ингридиентов
        if(showall)
        {
          list.entries.add(ent);
        }
        else
        {
          GArray<Integer> _itm = new GArray<Integer>();
          // Проверка наличия у игрока ингридиентов
          for(MultiSellIngredient i : ingridients)
          {
            L2Item template = i.getItemId() <= 0 ? null : ItemTable.getInstance().getTemplate(i.getItemId());
            if(i.getItemId() <= 0 || template.getType2() <= L2Item.TYPE2_ACCESSORY || template.getType2() >= (nokey ? L2Item.TYPE2_OTHER : L2Item.TYPE2_PET_WOLF)) // Экипировка
            {
              if(i.getItemId() == 12374) // Mammon's Varnish Enhancer
              {
                continue;
              }
              //TODO: а мы должны тут сверять count?
              if(i.getItemId() == L2Item.ITEM_ID_CLAN_REPUTATION_SCORE)
              {
                if(!_itm.contains(i.getItemId()) && player.getClan() != null && player.getClan().getReputationScore() >= i.getItemCount())
                {
                  _itm.add(i.getItemId());
                }
                continue;
              }
              else if(i.getItemId() == L2Item.ITEM_ID_PC_BANG_POINTS)
              {
                if(!_itm.contains(i.getItemId()) && player.getPcBangPoints() >= i.getItemCount())
                {
                  _itm.add(i.getItemId());
                }
                continue;
              }
              else if(i.getItemId() == L2Item.ITEM_ID_FAME)
              {
                if(!_itm.contains(i.getItemId()) && player.getFame() >= i.getItemCount())
                {
                  _itm.add(i.getItemId());
                }
                continue;
              }
              for(final L2ItemInstance item : inv.getItems())
              {
                if(item.getItemId() == i.getItemId() && !item.isEquipped() && (item.getCustomFlags() & L2ItemInstance.FLAG_NO_TRADE) != L2ItemInstance.FLAG_NO_TRADE)
                {
                  if(_itm.contains(enchant ? i.getItemId() + i.getItemEnchant() * 100000 : i.getItemId())) // Не проверять одинаковые вещи
                  {
                    continue;
                  }
                  if(item.getEnchantLevel() < i.getItemEnchant()) // Некоторые мультиселлы требуют заточки
                  {
                    continue;
                  }
                  if(item.isStackable() && item.getCount() < i.getItemCount())
                  {
                    break;
                  }
                  _itm.add(enchant ? i.getItemId() + i.getItemEnchant() * 100000 : i.getItemId());
                  MultiSellEntry possibleEntry = new MultiSellEntry(enchant ? ent.getEntryId() + item.getEnchantLevel() * 100000 : ent.getEntryId());
                  for(MultiSellIngredient p : ent.getProduction())
                  {
                    p.setItemEnchant(item.getEnchantLevel());
                    possibleEntry.addProduct(p);
                  }
                  for(MultiSellIngredient ig : ingridients)
                  {
                    if(template != null && template.getType2() <= L2Item.TYPE2_ACCESSORY)
                    {
                      ig.setItemEnchant(item.getEnchantLevel());
                    }
                    possibleEntry.addIngredient(ig);
                  }
                  list.entries.add(possibleEntry);
                  break;
                }
              }
View Full Code Here

      {
        continue;
      }
      if(item[ItemTable.WEX_SA1] > 0 && item[ItemTable.WEX_SA_CRY1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(i, 1));
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA_CRY1], 1));
        e1.addIngredient(new MultiSellIngredient(price[0], price[1]));
        if(price[2] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(57, price[2]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_SA1], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_SA2] > 0 && item[ItemTable.WEX_SA_CRY2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(i, 1));
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA_CRY2], 1));
        e1.addIngredient(new MultiSellIngredient(price[0], price[1]));
        if(price[2] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(57, price[2]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_SA2], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_SA3] > 0 && item[ItemTable.WEX_SA_CRY3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(i, 1));
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA_CRY3], 1));
        e1.addIngredient(new MultiSellIngredient(price[0], price[1]));
        if(price[2] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(57, price[2]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_SA3], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_SA1] > 0 && item[ItemTable.WEX_SA_CRY1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE], 1));
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA_CRY1], 1));
        e1.addIngredient(new MultiSellIngredient(price[0], price[1]));
        if(price[2] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(57, price[2]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA1], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_SA2] > 0 && item[ItemTable.WEX_SA_CRY2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE], 1));
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA_CRY2], 1));
        e1.addIngredient(new MultiSellIngredient(price[0], price[1]));
        if(price[2] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(57, price[2]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA2], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_SA3] > 0 && item[ItemTable.WEX_SA_CRY3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE], 1));
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA_CRY3], 1));
        e1.addIngredient(new MultiSellIngredient(price[0], price[1]));
        if(price[2] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(57, price[2]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA3], 1));
        list.addEntry(e1);
      }
    }
  }
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.base.MultiSellEntry

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.