RequestEvaluate.java 3.8 KB

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