L2DropData.java 4.0 KB

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