RequestEvaluate.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.gameserver.model.actor.instance.L2PcInstance;
  17. import com.l2jserver.gameserver.network.SystemMessageId;
  18. import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
  19. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  20. import com.l2jserver.gameserver.network.serverpackets.UserInfo;
  21. public final class RequestEvaluate extends L2GameClientPacket
  22. {
  23. private static final String _C__B9_REQUESTEVALUATE = "[C] B9 RequestEvaluate";
  24. @SuppressWarnings("unused")
  25. private int _targetId;
  26. @Override
  27. protected void readImpl()
  28. {
  29. _targetId = readD();
  30. }
  31. @Override
  32. protected void runImpl()
  33. {
  34. L2PcInstance activeChar = getClient().getActiveChar();
  35. if (activeChar == null)
  36. return;
  37. L2PcInstance target = (L2PcInstance) activeChar.getTarget();
  38. if (target == null)
  39. {
  40. activeChar.sendPacket(new SystemMessage(SystemMessageId.SELECT_TARGET));
  41. return;
  42. }
  43. if (!(activeChar.getTarget() instanceof L2PcInstance))
  44. {
  45. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  46. return;
  47. }
  48. if (activeChar.getLevel() < 10)
  49. {
  50. activeChar.sendPacket(new SystemMessage(SystemMessageId.ONLY_LEVEL_SUP_10_CAN_RECOMMEND));
  51. return;
  52. }
  53. if (activeChar.getTarget() == activeChar)
  54. {
  55. activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_CANNOT_RECOMMEND_YOURSELF));
  56. return;
  57. }
  58. if (activeChar.getRecomLeft() <= 0)
  59. {
  60. activeChar.sendPacket(new SystemMessage(SystemMessageId.NO_MORE_RECOMMENDATIONS_TO_HAVE));
  61. return;
  62. }
  63. if (target.getRecomHave() >= 255)
  64. {
  65. activeChar.sendPacket(new SystemMessage(SystemMessageId.YOUR_TARGET_NO_LONGER_RECEIVE_A_RECOMMENDATION));
  66. return;
  67. }
  68. if (!activeChar.canRecom(target))
  69. {
  70. activeChar.sendPacket(new SystemMessage(SystemMessageId.THAT_CHARACTER_IS_RECOMMENDED));
  71. return;
  72. }
  73. activeChar.giveRecom(target);
  74. SystemMessage sm = null;
  75. sm = new SystemMessage(SystemMessageId.YOU_HAVE_RECOMMENDED_C1_YOU_HAVE_S2_RECOMMENDATIONS_LEFT);
  76. sm.addPcName(target);
  77. sm.addNumber(activeChar.getRecomLeft());
  78. activeChar.sendPacket(sm);
  79. sm = new SystemMessage(SystemMessageId.YOU_HAVE_BEEN_RECOMMENDED_BY_C1);
  80. sm.addPcName(activeChar);
  81. target.sendPacket(sm);
  82. sm = null;
  83. activeChar.sendPacket(new UserInfo(activeChar));
  84. sendPacket(new ExBrExtraUserInfo(activeChar));
  85. target.broadcastUserInfo();
  86. }
  87. /* (non-Javadoc)
  88. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
  89. */
  90. @Override
  91. public String getType()
  92. {
  93. return _C__B9_REQUESTEVALUATE;
  94. }
  95. }