TvTEventTeam.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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.entity;
  20. import java.util.Map;
  21. import java.util.concurrent.ConcurrentHashMap;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. /**
  24. * @author HorridoJoho
  25. */
  26. public class TvTEventTeam
  27. {
  28. /** The name of the team<br> */
  29. private final String _name;
  30. /** The team spot coordinated<br> */
  31. private int[] _coordinates = new int[3];
  32. /** The points of the team<br> */
  33. private short _points;
  34. /** Name and instance of all participated players in map. */
  35. private final Map<Integer, L2PcInstance> _participatedPlayers = new ConcurrentHashMap<>();
  36. /**
  37. * C'tor initialize the team<br>
  38. * <br>
  39. * @param name as String<br>
  40. * @param coordinates as int[]<br>
  41. */
  42. public TvTEventTeam(String name, int[] coordinates)
  43. {
  44. _name = name;
  45. _coordinates = coordinates;
  46. _points = 0;
  47. }
  48. /**
  49. * Adds a player to the team<br>
  50. * <br>
  51. * @param playerInstance as L2PcInstance<br>
  52. * @return boolean: true if success, otherwise false<br>
  53. */
  54. public boolean addPlayer(L2PcInstance playerInstance)
  55. {
  56. if (playerInstance == null)
  57. {
  58. return false;
  59. }
  60. _participatedPlayers.put(playerInstance.getObjectId(), playerInstance);
  61. return true;
  62. }
  63. /**
  64. * Removes a player from the team
  65. * @param playerObjectId
  66. */
  67. public void removePlayer(int playerObjectId)
  68. {
  69. _participatedPlayers.remove(playerObjectId);
  70. }
  71. /**
  72. * Increases the points of the team<br>
  73. */
  74. public void increasePoints()
  75. {
  76. ++_points;
  77. }
  78. /**
  79. * Cleanup the team and make it ready for adding players again<br>
  80. */
  81. public void cleanMe()
  82. {
  83. _participatedPlayers.clear();
  84. _points = 0;
  85. }
  86. /**
  87. * Is given player in this team?
  88. * @param playerObjectId
  89. * @return boolean: true if player is in this team, otherwise false
  90. */
  91. public boolean containsPlayer(int playerObjectId)
  92. {
  93. return _participatedPlayers.containsKey(playerObjectId);
  94. }
  95. /**
  96. * Returns the name of the team<br>
  97. * <br>
  98. * @return String: name of the team<br>
  99. */
  100. public String getName()
  101. {
  102. return _name;
  103. }
  104. /**
  105. * Returns the coordinates of the team spot<br>
  106. * <br>
  107. * @return int[]: team coordinates<br>
  108. */
  109. public int[] getCoordinates()
  110. {
  111. return _coordinates;
  112. }
  113. /**
  114. * Returns the points of the team<br>
  115. * <br>
  116. * @return short: team points<br>
  117. */
  118. public short getPoints()
  119. {
  120. return _points;
  121. }
  122. /**
  123. * Returns name and instance of all participated players in Map<br>
  124. * <br>
  125. * @return Map<String, L2PcInstance>: map of players in this team<br>
  126. */
  127. public Map<Integer, L2PcInstance> getParticipatedPlayers()
  128. {
  129. return _participatedPlayers;
  130. }
  131. /**
  132. * Returns player count of this team<br>
  133. * <br>
  134. * @return int: number of players in team<br>
  135. */
  136. public int getParticipatedPlayerCount()
  137. {
  138. return _participatedPlayers.size();
  139. }
  140. }