AuctionItem.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (C) 2004-2015 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.itemauction;
  20. import com.l2jserver.gameserver.datatables.ItemTable;
  21. import com.l2jserver.gameserver.model.L2Augmentation;
  22. import com.l2jserver.gameserver.model.StatsSet;
  23. import com.l2jserver.gameserver.model.items.L2Item;
  24. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  25. /**
  26. * @author Forsaiken
  27. */
  28. public final class AuctionItem
  29. {
  30. private final int _auctionItemId;
  31. private final int _auctionLength;
  32. private final long _auctionInitBid;
  33. private final int _itemId;
  34. private final long _itemCount;
  35. private final StatsSet _itemExtra;
  36. public AuctionItem(final int auctionItemId, final int auctionLength, final long auctionInitBid, final int itemId, final long itemCount, final StatsSet itemExtra)
  37. {
  38. _auctionItemId = auctionItemId;
  39. _auctionLength = auctionLength;
  40. _auctionInitBid = auctionInitBid;
  41. _itemId = itemId;
  42. _itemCount = itemCount;
  43. _itemExtra = itemExtra;
  44. }
  45. public final boolean checkItemExists()
  46. {
  47. final L2Item item = ItemTable.getInstance().getTemplate(_itemId);
  48. if (item == null)
  49. {
  50. return false;
  51. }
  52. return true;
  53. }
  54. public final int getAuctionItemId()
  55. {
  56. return _auctionItemId;
  57. }
  58. public final int getAuctionLength()
  59. {
  60. return _auctionLength;
  61. }
  62. public final long getAuctionInitBid()
  63. {
  64. return _auctionInitBid;
  65. }
  66. public final int getItemId()
  67. {
  68. return _itemId;
  69. }
  70. public final long getItemCount()
  71. {
  72. return _itemCount;
  73. }
  74. public final L2ItemInstance createNewItemInstance()
  75. {
  76. final L2ItemInstance item = ItemTable.getInstance().createItem("ItemAuction", _itemId, _itemCount, null, null);
  77. item.setEnchantLevel(item.getDefaultEnchantLevel());
  78. final int augmentationId = _itemExtra.getInt("augmentation_id", 0);
  79. if (augmentationId > 0)
  80. {
  81. item.setAugmentation(new L2Augmentation(augmentationId));
  82. }
  83. return item;
  84. }
  85. }