L2DropData.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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;
  16. import java.util.Arrays;
  17. /**
  18. * Special thanks to nuocnam.
  19. * @author LittleVexy
  20. */
  21. public class L2DropData
  22. {
  23. public static final int MAX_CHANCE = 1000000;
  24. private int _itemId;
  25. private int _minDrop;
  26. private int _maxDrop;
  27. private double _chance;
  28. private String _questID = null;
  29. private String[] _stateID = null;
  30. /**
  31. * Returns the ID of the item dropped
  32. * @return int
  33. */
  34. public int getItemId()
  35. {
  36. return _itemId;
  37. }
  38. /**
  39. * Sets the ID of the item dropped
  40. * @param itemId : int designating the ID of the item
  41. */
  42. public void setItemId(int itemId)
  43. {
  44. _itemId = itemId;
  45. }
  46. /**
  47. * Returns the minimum quantity of items dropped
  48. * @return int
  49. */
  50. public int getMinDrop()
  51. {
  52. return _minDrop;
  53. }
  54. /**
  55. * Returns the maximum quantity of items dropped
  56. * @return int
  57. */
  58. public int getMaxDrop()
  59. {
  60. return _maxDrop;
  61. }
  62. /**
  63. * Returns the chance of having a drop
  64. * @return int
  65. */
  66. public double getChance()
  67. {
  68. return _chance;
  69. }
  70. /**
  71. * Sets the value for minimal quantity of dropped items
  72. * @param mindrop : int designating the quantity
  73. */
  74. public void setMinDrop(int mindrop)
  75. {
  76. _minDrop = mindrop;
  77. }
  78. /**
  79. * Sets the value for maximal quantity of dopped items
  80. * @param maxdrop : int designating the quantity of dropped items
  81. */
  82. public void setMaxDrop(int maxdrop)
  83. {
  84. _maxDrop = maxdrop;
  85. }
  86. /**
  87. * Sets the chance of having the item for a drop
  88. * @param chance : int designating the chance
  89. */
  90. public void setChance(double chance)
  91. {
  92. _chance = chance;
  93. }
  94. /**
  95. * Returns the stateID.
  96. * @return String[]
  97. */
  98. public String[] getStateIDs()
  99. {
  100. return _stateID;
  101. }
  102. /**
  103. * Adds states of the dropped item
  104. * @param list : String[]
  105. */
  106. public void addStates(String[] list)
  107. {
  108. _stateID = list;
  109. }
  110. /**
  111. * Returns the questID.
  112. * @return String designating the ID of the quest
  113. */
  114. public String getQuestID()
  115. {
  116. return _questID;
  117. }
  118. /**
  119. * Sets the questID
  120. * @param questID the quest Id to set.
  121. */
  122. public void setQuestID(String questID)
  123. {
  124. _questID = questID;
  125. }
  126. /**
  127. * Returns if the dropped item is requested for a quest
  128. * @return boolean
  129. */
  130. public boolean isQuestDrop()
  131. {
  132. return (_questID != null) && (_stateID != null);
  133. }
  134. /**
  135. * Returns a report of the object
  136. * @return String
  137. */
  138. @Override
  139. public String toString()
  140. {
  141. String out = "ItemID: " + getItemId() + " Min: " + getMinDrop() + " Max: " + getMaxDrop() + " Chance: " + (getChance() / 10000.0) + "%";
  142. if (isQuestDrop())
  143. {
  144. out += " QuestID: " + getQuestID() + " StateID's: " + Arrays.toString(getStateIDs());
  145. }
  146. return out;
  147. }
  148. @Override
  149. public int hashCode()
  150. {
  151. final int prime = 31;
  152. int result = 1;
  153. result = (prime * result) + _itemId;
  154. return result;
  155. }
  156. @Override
  157. public boolean equals(Object obj)
  158. {
  159. if (this == obj)
  160. {
  161. return true;
  162. }
  163. if (obj == null)
  164. {
  165. return false;
  166. }
  167. if (!(obj instanceof L2DropData))
  168. {
  169. return false;
  170. }
  171. final L2DropData other = (L2DropData) obj;
  172. if (_itemId != other._itemId)
  173. {
  174. return false;
  175. }
  176. return true;
  177. }
  178. }