Ingredient.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Copyright (C) 2004-2013 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.model.multisell;
  20. import com.l2jserver.gameserver.datatables.ItemTable;
  21. import com.l2jserver.gameserver.model.items.L2Armor;
  22. import com.l2jserver.gameserver.model.items.L2Item;
  23. import com.l2jserver.gameserver.model.items.L2Weapon;
  24. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  25. /**
  26. * @author DS
  27. */
  28. public class Ingredient
  29. {
  30. private int _itemId;
  31. private long _itemCount;
  32. private boolean _isTaxIngredient;
  33. private boolean _maintainIngredient;
  34. private L2Item _template = null;
  35. private ItemInfo _itemInfo = null;
  36. public Ingredient(int itemId, long itemCount, boolean isTaxIngredient, boolean maintainIngredient)
  37. {
  38. _itemId = itemId;
  39. _itemCount = itemCount;
  40. _isTaxIngredient = isTaxIngredient;
  41. _maintainIngredient = maintainIngredient;
  42. if (_itemId > 0)
  43. {
  44. _template = ItemTable.getInstance().getTemplate(_itemId);
  45. }
  46. }
  47. /**
  48. * @return a new Ingredient instance with the same values as this.
  49. */
  50. public Ingredient getCopy()
  51. {
  52. return new Ingredient(_itemId, _itemCount, _isTaxIngredient, _maintainIngredient);
  53. }
  54. public final L2Item getTemplate()
  55. {
  56. return _template;
  57. }
  58. public final void setItemInfo(L2ItemInstance item)
  59. {
  60. _itemInfo = new ItemInfo(item);
  61. }
  62. public final void setItemInfo(ItemInfo info)
  63. {
  64. _itemInfo = info;
  65. }
  66. public final ItemInfo getItemInfo()
  67. {
  68. return _itemInfo;
  69. }
  70. public final int getEnchantLevel()
  71. {
  72. return _itemInfo != null ? _itemInfo.getEnchantLevel() : 0;
  73. }
  74. public final void setItemId(int itemId)
  75. {
  76. _itemId = itemId;
  77. }
  78. public final int getItemId()
  79. {
  80. return _itemId;
  81. }
  82. public final void setItemCount(long itemCount)
  83. {
  84. _itemCount = itemCount;
  85. }
  86. public final long getItemCount()
  87. {
  88. return _itemCount;
  89. }
  90. public final void setIsTaxIngredient(boolean isTaxIngredient)
  91. {
  92. _isTaxIngredient = isTaxIngredient;
  93. }
  94. public final boolean isTaxIngredient()
  95. {
  96. return _isTaxIngredient;
  97. }
  98. public final void setMaintainIngredient(boolean maintainIngredient)
  99. {
  100. _maintainIngredient = maintainIngredient;
  101. }
  102. public final boolean getMaintainIngredient()
  103. {
  104. return _maintainIngredient;
  105. }
  106. public final boolean isStackable()
  107. {
  108. return _template == null ? true : _template.isStackable();
  109. }
  110. public final boolean isArmorOrWeapon()
  111. {
  112. return _template == null ? false : (_template instanceof L2Armor) || (_template instanceof L2Weapon);
  113. }
  114. public final int getWeight()
  115. {
  116. return _template == null ? 0 : _template.getWeight();
  117. }
  118. }