L2SkillLearn.java 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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.logging.Logger;
  17. import com.l2jserver.gameserver.templates.StatsSet;
  18. /**
  19. * @author Zoey76
  20. */
  21. public final class L2SkillLearn
  22. {
  23. private static final Logger _log = Logger.getLogger(L2SkillLearn.class.getName());
  24. private final String _skillName;
  25. private final int _skillId;
  26. private final int _skillLvl;
  27. private final int _getLevel;
  28. private final boolean _autoGet;
  29. private final int _levelUpSp;
  30. private final int[][] _itemsIdCount;
  31. private final int[] _races;
  32. private final int[] _preReqSkillIdLvl;
  33. private final int _socialClass;
  34. private final boolean _residenceSkill;
  35. private final int[] _residenceIds;
  36. private final int[][] _subClassLvlNumber;
  37. private final boolean _learnedByNpc;
  38. private final boolean _learnedByFS;
  39. /**
  40. * Constructor for L2SkillLearn.
  41. * @param set the set with the L2SkillLearn data.
  42. */
  43. public L2SkillLearn(StatsSet set)
  44. {
  45. _skillName = set.getString("skillName");
  46. _skillId = set.getInteger("skillId");
  47. _skillLvl = set.getInteger("skillLvl");
  48. _getLevel = set.getInteger("getLevel");
  49. _autoGet = set.getBool("autoGet", false);
  50. _levelUpSp = set.getInteger("levelUpSp", 0);
  51. if (!set.getString("itemsIdCount", "").isEmpty())
  52. {
  53. final String[] items = set.getString("itemsIdCount").split(";");
  54. _itemsIdCount = new int[items.length][2];
  55. int i = 0;
  56. for (String itemIdCount : items)
  57. {
  58. try
  59. {
  60. _itemsIdCount[i][0] = Integer.parseInt(itemIdCount.split(",")[0]);//Id
  61. _itemsIdCount[i][1] = Integer.parseInt(itemIdCount.split(",")[1]);//Count
  62. i++;
  63. }
  64. catch (Exception e)
  65. {
  66. _log.severe(getClass().getSimpleName() + ": Malformed itemsIdCount for Learn Skill Id " + _skillId + " and level " + _skillLvl + "!");
  67. }
  68. }
  69. }
  70. else
  71. {
  72. _itemsIdCount = null;
  73. }
  74. if (!set.getString("race", "").isEmpty())
  75. {
  76. _races = set.getIntegerArray("race");
  77. }
  78. else
  79. {
  80. _races = null;
  81. }
  82. if (!set.getString("preReqSkillIdLvl", "").isEmpty())
  83. {
  84. _preReqSkillIdLvl = new int[2];
  85. try
  86. {
  87. _preReqSkillIdLvl[0] = Integer.parseInt(set.getString("preReqSkillIdLvl").split(",")[0]);
  88. _preReqSkillIdLvl[1] = Integer.parseInt(set.getString("preReqSkillIdLvl").split(",")[1]);
  89. }
  90. catch (Exception e)
  91. {
  92. _log.severe(getClass().getSimpleName() + ": Malformed preReqSkillIdLvl for Learn Skill Id " + _skillId + " and level " + _skillLvl + "!");
  93. }
  94. }
  95. else
  96. {
  97. _preReqSkillIdLvl = null;
  98. }
  99. _socialClass = set.getInteger("socialClass", 0);
  100. _residenceSkill = set.getBool("residenceSkill", false);
  101. if (!set.getString("residenceIds", "").isEmpty())
  102. {
  103. _residenceIds = set.getIntegerArray("residenceIds");
  104. }
  105. else
  106. {
  107. _residenceIds = null;
  108. }
  109. if (!set.getString("subClassLvlNumber", "").isEmpty())
  110. {
  111. final String[] subLvLNumList = set.getString("subClassLvlNumber").split(";");
  112. _subClassLvlNumber = new int[subLvLNumList.length][2];
  113. int i = 0;
  114. for (String subLvlNum : subLvLNumList)
  115. {
  116. try
  117. {
  118. _subClassLvlNumber[i][0] = Integer.parseInt(subLvlNum.split(",")[0]);
  119. _subClassLvlNumber[i][1] = Integer.parseInt(subLvlNum.split(",")[1]);
  120. i++;
  121. }
  122. catch (Exception e)
  123. {
  124. _log.severe(getClass().getSimpleName() + ": Malformed subClassLvlNumber for Learn Skill Id " + _skillId + " and level " + _skillLvl + "!");
  125. }
  126. }
  127. }
  128. else
  129. {
  130. _subClassLvlNumber = null;
  131. }
  132. _learnedByNpc = set.getBool("learnedByNpc", false);
  133. _learnedByFS = set.getBool("learnedByFS", false);
  134. }
  135. /**
  136. * @return the name of this skill.
  137. */
  138. public String getName()
  139. {
  140. return _skillName;
  141. }
  142. /**
  143. * @return the ID of this skill.
  144. */
  145. public int getSkillId()
  146. {
  147. return _skillId;
  148. }
  149. /**
  150. * @return the level of this skill.
  151. */
  152. public int getSkillLevel()
  153. {
  154. return _skillLvl;
  155. }
  156. /**
  157. * @return the minimum level required to acquire this skill.
  158. */
  159. public int getGetLevel()
  160. {
  161. return _getLevel;
  162. }
  163. /**
  164. * @return the amount of SP/Clan Reputation to acquire this skill.
  165. */
  166. public int getLevelUpSp()
  167. {
  168. return _levelUpSp;
  169. }
  170. /**
  171. * @return {@code true} if the skill is auto-get, this skill is automatically delivered.
  172. */
  173. public boolean isAutoGet()
  174. {
  175. return _autoGet;
  176. }
  177. /**
  178. * @return the multidimensional array with the item IDs and amounts required to acquire this skill.
  179. */
  180. public int[][] getItemsIdCount()
  181. {
  182. return _itemsIdCount;
  183. }
  184. /**
  185. * @return the array with the races that can acquire this skill.
  186. */
  187. public int[] getRaces()
  188. {
  189. return _races;
  190. }
  191. /**
  192. * @return the array with required skill IDs and levels to acquire this skill.
  193. */
  194. public int[] getPreReqSkillIdLvl()
  195. {
  196. return _preReqSkillIdLvl;
  197. }
  198. /**
  199. * @return the social class required to get this skill.
  200. */
  201. public int getSocialClass()
  202. {
  203. return _socialClass;
  204. }
  205. /**
  206. * @return {@code true} if this skill is a Residence skill.
  207. */
  208. public boolean isResidencialSkill()
  209. {
  210. return _residenceSkill;
  211. }
  212. /**
  213. * @return the array with the IDs where this skill is available.
  214. */
  215. public int[] getRecidenceIds()
  216. {
  217. return _residenceIds;
  218. }
  219. /**
  220. * @return the array with Sub-Class conditions, amount of subclasses and level.
  221. */
  222. public int[][] getSubClassConditions()
  223. {
  224. return _subClassLvlNumber;
  225. }
  226. /**
  227. * @return {@code true} if this skill is learned from Npc.
  228. */
  229. public boolean isLearnedByNpc()
  230. {
  231. return _learnedByNpc;
  232. }
  233. /**
  234. * @return {@code true} if this skill is learned by Forgotten Scroll.
  235. */
  236. public boolean isLearnedByFS()
  237. {
  238. return _learnedByFS;
  239. }
  240. }