L2Fish.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. /**
  17. * Class for the Fish object.
  18. * @author nonom
  19. */
  20. public class L2Fish implements Cloneable
  21. {
  22. private final int _fishId;
  23. private final int _itemId;
  24. private final String _itemName;
  25. private int _fishGroup;
  26. private final int _fishLevel;
  27. private final double _fishBiteRate;
  28. private final double _fishGuts;
  29. private final int _fishHp;
  30. private final int _fishMaxLength;
  31. private final double _fishLengthRate;
  32. private final double _hpRegen;
  33. private final int _startCombatTime;
  34. private final int _combatDuration;
  35. private final int _gutsCheckTime;
  36. private final double _gutsCheckProbability;
  37. private final double _cheatingProb;
  38. private final int _fishGrade;
  39. public L2Fish(StatsSet set)
  40. {
  41. _fishId = set.getInteger("fishId");
  42. _itemId = set.getInteger("itemId");
  43. _itemName = set.getString("itemName");
  44. _fishGroup = getGroupId(set.getString("fishGroup"));
  45. _fishLevel = set.getInteger("fishLevel");
  46. _fishBiteRate = set.getDouble("fishBiteRate"); // TODO: Support needed.
  47. _fishGuts = set.getDouble("fishGuts");
  48. _fishHp = set.getInteger("fishHp");
  49. _fishMaxLength = set.getInteger("fishMaxLength"); // TODO: Support needed.
  50. _fishLengthRate = set.getDouble("fishLengthRate"); // TODO: Support needed.
  51. _hpRegen = set.getDouble("hpRegen");
  52. _startCombatTime = set.getInteger("startCombatTime");
  53. _combatDuration = set.getInteger("combatDuration");
  54. _gutsCheckTime = set.getInteger("gutsCheckTime");
  55. _gutsCheckProbability = set.getDouble("gutsCheckProbability"); // TODO: Support needed.
  56. _cheatingProb = set.getDouble("cheatingProb"); // TODO: Support needed.
  57. _fishGrade = getGradeId(set.getString("fishGrade"));
  58. }
  59. @Override
  60. public L2Fish clone()
  61. {
  62. try
  63. {
  64. return (L2Fish) super.clone();
  65. }
  66. catch (CloneNotSupportedException e)
  67. {
  68. return null;
  69. }
  70. }
  71. /**
  72. * @return the fish Id.
  73. */
  74. public int getFishId()
  75. {
  76. return _fishId;
  77. }
  78. /**
  79. * @return the fish Item Id.
  80. */
  81. public int getItemId()
  82. {
  83. return _itemId;
  84. }
  85. /**
  86. * @return the fish Item name Id.
  87. */
  88. public String getItemName()
  89. {
  90. return _itemName;
  91. }
  92. /**
  93. * @return the fish Group.
  94. */
  95. public int getFishGroup()
  96. {
  97. return _fishGroup;
  98. }
  99. /**
  100. * @return the fish Level.
  101. */
  102. public int getFishLevel()
  103. {
  104. return _fishLevel;
  105. }
  106. /**
  107. * @return the fish Bite Rate.
  108. */
  109. public double getFishBiteRate()
  110. {
  111. return _fishBiteRate;
  112. }
  113. /**
  114. * @return the fish Guts.
  115. */
  116. public double getFishGuts()
  117. {
  118. return _fishGuts;
  119. }
  120. /**
  121. * @return the fish Hp.
  122. */
  123. public int getFishHp()
  124. {
  125. return _fishHp;
  126. }
  127. /**
  128. * @return the fish Max length.
  129. */
  130. public int getFishMaxLength()
  131. {
  132. return _fishMaxLength;
  133. }
  134. /**
  135. * @return the fish Length rate.
  136. */
  137. public double getFishLengthRate()
  138. {
  139. return _fishLengthRate;
  140. }
  141. /**
  142. * @return the fish Hp regen.
  143. */
  144. public double getHpRegen()
  145. {
  146. return _hpRegen;
  147. }
  148. /**
  149. * @return the fish start Combat time.
  150. */
  151. public int getStartCombatTime()
  152. {
  153. return _startCombatTime;
  154. }
  155. /**
  156. * @return the fish Combat duration.
  157. */
  158. public int getCombatDuration()
  159. {
  160. return _combatDuration;
  161. }
  162. /**
  163. * @return the fish Guts check time.
  164. */
  165. public int getGutsCheckTime()
  166. {
  167. return _gutsCheckTime;
  168. }
  169. /**
  170. * @return the fish Guts Check probability.
  171. */
  172. public double getGutsCheckProbability()
  173. {
  174. return _gutsCheckProbability;
  175. }
  176. /**
  177. * @return the fish Cheating prob.
  178. */
  179. public double getCheatingProb()
  180. {
  181. return _cheatingProb;
  182. }
  183. /**
  184. * @return the fish Grade.
  185. */
  186. public int getFishGrade()
  187. {
  188. return _fishGrade;
  189. }
  190. /**
  191. * @param fg the fish Group.
  192. */
  193. public void setFishGroup(int fg)
  194. {
  195. _fishGroup = fg;
  196. }
  197. /**
  198. * @param name the Group Name.
  199. * @return the fish Group Id.
  200. */
  201. private int getGroupId(String name)
  202. {
  203. switch (name)
  204. {
  205. case "swift":
  206. return 1;
  207. case "ugly":
  208. return 2;
  209. case "fish_box":
  210. return 3;
  211. case "easy_wide":
  212. return 4;
  213. case "easy_swift":
  214. return 5;
  215. case "easy_ugly":
  216. return 6;
  217. case "hard_wide":
  218. return 7;
  219. case "hard_swift":
  220. return 8;
  221. case "hard_ugly":
  222. return 9;
  223. case "hs_fish":
  224. return 10; // FIXME: Verify the ID
  225. case "wide":
  226. default:
  227. return 0;
  228. }
  229. }
  230. /**
  231. * @param name the Grade Name.
  232. * @return the fish Grade Id.
  233. */
  234. private int getGradeId(String name)
  235. {
  236. switch (name)
  237. {
  238. case "fish_easy":
  239. return 0;
  240. case "fish_hard":
  241. return 2;
  242. case "fish_normal":
  243. default:
  244. return 1;
  245. }
  246. }
  247. }