L2Fish.java 5.4 KB

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