ExOlympiadUserInfo.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.serverpackets;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.gameserver.model.olympiad.Participant;
  22. /**
  23. * @author godson
  24. */
  25. public class ExOlympiadUserInfo extends L2GameServerPacket
  26. {
  27. private final L2PcInstance _player;
  28. private Participant _par = null;
  29. private int _curHp;
  30. private int _maxHp;
  31. private int _curCp;
  32. private int _maxCp;
  33. public ExOlympiadUserInfo(L2PcInstance player)
  34. {
  35. _player = player;
  36. if (_player != null)
  37. {
  38. _curHp = (int) _player.getCurrentHp();
  39. _maxHp = _player.getMaxHp();
  40. _curCp = (int) _player.getCurrentCp();
  41. _maxCp = _player.getMaxCp();
  42. }
  43. else
  44. {
  45. _curHp = 0;
  46. _maxHp = 100;
  47. _curCp = 0;
  48. _maxCp = 100;
  49. }
  50. }
  51. public ExOlympiadUserInfo(Participant par)
  52. {
  53. _par = par;
  54. _player = par.getPlayer();
  55. if (_player != null)
  56. {
  57. _curHp = (int) _player.getCurrentHp();
  58. _maxHp = _player.getMaxHp();
  59. _curCp = (int) _player.getCurrentCp();
  60. _maxCp = _player.getMaxCp();
  61. }
  62. else
  63. {
  64. _curHp = 0;
  65. _maxHp = 100;
  66. _curCp = 0;
  67. _maxCp = 100;
  68. }
  69. }
  70. @Override
  71. protected final void writeImpl()
  72. {
  73. writeC(0xFE);
  74. writeH(0x7A);
  75. if (_player != null)
  76. {
  77. writeC(_player.getOlympiadSide());
  78. writeD(_player.getObjectId());
  79. writeS(_player.getName());
  80. writeD(_player.getClassId().getId());
  81. }
  82. else
  83. {
  84. writeC(_par.getSide());
  85. writeD(_par.getObjectId());
  86. writeS(_par.getName());
  87. writeD(_par.getBaseClass());
  88. }
  89. writeD(_curHp);
  90. writeD(_maxHp);
  91. writeD(_curCp);
  92. writeD(_maxCp);
  93. }
  94. }