RequestConfirmCancelItem.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.network.clientpackets;
  16. import com.l2jserver.Config;
  17. import com.l2jserver.gameserver.model.L2ItemInstance;
  18. import com.l2jserver.gameserver.model.L2World;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.SystemMessageId;
  21. import com.l2jserver.gameserver.network.serverpackets.ExPutItemResultForVariationCancel;
  22. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  23. import com.l2jserver.gameserver.templates.item.L2Item;
  24. import com.l2jserver.gameserver.util.Util;
  25. /**
  26. * Format(ch) d
  27. * @author -Wooden-
  28. */
  29. public final class RequestConfirmCancelItem extends L2GameClientPacket
  30. {
  31. private static final String _C__D0_2D_REQUESTCONFIRMCANCELITEM = "[C] D0:2D RequestConfirmCancelItem";
  32. private int _itemId;
  33. /**
  34. * @param buf
  35. * @param client
  36. */
  37. @Override
  38. protected void readImpl()
  39. {
  40. _itemId = readD();
  41. }
  42. /**
  43. * @see com.l2jserver.util.network.BaseRecievePacket.ClientBasePacket#runImpl()
  44. */
  45. @Override
  46. protected void runImpl()
  47. {
  48. final L2PcInstance activeChar = getClient().getActiveChar();
  49. final L2ItemInstance item = (L2ItemInstance)L2World.getInstance().findObject(_itemId);
  50. if (activeChar == null || item == null)
  51. return;
  52. if (item.getOwnerId() != activeChar.getObjectId())
  53. {
  54. Util.handleIllegalPlayerAction(getClient().getActiveChar(),"Warning!! Character "+getClient().getActiveChar().getName()+" of account "+getClient().getActiveChar().getAccountName()+" tryied to destroy augment on item that doesn't own.",Config.DEFAULT_PUNISH);
  55. return;
  56. }
  57. if (!item.isAugmented())
  58. {
  59. activeChar.sendPacket(new SystemMessage(SystemMessageId.AUGMENTATION_REMOVAL_CAN_ONLY_BE_DONE_ON_AN_AUGMENTED_ITEM));
  60. return;
  61. }
  62. if (item.isPvp())
  63. {
  64. activeChar.sendPacket(new SystemMessage(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM));
  65. return;
  66. }
  67. int price=0;
  68. switch (item.getItem().getCrystalType())
  69. {
  70. case L2Item.CRYSTAL_C:
  71. if (item.getCrystalCount() < 1720)
  72. price = 95000;
  73. else if (item.getCrystalCount() < 2452)
  74. price = 150000;
  75. else
  76. price = 210000;
  77. break;
  78. case L2Item.CRYSTAL_B:
  79. if (item.getCrystalCount() < 1746)
  80. price = 240000;
  81. else
  82. price = 270000;
  83. break;
  84. case L2Item.CRYSTAL_A:
  85. if (item.getCrystalCount() < 2160)
  86. price = 330000;
  87. else if (item.getCrystalCount() < 2824)
  88. price = 390000;
  89. else
  90. price = 420000;
  91. break;
  92. case L2Item.CRYSTAL_S:
  93. price = 480000;
  94. break;
  95. case L2Item.CRYSTAL_S80:
  96. case L2Item.CRYSTAL_S84:
  97. price = 920000;
  98. break;
  99. // any other item type is not augmentable
  100. default:
  101. return;
  102. }
  103. activeChar.sendPacket(new ExPutItemResultForVariationCancel(_itemId, price));
  104. }
  105. /**
  106. * @see com.l2jserver.gameserver.BasePacket#getType()
  107. */
  108. @Override
  109. public String getType()
  110. {
  111. return _C__D0_2D_REQUESTCONFIRMCANCELITEM;
  112. }
  113. }