Participant.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 Participant(L2PcInstance plr, int olympiadSide)
  33. {
  34. objectId = plr.getObjectId();
  35. player = plr;
  36. name = plr.getName();
  37. side = olympiadSide;
  38. baseClass = plr.getBaseClass();
  39. stats = Olympiad.getNobleStats(getObjectId());
  40. }
  41. public Participant(int objId, int olympiadSide)
  42. {
  43. objectId = objId;
  44. player = null;
  45. name = "-";
  46. side = olympiadSide;
  47. baseClass = 0;
  48. stats = null;
  49. }
  50. /**
  51. * Updates the reference to {@link #player}, if it's null or appears off-line.
  52. * @return {@code true} if after the update the player isn't null, {@code false} otherwise.
  53. */
  54. public final boolean updatePlayer()
  55. {
  56. if ((player == null) || !player.isOnline())
  57. {
  58. player = L2World.getInstance().getPlayer(getObjectId());
  59. }
  60. return (player != null);
  61. }
  62. /**
  63. * @param statName
  64. * @param increment
  65. */
  66. public final void updateStat(String statName, int increment)
  67. {
  68. stats.set(statName, Math.max(stats.getInteger(statName) + increment, 0));
  69. }
  70. /**
  71. * @return the name the player's name.
  72. */
  73. public String getName()
  74. {
  75. return name;
  76. }
  77. /**
  78. * @return the player
  79. */
  80. public L2PcInstance getPlayer()
  81. {
  82. return player;
  83. }
  84. /**
  85. * @return the objectId
  86. */
  87. public int getObjectId()
  88. {
  89. return objectId;
  90. }
  91. /**
  92. * @return the stats
  93. */
  94. public StatsSet getStats()
  95. {
  96. return stats;
  97. }
  98. /**
  99. * @param noble the player to set
  100. */
  101. public void setPlayer(L2PcInstance noble)
  102. {
  103. player = noble;
  104. }
  105. /**
  106. * @return the side
  107. */
  108. public int getSide()
  109. {
  110. return side;
  111. }
  112. /**
  113. * @return the baseClass
  114. */
  115. public int getBaseClass()
  116. {
  117. return baseClass;
  118. }
  119. /**
  120. * @return the disconnected
  121. */
  122. public boolean isDisconnected()
  123. {
  124. return disconnected;
  125. }
  126. /**
  127. * @param val the disconnected to set
  128. */
  129. public void setDisconnected(boolean val)
  130. {
  131. disconnected = val;
  132. }
  133. /**
  134. * @return the defaulted
  135. */
  136. public boolean isDefaulted()
  137. {
  138. return defaulted;
  139. }
  140. /**
  141. * @param val the value to set.
  142. */
  143. public void setDefaulted(boolean val)
  144. {
  145. defaulted = val;
  146. }
  147. }