RequestConfirmCancelItem.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 net.sf.l2j.gameserver.clientpackets;
  16. import net.sf.l2j.gameserver.model.L2ItemInstance;
  17. import net.sf.l2j.gameserver.model.L2World;
  18. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  19. import net.sf.l2j.gameserver.network.SystemMessageId;
  20. import net.sf.l2j.gameserver.serverpackets.ExPutItemResultForVariationCancel;
  21. import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  22. import net.sf.l2j.gameserver.templates.L2Item;
  23. /**
  24. * Format(ch) d
  25. * @author -Wooden-
  26. */
  27. public final class RequestConfirmCancelItem extends L2GameClientPacket
  28. {
  29. private static final String _C__D0_2D_REQUESTCONFIRMCANCELITEM = "[C] D0:2D RequestConfirmCancelItem";
  30. private int _itemId;
  31. /**
  32. * @param buf
  33. * @param client
  34. */
  35. @Override
  36. protected void readImpl()
  37. {
  38. _itemId = readD();
  39. }
  40. /**
  41. * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#runImpl()
  42. */
  43. @Override
  44. protected
  45. void runImpl()
  46. {
  47. L2PcInstance activeChar = getClient().getActiveChar();
  48. L2ItemInstance item = (L2ItemInstance)L2World.getInstance().findObject(_itemId);
  49. if (activeChar == null || item == null) return;
  50. if (!item.isAugmented())
  51. {
  52. activeChar.sendPacket(new SystemMessage(SystemMessageId.AUGMENTATION_REMOVAL_CAN_ONLY_BE_DONE_ON_AN_AUGMENTED_ITEM));
  53. return;
  54. }
  55. int price=0;
  56. switch (item.getItem().getItemGrade())
  57. {
  58. case L2Item.CRYSTAL_C:
  59. if (item.getCrystalCount() < 1720)
  60. price = 95000;
  61. else if (item.getCrystalCount() < 2452)
  62. price = 150000;
  63. else
  64. price = 210000;
  65. break;
  66. case L2Item.CRYSTAL_B:
  67. if (item.getCrystalCount() < 1746)
  68. price = 240000;
  69. else
  70. price = 270000;
  71. break;
  72. case L2Item.CRYSTAL_A:
  73. if (item.getCrystalCount() < 2160)
  74. price = 330000;
  75. else if (item.getCrystalCount() < 2824)
  76. price = 390000;
  77. else
  78. price = 420000;
  79. break;
  80. case L2Item.CRYSTAL_S:
  81. case L2Item.CRYSTAL_S80:
  82. price = 480000;
  83. break;
  84. // any other item type is not augmentable
  85. default:
  86. return;
  87. }
  88. activeChar.sendPacket(new ExPutItemResultForVariationCancel(_itemId, price));
  89. }
  90. /**
  91. * @see net.sf.l2j.gameserver.BasePacket#getType()
  92. */
  93. @Override
  94. public String getType()
  95. {
  96. return _C__D0_2D_REQUESTCONFIRMCANCELITEM;
  97. }
  98. }