L2Fish.java 5.4 KB

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