AuctionItem.java 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.items.L2Item;
  20. import com.l2jserver.gameserver.model.items.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. {
  46. return false;
  47. }
  48. return true;
  49. }
  50. public final int getAuctionItemId()
  51. {
  52. return _auctionItemId;
  53. }
  54. public final int getAuctionLength()
  55. {
  56. return _auctionLength;
  57. }
  58. public final long getAuctionInitBid()
  59. {
  60. return _auctionInitBid;
  61. }
  62. public final int getItemId()
  63. {
  64. return _itemId;
  65. }
  66. public final long getItemCount()
  67. {
  68. return _itemCount;
  69. }
  70. public final L2ItemInstance createNewItemInstance()
  71. {
  72. final L2ItemInstance item = ItemTable.getInstance().createItem("ItemAuction", _itemId, _itemCount, null, null);
  73. item.setEnchantLevel(item.getDefaultEnchantLevel());
  74. final int augmentationId = _itemExtra.getInteger("augmentation_id", 0);
  75. if (augmentationId != 0)
  76. {
  77. final int augmentationSkillId = _itemExtra.getInteger("augmentation_skill_id", 0);
  78. final int augmentationSkillLevel = _itemExtra.getInteger("augmentation_skill_lvl", 0);
  79. item.setAugmentation(new L2Augmentation(augmentationId, augmentationSkillId, augmentationSkillLevel));
  80. }
  81. return item;
  82. }
  83. }