RequestConfirmCancelItem.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.network.clientpackets;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  23. import com.l2jserver.gameserver.network.SystemMessageId;
  24. import com.l2jserver.gameserver.network.serverpackets.ExPutItemResultForVariationCancel;
  25. import com.l2jserver.gameserver.util.Util;
  26. /**
  27. * Format(ch) d
  28. * @author -Wooden-
  29. */
  30. public final class RequestConfirmCancelItem extends L2GameClientPacket
  31. {
  32. private static final String _C__D0_42_REQUESTCONFIRMCANCELITEM = "[C] D0:42 RequestConfirmCancelItem";
  33. private int _objectId;
  34. @Override
  35. protected void readImpl()
  36. {
  37. _objectId = readD();
  38. }
  39. @Override
  40. protected void runImpl()
  41. {
  42. final L2PcInstance activeChar = getClient().getActiveChar();
  43. if (activeChar == null)
  44. {
  45. return;
  46. }
  47. final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
  48. if (item == null)
  49. {
  50. return;
  51. }
  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(SystemMessageId.AUGMENTATION_REMOVAL_CAN_ONLY_BE_DONE_ON_AN_AUGMENTED_ITEM);
  60. return;
  61. }
  62. if (item.isPvp() && !Config.ALT_ALLOW_AUGMENT_PVP_ITEMS)
  63. {
  64. activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
  65. return;
  66. }
  67. int price = 0;
  68. switch (item.getItem().getCrystalType())
  69. {
  70. case C:
  71. if (item.getCrystalCount() < 1720)
  72. {
  73. price = 95000;
  74. }
  75. else if (item.getCrystalCount() < 2452)
  76. {
  77. price = 150000;
  78. }
  79. else
  80. {
  81. price = 210000;
  82. }
  83. break;
  84. case B:
  85. if (item.getCrystalCount() < 1746)
  86. {
  87. price = 240000;
  88. }
  89. else
  90. {
  91. price = 270000;
  92. }
  93. break;
  94. case A:
  95. if (item.getCrystalCount() < 2160)
  96. {
  97. price = 330000;
  98. }
  99. else if (item.getCrystalCount() < 2824)
  100. {
  101. price = 390000;
  102. }
  103. else
  104. {
  105. price = 420000;
  106. }
  107. break;
  108. case S:
  109. price = 480000;
  110. break;
  111. case S80:
  112. case S84:
  113. price = 920000;
  114. break;
  115. // TODO: S84 TOP price 3.2M
  116. // any other item type is not augmentable
  117. default:
  118. return;
  119. }
  120. activeChar.sendPacket(new ExPutItemResultForVariationCancel(item, price));
  121. }
  122. @Override
  123. public String getType()
  124. {
  125. return _C__D0_42_REQUESTCONFIRMCANCELITEM;
  126. }
  127. }