SkillTreeTable.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  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.datatables;
  16. import java.sql.Connection;
  17. import java.sql.PreparedStatement;
  18. import java.sql.ResultSet;
  19. import java.util.Collection;
  20. import java.util.List;
  21. import java.util.Map;
  22. import java.util.logging.Level;
  23. import java.util.logging.Logger;
  24. import com.l2jserver.L2DatabaseFactory;
  25. import com.l2jserver.gameserver.model.L2PledgeSkillLearn;
  26. import com.l2jserver.gameserver.model.L2Skill;
  27. import com.l2jserver.gameserver.model.L2SkillLearn;
  28. import com.l2jserver.gameserver.model.L2TransformSkillLearn;
  29. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  30. import com.l2jserver.gameserver.model.base.ClassId;
  31. import javolution.util.FastList;
  32. import javolution.util.FastMap;
  33. /**
  34. * This class ...
  35. *
  36. * @version $Revision: 1.13.2.2.2.8 $ $Date: 2005/04/06 16:13:25 $
  37. */
  38. public class SkillTreeTable
  39. {
  40. private static Logger _log = Logger.getLogger(SkillTreeTable.class.getName());
  41. private Map<ClassId, Map<Integer, L2SkillLearn>> _skillTrees;
  42. private List<L2SkillLearn> _fishingSkillTrees; //all common skills (teached by Fisherman)
  43. private List<L2SkillLearn> _expandDwarfCraftSkillTrees; //list of special skill for dwarf (expand dwarf craft) learned by class teacher
  44. private List<L2PledgeSkillLearn> _pledgeSkillTrees; //pledge skill list
  45. private List<L2TransformSkillLearn> _TransformSkillTrees; // Transform Skills (Test)
  46. private FastList<L2SkillLearn> _specialSkillTrees;
  47. public static SkillTreeTable getInstance()
  48. {
  49. return SingletonHolder._instance;
  50. }
  51. private SkillTreeTable()
  52. {
  53. load();
  54. }
  55. /**
  56. * Return the minimum level needed to have this Expertise.<BR><BR>
  57. *
  58. * @param grade The grade level searched
  59. */
  60. public int getExpertiseLevel(int grade)
  61. {
  62. if (grade <= 0)
  63. return 0;
  64. // since expertise comes at same level for all classes we use paladin for now
  65. Map<Integer, L2SkillLearn> learnMap = getSkillTrees().get(ClassId.paladin);
  66. int skillHashCode = SkillTable.getSkillHashCode(239, grade);
  67. if (learnMap.containsKey(skillHashCode))
  68. {
  69. return learnMap.get(skillHashCode).getMinLevel();
  70. }
  71. _log.severe("Expertise not found for grade " + grade);
  72. return 0;
  73. }
  74. /**
  75. * Each class receives new skill on certain levels, this methods allow the retrieval of the minimun character level
  76. * of given class required to learn a given skill
  77. * @param skillId The iD of the skill
  78. * @param classID The classId of the character
  79. * @param skillLvl The SkillLvl
  80. * @return The min level
  81. */
  82. public int getMinSkillLevel(int skillId, ClassId classId, int skillLvl)
  83. {
  84. Map<Integer, L2SkillLearn> map = getSkillTrees().get(classId);
  85. int skillHashCode = SkillTable.getSkillHashCode(skillId, skillLvl);
  86. if (map.containsKey(skillHashCode))
  87. {
  88. return map.get(skillHashCode).getMinLevel();
  89. }
  90. return 0;
  91. }
  92. public int getMinSkillLevel(int skillId, int skillLvl)
  93. {
  94. int skillHashCode = SkillTable.getSkillHashCode(skillId, skillLvl);
  95. // Look on all classes for this skill (takes the first one found)
  96. for (Map<Integer, L2SkillLearn> map : getSkillTrees().values())
  97. {
  98. // checks if the current class has this skill
  99. if (map.containsKey(skillHashCode))
  100. {
  101. return map.get(skillHashCode).getMinLevel();
  102. }
  103. }
  104. return 0;
  105. }
  106. private void load()
  107. {
  108. int classId = 0;
  109. int count = 0;
  110. int count2 = 0;
  111. int count3 = 0;
  112. int count4 = 0;
  113. int count5 = 0;
  114. int count6 = 0;
  115. Connection con = null;
  116. try
  117. {
  118. con = L2DatabaseFactory.getInstance().getConnection();
  119. try
  120. {
  121. PreparedStatement statement = con.prepareStatement("SELECT * FROM class_list ORDER BY id");
  122. ResultSet classlist = statement.executeQuery();
  123. Map<Integer, L2SkillLearn> map;
  124. int parentClassId;
  125. L2SkillLearn skillLearn;
  126. PreparedStatement statement2 = con.prepareStatement("SELECT class_id, skill_id, level, name, sp, min_level FROM skill_trees where class_id=? ORDER BY skill_id, level");
  127. while (classlist.next())
  128. {
  129. map = new FastMap<Integer, L2SkillLearn>();
  130. parentClassId = classlist.getInt("parent_id");
  131. classId = classlist.getInt("id");
  132. statement2.setInt(1, classId);
  133. ResultSet skilltree = statement2.executeQuery();
  134. statement2.clearParameters();
  135. if (parentClassId != -1)
  136. {
  137. Map<Integer, L2SkillLearn> parentMap = getSkillTrees().get(ClassId.values()[parentClassId]);
  138. map.putAll(parentMap);
  139. }
  140. int prevSkillId = -1;
  141. while (skilltree.next())
  142. {
  143. int id = skilltree.getInt("skill_id");
  144. int lvl = skilltree.getInt("level");
  145. String name = skilltree.getString("name");
  146. int minLvl = skilltree.getInt("min_level");
  147. int cost = skilltree.getInt("sp");
  148. if (prevSkillId != id)
  149. prevSkillId = id;
  150. skillLearn = new L2SkillLearn(id, lvl, minLvl, name, cost, 0, 0);
  151. map.put(SkillTable.getSkillHashCode(id, lvl), skillLearn);
  152. }
  153. getSkillTrees().put(ClassId.values()[classId], map);
  154. skilltree.close();
  155. count += map.size();
  156. _log.fine("SkillTreeTable: skill tree for class " + classId + " has " + map.size() + " skills");
  157. }
  158. classlist.close();
  159. statement.close();
  160. statement2.close();
  161. }
  162. catch (Exception e)
  163. {
  164. _log.log(Level.SEVERE, "Error while creating skill tree (Class ID " + classId + "): " + e.getMessage(), e);
  165. }
  166. _log.info("SkillTreeTable: Loaded " + count + " skills.");
  167. //Skill tree for fishing skill (from Fisherman)
  168. try
  169. {
  170. _fishingSkillTrees = new FastList<L2SkillLearn>();
  171. _expandDwarfCraftSkillTrees = new FastList<L2SkillLearn>();
  172. PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, sp, min_level, costid, cost, isfordwarf FROM fishing_skill_trees ORDER BY skill_id, level");
  173. ResultSet skilltree2 = statement.executeQuery();
  174. int prevSkillId = -1;
  175. while (skilltree2.next())
  176. {
  177. int id = skilltree2.getInt("skill_id");
  178. int lvl = skilltree2.getInt("level");
  179. String name = skilltree2.getString("name");
  180. int minLvl = skilltree2.getInt("min_level");
  181. int cost = skilltree2.getInt("sp");
  182. int costId = skilltree2.getInt("costid");
  183. int costCount = skilltree2.getInt("cost");
  184. int isDwarven = skilltree2.getInt("isfordwarf");
  185. if (prevSkillId != id)
  186. prevSkillId = id;
  187. L2SkillLearn skill = new L2SkillLearn(id, lvl, minLvl, name, cost, costId, costCount);
  188. if (isDwarven == 0)
  189. _fishingSkillTrees.add(skill);
  190. else
  191. _expandDwarfCraftSkillTrees.add(skill);
  192. }
  193. skilltree2.close();
  194. statement.close();
  195. count2 = _fishingSkillTrees.size();
  196. count3 = _expandDwarfCraftSkillTrees.size();
  197. }
  198. catch (Exception e)
  199. {
  200. _log.log(Level.SEVERE, "Error while creating fishing skill table: " + e.getMessage(), e);
  201. }
  202. try
  203. {
  204. _pledgeSkillTrees = new FastList<L2PledgeSkillLearn>();
  205. PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, clan_lvl, repCost, itemId, itemCount FROM pledge_skill_trees ORDER BY skill_id, level");
  206. ResultSet skilltree4 = statement.executeQuery();
  207. int prevSkillId = -1;
  208. while (skilltree4.next())
  209. {
  210. int id = skilltree4.getInt("skill_id");
  211. int lvl = skilltree4.getInt("level");
  212. String name = skilltree4.getString("name");
  213. int baseLvl = skilltree4.getInt("clan_lvl");
  214. int sp = skilltree4.getInt("repCost");
  215. int itemId = skilltree4.getInt("itemId");
  216. int itemCount = skilltree4.getInt("itemCount");
  217. if (prevSkillId != id)
  218. prevSkillId = id;
  219. L2PledgeSkillLearn skill = new L2PledgeSkillLearn(id, lvl, baseLvl, name, sp, itemId, itemCount);
  220. _pledgeSkillTrees.add(skill);
  221. }
  222. skilltree4.close();
  223. statement.close();
  224. count4 = _pledgeSkillTrees.size();
  225. }
  226. catch (Exception e)
  227. {
  228. _log.log(Level.SEVERE, "Error while creating pledge skill table: " + e.getMessage(), e);
  229. }
  230. try
  231. {
  232. _TransformSkillTrees = new FastList<L2TransformSkillLearn>();
  233. PreparedStatement statement = con.prepareStatement("SELECT race_id, skill_id, item_id, level, name, sp, min_level FROM transform_skill_trees ORDER BY race_id, skill_id, level");
  234. ResultSet skilltree5 = statement.executeQuery();
  235. int prevSkillId = -1;
  236. while (skilltree5.next())
  237. {
  238. int race_id = skilltree5.getInt("race_id");
  239. int skill_id = skilltree5.getInt("skill_id");
  240. int item_id = skilltree5.getInt("item_id");
  241. int level = skilltree5.getInt("level");
  242. String name = skilltree5.getString("name");
  243. int sp = skilltree5.getInt("sp");
  244. int min_level = skilltree5.getInt("min_level");
  245. if (prevSkillId != skill_id)
  246. prevSkillId = skill_id;
  247. L2TransformSkillLearn skill = new L2TransformSkillLearn(race_id, skill_id, item_id, level, name, sp, min_level);
  248. _TransformSkillTrees.add(skill);
  249. }
  250. skilltree5.close();
  251. statement.close();
  252. count5 = _TransformSkillTrees.size();
  253. }
  254. catch (Exception e)
  255. {
  256. _log.log(Level.SEVERE, "Error while creating Transformation skill table ", e);
  257. }
  258. try
  259. {
  260. _specialSkillTrees = new FastList<L2SkillLearn>();
  261. PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, costid, cost FROM special_skill_trees ORDER BY skill_id, level");
  262. ResultSet skilltree6 = statement.executeQuery();
  263. int prevSkillId = -1;
  264. while (skilltree6.next())
  265. {
  266. int id = skilltree6.getInt("skill_id");
  267. int lvl = skilltree6.getInt("level");
  268. String name = skilltree6.getString("name");
  269. int costId = skilltree6.getInt("costid");
  270. int costCount = skilltree6.getInt("cost");
  271. if (prevSkillId != id)
  272. prevSkillId = id;
  273. L2SkillLearn skill = new L2SkillLearn(id, lvl, 0, name, 0, costId, costCount);
  274. _specialSkillTrees.add(skill);
  275. }
  276. skilltree6.close();
  277. statement.close();
  278. count6 = _specialSkillTrees.size();
  279. }
  280. catch (Exception e)
  281. {
  282. _log.log(Level.SEVERE, "Error while creating special skill table: " + e.getMessage(), e);
  283. }
  284. }
  285. catch (Exception e)
  286. {
  287. _log.log(Level.SEVERE, "Error while skill tables ", e);
  288. }
  289. finally
  290. {
  291. L2DatabaseFactory.close(con);
  292. }
  293. _log.info("FishingSkillTreeTable: Loaded " + count2 + " general skills.");
  294. _log.info("DwarvenCraftSkillTreeTable: Loaded " + count3 + " dwarven skills.");
  295. _log.info("PledgeSkillTreeTable: Loaded " + count4 + " pledge skills");
  296. _log.info("TransformSkillTreeTable: Loaded " + count5 + " transform skills");
  297. _log.info("SpecialSkillTreeTable: Loaded " + count6 + " special skills");
  298. }
  299. private Map<ClassId, Map<Integer, L2SkillLearn>> getSkillTrees()
  300. {
  301. if (_skillTrees == null)
  302. _skillTrees = new FastMap<ClassId, Map<Integer, L2SkillLearn>>();
  303. return _skillTrees;
  304. }
  305. public L2SkillLearn[] getAvailableSkills(L2PcInstance cha, ClassId classId)
  306. {
  307. List<L2SkillLearn> result = new FastList<L2SkillLearn>();
  308. Collection<L2SkillLearn> skills = getSkillTrees().get(classId).values();
  309. if (skills == null)
  310. {
  311. // the skilltree for this class is undefined, so we give an empty list
  312. _log.warning("Skilltree for class " + classId + " is not defined !");
  313. return new L2SkillLearn[0];
  314. }
  315. L2Skill[] oldSkills = cha.getAllSkills();
  316. for (L2SkillLearn temp : skills)
  317. {
  318. if (temp.getMinLevel() <= cha.getLevel())
  319. {
  320. boolean knownSkill = false;
  321. for (int j = 0; j < oldSkills.length && !knownSkill; j++)
  322. {
  323. if (oldSkills[j].getId() == temp.getId())
  324. {
  325. knownSkill = true;
  326. if (oldSkills[j].getLevel() == temp.getLevel() - 1)
  327. {
  328. // this is the next level of a skill that we know
  329. result.add(temp);
  330. }
  331. }
  332. }
  333. if (!knownSkill && temp.getLevel() == 1)
  334. {
  335. // this is a new skill
  336. result.add(temp);
  337. }
  338. }
  339. }
  340. return result.toArray(new L2SkillLearn[result.size()]);
  341. }
  342. public L2SkillLearn[] getAvailableSkills(L2PcInstance cha)
  343. {
  344. List<L2SkillLearn> result = new FastList<L2SkillLearn>();
  345. List<L2SkillLearn> skills = new FastList<L2SkillLearn>();
  346. skills.addAll(_fishingSkillTrees);
  347. if (skills.size() < 1)
  348. {
  349. // the skilltree for this class is undefined, so we give an empty list
  350. _log.warning("Skilltree for fishing is not defined !");
  351. return new L2SkillLearn[0];
  352. }
  353. if (cha.hasDwarvenCraft() && _expandDwarfCraftSkillTrees != null)
  354. {
  355. skills.addAll(_expandDwarfCraftSkillTrees);
  356. }
  357. L2Skill[] oldSkills = cha.getAllSkills();
  358. for (L2SkillLearn temp : skills)
  359. {
  360. if (temp.getMinLevel() <= cha.getLevel())
  361. {
  362. boolean knownSkill = false;
  363. for (int j = 0; j < oldSkills.length && !knownSkill; j++)
  364. {
  365. if (oldSkills[j].getId() == temp.getId())
  366. {
  367. knownSkill = true;
  368. if (oldSkills[j].getLevel() == temp.getLevel() - 1)
  369. {
  370. // this is the next level of a skill that we know
  371. result.add(temp);
  372. }
  373. }
  374. }
  375. if (!knownSkill && temp.getLevel() == 1)
  376. {
  377. // this is a new skill
  378. result.add(temp);
  379. }
  380. }
  381. }
  382. return result.toArray(new L2SkillLearn[result.size()]);
  383. }
  384. public L2SkillLearn[] getAvailableSpecialSkills(L2PcInstance cha)
  385. {
  386. List<L2SkillLearn> result = new FastList<L2SkillLearn>();
  387. List<L2SkillLearn> skills = new FastList<L2SkillLearn>();
  388. skills.addAll(_specialSkillTrees);
  389. if (skills.size() < 1)
  390. {
  391. // the skilltree for this class is undefined, so we give an empty list
  392. _log.warning("Skilltree for special is not defined !");
  393. return new L2SkillLearn[0];
  394. }
  395. L2Skill[] oldSkills = cha.getAllSkills();
  396. for (L2SkillLearn temp : skills)
  397. {
  398. boolean knownSkill = false;
  399. for (int j = 0; j < oldSkills.length && !knownSkill; j++)
  400. {
  401. if (oldSkills[j].getId() == temp.getId())
  402. {
  403. knownSkill = true;
  404. if (oldSkills[j].getLevel() == temp.getLevel() - 1)
  405. {
  406. // this is the next level of a skill that we know
  407. result.add(temp);
  408. }
  409. }
  410. }
  411. if (!knownSkill && temp.getLevel() == 1)
  412. {
  413. // this is a new skill
  414. result.add(temp);
  415. }
  416. }
  417. return result.toArray(new L2SkillLearn[result.size()]);
  418. }
  419. public L2TransformSkillLearn[] getAvailableTransformSkills(L2PcInstance cha)
  420. {
  421. List<L2TransformSkillLearn> result = new FastList<L2TransformSkillLearn>();
  422. List<L2TransformSkillLearn> skills = _TransformSkillTrees;
  423. if (skills == null)
  424. {
  425. // the skilltree for this class is undefined, so we give an empty list
  426. _log.warning("No Transform skills defined!");
  427. return new L2TransformSkillLearn[0];
  428. }
  429. L2Skill[] oldSkills = cha.getAllSkills();
  430. for (L2TransformSkillLearn temp : skills)
  431. {
  432. if (temp.getMinLevel() <= cha.getLevel() && (temp.getRace() == cha.getRace().ordinal() || temp.getRace() == -1))
  433. {
  434. boolean knownSkill = false;
  435. for (int j = 0; j < oldSkills.length && !knownSkill; j++)
  436. {
  437. if (oldSkills[j].getId() == temp.getId())
  438. {
  439. knownSkill = true;
  440. if (oldSkills[j].getLevel() == temp.getLevel() - 1)
  441. {
  442. // this is the next level of a skill that we know
  443. result.add(temp);
  444. }
  445. }
  446. }
  447. if (!knownSkill && temp.getLevel() == 1)
  448. {
  449. // this is a new skill
  450. result.add(temp);
  451. }
  452. }
  453. }
  454. return result.toArray(new L2TransformSkillLearn[result.size()]);
  455. }
  456. public L2PledgeSkillLearn[] getAvailablePledgeSkills(L2PcInstance cha)
  457. {
  458. List<L2PledgeSkillLearn> result = new FastList<L2PledgeSkillLearn>();
  459. List<L2PledgeSkillLearn> skills = _pledgeSkillTrees;
  460. if (skills == null)
  461. {
  462. // the skilltree for this class is undefined, so we give an empty list
  463. _log.warning("No clan skills defined!");
  464. return new L2PledgeSkillLearn[0];
  465. }
  466. L2Skill[] oldSkills = cha.getClan().getAllSkills();
  467. for (L2PledgeSkillLearn temp : skills)
  468. {
  469. if (temp.getBaseLevel() <= cha.getClan().getLevel())
  470. {
  471. boolean knownSkill = false;
  472. for (int j = 0; j < oldSkills.length && !knownSkill; j++)
  473. {
  474. if (oldSkills[j].getId() == temp.getId())
  475. {
  476. knownSkill = true;
  477. if (oldSkills[j].getLevel() == temp.getLevel() - 1)
  478. {
  479. // this is the next level of a skill that we know
  480. result.add(temp);
  481. }
  482. }
  483. }
  484. if (!knownSkill && temp.getLevel() == 1)
  485. {
  486. // this is a new skill
  487. result.add(temp);
  488. }
  489. }
  490. }
  491. return result.toArray(new L2PledgeSkillLearn[result.size()]);
  492. }
  493. /**
  494. * Returns all allowed skills for a given class.
  495. * @param classId
  496. * @return all allowed skills for a given class.
  497. */
  498. public Collection<L2SkillLearn> getAllowedSkills(ClassId classId)
  499. {
  500. return getSkillTrees().get(classId).values();
  501. }
  502. public int getMinLevelForNewSkill(L2PcInstance cha, ClassId classId)
  503. {
  504. int minLevel = 0;
  505. Collection<L2SkillLearn> skills = getSkillTrees().get(classId).values();
  506. if (skills == null)
  507. {
  508. // the skilltree for this class is undefined, so we give an empty list
  509. _log.warning("Skilltree for class " + classId + " is not defined !");
  510. return minLevel;
  511. }
  512. for (L2SkillLearn temp : skills)
  513. {
  514. if (temp.getMinLevel() > cha.getLevel() && temp.getSpCost() != 0)
  515. if (minLevel == 0 || temp.getMinLevel() < minLevel)
  516. minLevel = temp.getMinLevel();
  517. }
  518. return minLevel;
  519. }
  520. public int getMinLevelForNewSkill(L2PcInstance cha)
  521. {
  522. int minLevel = 0;
  523. List<L2SkillLearn> skills = new FastList<L2SkillLearn>();
  524. skills.addAll(_fishingSkillTrees);
  525. if (skills.size() < 1)
  526. {
  527. // the skilltree for this class is undefined, so we give an empty list
  528. _log.warning("SkillTree for fishing is not defined !");
  529. return minLevel;
  530. }
  531. if (cha.hasDwarvenCraft() && _expandDwarfCraftSkillTrees != null)
  532. {
  533. skills.addAll(_expandDwarfCraftSkillTrees);
  534. }
  535. for (L2SkillLearn s : skills)
  536. {
  537. if (s.getMinLevel() > cha.getLevel())
  538. if (minLevel == 0 || s.getMinLevel() < minLevel)
  539. minLevel = s.getMinLevel();
  540. }
  541. return minLevel;
  542. }
  543. public int getMinLevelForNewTransformSkill(L2PcInstance cha)
  544. {
  545. int minLevel = 0;
  546. List<L2TransformSkillLearn> skills = new FastList<L2TransformSkillLearn>();
  547. skills.addAll(_TransformSkillTrees);
  548. if (skills.size() < 1)
  549. {
  550. // the skilltree for this class is undefined, so we give an empty list
  551. _log.warning("SkillTree for fishing is not defined !");
  552. return minLevel;
  553. }
  554. for (L2TransformSkillLearn s : skills)
  555. {
  556. if ((s.getMinLevel() > cha.getLevel()) && (s.getRace() == cha.getRace().ordinal()))
  557. if (minLevel == 0 || s.getMinLevel() < minLevel)
  558. minLevel = s.getMinLevel();
  559. }
  560. return minLevel;
  561. }
  562. public int getSkillCost(L2PcInstance player, L2Skill skill)
  563. {
  564. int skillCost = 100000000;
  565. ClassId classId = player.getSkillLearningClassId();
  566. int skillHashCode = SkillTable.getSkillHashCode(skill);
  567. if (getSkillTrees().get(classId).containsKey(skillHashCode))
  568. {
  569. L2SkillLearn skillLearn = getSkillTrees().get(classId).get(skillHashCode);
  570. if (skillLearn.getMinLevel() <= player.getLevel())
  571. {
  572. skillCost = skillLearn.getSpCost();
  573. if (!player.getClassId().equalsOrChildOf(classId))
  574. return skillCost;
  575. }
  576. }
  577. return skillCost;
  578. }
  579. @SuppressWarnings("synthetic-access")
  580. private static class SingletonHolder
  581. {
  582. protected static final SkillTreeTable _instance = new SkillTreeTable();
  583. }
  584. public void reload()
  585. {
  586. load();
  587. }
  588. }