Participant.java 3.8 KB

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