L2SkillLearn.java 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. _itemsIdCount[i][0] = Integer.parseInt(itemIdCount.split(",")[0]);//Id
  59. _itemsIdCount[i][1] = Integer.parseInt(itemIdCount.split(",")[1]);//Count
  60. i++;
  61. }
  62. }
  63. else
  64. {
  65. _itemsIdCount = null;
  66. }
  67. if (!set.getString("race", "").isEmpty())
  68. {
  69. _races = set.getIntegerArray("race");
  70. }
  71. else
  72. {
  73. _races = null;
  74. }
  75. if (!set.getString("preReqSkillIdLvl", "").isEmpty())
  76. {
  77. _preReqSkillIdLvl = new int[2];
  78. try
  79. {
  80. _preReqSkillIdLvl[0] = Integer.parseInt(set.getString("preReqSkillIdLvl").split(",")[0]);
  81. _preReqSkillIdLvl[1] = Integer.parseInt(set.getString("preReqSkillIdLvl").split(",")[1]);
  82. }
  83. catch (Exception e)
  84. {
  85. _log.severe(getClass().getSimpleName() + ": Malformed preReqSkillIdLvl for Learn Skill Id " + _skillId + " and level " + _skillLvl + "!");
  86. }
  87. }
  88. else
  89. {
  90. _preReqSkillIdLvl = null;
  91. }
  92. _socialClass = set.getInteger("socialClass", 0);
  93. _residenceSkill = set.getBool("residenceSkill", false);
  94. if (!set.getString("residenceIds", "").isEmpty())
  95. {
  96. _residenceIds = set.getIntegerArray("residenceIds");
  97. }
  98. else
  99. {
  100. _residenceIds = null;
  101. }
  102. if (!set.getString("subClassLvlNumber", "").isEmpty())
  103. {
  104. final String[] subLvLNumList = set.getString("subClassLvlNumber").split(";");
  105. _subClassLvlNumber = new int[subLvLNumList.length][2];
  106. int i = 0;
  107. for (String subLvlNum : subLvLNumList)
  108. {
  109. _subClassLvlNumber[i][0] = Integer.parseInt(subLvlNum.split(",")[0]);
  110. _subClassLvlNumber[i][1] = Integer.parseInt(subLvlNum.split(",")[1]);
  111. i++;
  112. }
  113. }
  114. else
  115. {
  116. _subClassLvlNumber = null;
  117. }
  118. _learnedByNpc = set.getBool("learnedByNpc", false);
  119. _learnedByFS = set.getBool("learnedByFS", false);
  120. }
  121. /**
  122. * @return the name of this skill.
  123. */
  124. public String getName()
  125. {
  126. return _skillName;
  127. }
  128. /**
  129. * @return the ID of this skill.
  130. */
  131. public int getSkillId()
  132. {
  133. return _skillId;
  134. }
  135. /**
  136. * @return the level of this skill.
  137. */
  138. public int getSkillLevel()
  139. {
  140. return _skillLvl;
  141. }
  142. /**
  143. * @return the minimum level required to acquire this skill.
  144. */
  145. public int getGetLevel()
  146. {
  147. return _getLevel;
  148. }
  149. /**
  150. * @return the amount of SP/Clan Reputation to acquire this skill.
  151. */
  152. public int getLevelUpSp()
  153. {
  154. return _levelUpSp;
  155. }
  156. /**
  157. * @return {@code true} if the skill is auto-get, this skill is automatically delivered.
  158. */
  159. public boolean isAutoGet()
  160. {
  161. return _autoGet;
  162. }
  163. /**
  164. * @return the multidimensional array with the item IDs and amounts required to acquire this skill.
  165. */
  166. public int[][] getItemsIdCount()
  167. {
  168. return _itemsIdCount;
  169. }
  170. /**
  171. * @return the array with the races that can acquire this skill.
  172. */
  173. public int[] getRaces()
  174. {
  175. return _races;
  176. }
  177. /**
  178. * @return the array with required skill IDs and levels to acquire this skill.
  179. */
  180. public int[] getPreReqSkillIdLvl()
  181. {
  182. return _preReqSkillIdLvl;
  183. }
  184. /**
  185. * @return the social class required to get this skill.
  186. */
  187. public int getSocialClass()
  188. {
  189. return _socialClass;
  190. }
  191. /**
  192. * @return {@code true} if this skill is a Residence skill.
  193. */
  194. public boolean isResidencialSkill()
  195. {
  196. return _residenceSkill;
  197. }
  198. /**
  199. * @return the array with the IDs where this skill is available.
  200. */
  201. public int[] getRecidenceIds()
  202. {
  203. return _residenceIds;
  204. }
  205. /**
  206. * @return the array with Sub-Class conditions, amount of subclasses and level.
  207. */
  208. public int[][] getSubClassConditions()
  209. {
  210. return _subClassLvlNumber;
  211. }
  212. /**
  213. * @return {@code true} if this skill is learned from Npc.
  214. */
  215. public boolean isLearnedByNpc()
  216. {
  217. return _learnedByNpc;
  218. }
  219. /**
  220. * @return {@code true} if this skill is learned by Forgotten Scroll.
  221. */
  222. public boolean isLearnedByFS()
  223. {
  224. return _learnedByFS;
  225. }
  226. }