AuctionItem.java 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.model.itemauction;
  16. import com.l2jserver.gameserver.datatables.ItemTable;
  17. import com.l2jserver.gameserver.model.L2Augmentation;
  18. import com.l2jserver.gameserver.model.StatsSet;
  19. import com.l2jserver.gameserver.model.item.L2Item;
  20. import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
  21. /**
  22. * @author Forsaiken
  23. */
  24. public final class AuctionItem
  25. {
  26. private final int _auctionItemId;
  27. private final int _auctionLength;
  28. private final long _auctionInitBid;
  29. private final int _itemId;
  30. private final long _itemCount;
  31. private final StatsSet _itemExtra;
  32. public AuctionItem(final int auctionItemId, final int auctionLength, final long auctionInitBid, final int itemId, final long itemCount, final StatsSet itemExtra)
  33. {
  34. _auctionItemId = auctionItemId;
  35. _auctionLength = auctionLength;
  36. _auctionInitBid = auctionInitBid;
  37. _itemId = itemId;
  38. _itemCount = itemCount;
  39. _itemExtra = itemExtra;
  40. }
  41. public final boolean checkItemExists()
  42. {
  43. final L2Item item = ItemTable.getInstance().getTemplate(_itemId);
  44. if (item == null)
  45. return false;
  46. return true;
  47. }
  48. public final int getAuctionItemId()
  49. {
  50. return _auctionItemId;
  51. }
  52. public final int getAuctionLength()
  53. {
  54. return _auctionLength;
  55. }
  56. public final long getAuctionInitBid()
  57. {
  58. return _auctionInitBid;
  59. }
  60. public final int getItemId()
  61. {
  62. return _itemId;
  63. }
  64. public final long getItemCount()
  65. {
  66. return _itemCount;
  67. }
  68. public final L2ItemInstance createNewItemInstance()
  69. {
  70. final L2ItemInstance item = ItemTable.getInstance().createItem("ItemAuction", _itemId, _itemCount, null, null);
  71. final int enchantLevel = _itemExtra.getInteger("enchant_level", 0);
  72. item.setEnchantLevel(enchantLevel);
  73. final int augmentationId = _itemExtra.getInteger("augmentation_id", 0);
  74. if (augmentationId != 0)
  75. {
  76. final int augmentationSkillId = _itemExtra.getInteger("augmentation_skill_id", 0);
  77. final int augmentationSkillLevel = _itemExtra.getInteger("augmentation_skill_lvl", 0);
  78. item.setAugmentation(new L2Augmentation(augmentationId, augmentationSkillId, augmentationSkillLevel));
  79. }
  80. return item;
  81. }
  82. }