Participant.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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.model.olympiad;
  16. import com.l2jserver.gameserver.model.L2World;
  17. import com.l2jserver.gameserver.model.StatsSet;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. /**
  20. * @author DS, Zoey76
  21. */
  22. public final class Participant
  23. {
  24. private final int objectId;
  25. private L2PcInstance player;
  26. private final String name;
  27. private final int side;
  28. private final int baseClass;
  29. private boolean disconnected = false;
  30. private boolean defaulted = false;
  31. private final StatsSet stats;
  32. public String clanName;
  33. public int clanId;
  34. public Participant(L2PcInstance plr, int olympiadSide)
  35. {
  36. objectId = plr.getObjectId();
  37. player = plr;
  38. name = plr.getName();
  39. side = olympiadSide;
  40. baseClass = plr.getBaseClass();
  41. stats = Olympiad.getNobleStats(getObjectId());
  42. clanName = plr.getClan() != null ? plr.getClan().getName() : "";
  43. clanId = plr.getClanId();
  44. }
  45. public Participant(int objId, int olympiadSide)
  46. {
  47. objectId = objId;
  48. player = null;
  49. name = "-";
  50. side = olympiadSide;
  51. baseClass = 0;
  52. stats = null;
  53. clanName = "";
  54. clanId = 0;
  55. }
  56. /**
  57. * Updates the reference to {@link #player}, if it's null or appears off-line.
  58. * @return {@code true} if after the update the player isn't null, {@code false} otherwise.
  59. */
  60. public final boolean updatePlayer()
  61. {
  62. if ((player == null) || !player.isOnline())
  63. {
  64. player = L2World.getInstance().getPlayer(getObjectId());
  65. }
  66. return (player != null);
  67. }
  68. /**
  69. * @param statName
  70. * @param increment
  71. */
  72. public final void updateStat(String statName, int increment)
  73. {
  74. stats.set(statName, Math.max(stats.getInteger(statName) + increment, 0));
  75. }
  76. /**
  77. * @return the name the player's name.
  78. */
  79. public String getName()
  80. {
  81. return name;
  82. }
  83. /**
  84. * @return the name the player's clan name.
  85. */
  86. public String getClanName()
  87. {
  88. return clanName;
  89. }
  90. /**
  91. * @return the name the player's id.
  92. */
  93. public int getClanId()
  94. {
  95. return clanId;
  96. }
  97. /**
  98. * @return the player
  99. */
  100. public L2PcInstance getPlayer()
  101. {
  102. return player;
  103. }
  104. /**
  105. * @return the objectId
  106. */
  107. public int getObjectId()
  108. {
  109. return objectId;
  110. }
  111. /**
  112. * @return the stats
  113. */
  114. public StatsSet getStats()
  115. {
  116. return stats;
  117. }
  118. /**
  119. * @param noble the player to set
  120. */
  121. public void setPlayer(L2PcInstance noble)
  122. {
  123. player = noble;
  124. }
  125. /**
  126. * @return the side
  127. */
  128. public int getSide()
  129. {
  130. return side;
  131. }
  132. /**
  133. * @return the baseClass
  134. */
  135. public int getBaseClass()
  136. {
  137. return baseClass;
  138. }
  139. /**
  140. * @return the disconnected
  141. */
  142. public boolean isDisconnected()
  143. {
  144. return disconnected;
  145. }
  146. /**
  147. * @param val the disconnected to set
  148. */
  149. public void setDisconnected(boolean val)
  150. {
  151. disconnected = val;
  152. }
  153. /**
  154. * @return the defaulted
  155. */
  156. public boolean isDefaulted()
  157. {
  158. return defaulted;
  159. }
  160. /**
  161. * @param val the value to set.
  162. */
  163. public void setDefaulted(boolean val)
  164. {
  165. defaulted = val;
  166. }
  167. }