SkillTreeTable.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  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. while (classlist.next())
  127. {
  128. map = new FastMap<Integer, L2SkillLearn>();
  129. parentClassId = classlist.getInt("parent_id");
  130. classId = classlist.getInt("id");
  131. 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");
  132. statement2.setInt(1, classId);
  133. ResultSet skilltree = statement2.executeQuery();
  134. if (parentClassId != -1)
  135. {
  136. Map<Integer, L2SkillLearn> parentMap = getSkillTrees().get(ClassId.values()[parentClassId]);
  137. map.putAll(parentMap);
  138. }
  139. int prevSkillId = -1;
  140. while (skilltree.next())
  141. {
  142. int id = skilltree.getInt("skill_id");
  143. int lvl = skilltree.getInt("level");
  144. String name = skilltree.getString("name");
  145. int minLvl = skilltree.getInt("min_level");
  146. int cost = skilltree.getInt("sp");
  147. if (prevSkillId != id)
  148. prevSkillId = id;
  149. skillLearn = new L2SkillLearn(id, lvl, minLvl, name, cost, 0, 0);
  150. map.put(SkillTable.getSkillHashCode(id, lvl), skillLearn);
  151. }
  152. getSkillTrees().put(ClassId.values()[classId], map);
  153. skilltree.close();
  154. statement2.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. }
  161. catch (Exception e)
  162. {
  163. _log.severe("Error while creating skill tree (Class ID " + classId + "):" + e);
  164. }
  165. _log.config("SkillTreeTable: Loaded " + count + " skills.");
  166. //Skill tree for fishing skill (from Fisherman)
  167. try
  168. {
  169. _fishingSkillTrees = new FastList<L2SkillLearn>();
  170. _expandDwarfCraftSkillTrees = new FastList<L2SkillLearn>();
  171. PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, sp, min_level, costid, cost, isfordwarf FROM fishing_skill_trees ORDER BY skill_id, level");
  172. ResultSet skilltree2 = statement.executeQuery();
  173. int prevSkillId = -1;
  174. while (skilltree2.next())
  175. {
  176. int id = skilltree2.getInt("skill_id");
  177. int lvl = skilltree2.getInt("level");
  178. String name = skilltree2.getString("name");
  179. int minLvl = skilltree2.getInt("min_level");
  180. int cost = skilltree2.getInt("sp");
  181. int costId = skilltree2.getInt("costid");
  182. int costCount = skilltree2.getInt("cost");
  183. int isDwarven = skilltree2.getInt("isfordwarf");
  184. if (prevSkillId != id)
  185. prevSkillId = id;
  186. L2SkillLearn skill = new L2SkillLearn(id, lvl, minLvl, name, cost, costId, costCount);
  187. if (isDwarven == 0)
  188. _fishingSkillTrees.add(skill);
  189. else
  190. _expandDwarfCraftSkillTrees.add(skill);
  191. }
  192. skilltree2.close();
  193. statement.close();
  194. count2 = _fishingSkillTrees.size();
  195. count3 = _expandDwarfCraftSkillTrees.size();
  196. }
  197. catch (Exception e)
  198. {
  199. _log.severe("Error while creating fishing skill table: " + e);
  200. }
  201. try
  202. {
  203. _pledgeSkillTrees = new FastList<L2PledgeSkillLearn>();
  204. PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, clan_lvl, repCost, itemId, itemCount FROM pledge_skill_trees ORDER BY skill_id, level");
  205. ResultSet skilltree4 = statement.executeQuery();
  206. int prevSkillId = -1;
  207. while (skilltree4.next())
  208. {
  209. int id = skilltree4.getInt("skill_id");
  210. int lvl = skilltree4.getInt("level");
  211. String name = skilltree4.getString("name");
  212. int baseLvl = skilltree4.getInt("clan_lvl");
  213. int sp = skilltree4.getInt("repCost");
  214. int itemId = skilltree4.getInt("itemId");
  215. int itemCount = skilltree4.getInt("itemCount");
  216. if (prevSkillId != id)
  217. prevSkillId = id;
  218. L2PledgeSkillLearn skill = new L2PledgeSkillLearn(id, lvl, baseLvl, name, sp, itemId, itemCount);
  219. _pledgeSkillTrees.add(skill);
  220. }
  221. skilltree4.close();
  222. statement.close();
  223. count4 = _pledgeSkillTrees.size();
  224. }
  225. catch (Exception e)
  226. {
  227. _log.severe("Error while creating pledge skill table: " + e);
  228. }
  229. try
  230. {
  231. _TransformSkillTrees = new FastList<L2TransformSkillLearn>();
  232. 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");
  233. ResultSet skilltree5 = statement.executeQuery();
  234. int prevSkillId = -1;
  235. while (skilltree5.next())
  236. {
  237. int race_id = skilltree5.getInt("race_id");
  238. int skill_id = skilltree5.getInt("skill_id");
  239. int item_id = skilltree5.getInt("item_id");
  240. int level = skilltree5.getInt("level");
  241. String name = skilltree5.getString("name");
  242. int sp = skilltree5.getInt("sp");
  243. int min_level = skilltree5.getInt("min_level");
  244. if (prevSkillId != skill_id)
  245. prevSkillId = skill_id;
  246. L2TransformSkillLearn skill = new L2TransformSkillLearn(race_id, skill_id, item_id, level, name, sp, min_level);
  247. _TransformSkillTrees.add(skill);
  248. }
  249. skilltree5.close();
  250. statement.close();
  251. count5 = _TransformSkillTrees.size();
  252. }
  253. catch (Exception e)
  254. {
  255. _log.log(Level.SEVERE, "Error while creating Transformation skill table ", e);
  256. }
  257. try
  258. {
  259. _specialSkillTrees = new FastList<L2SkillLearn>();
  260. PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, costid, cost FROM special_skill_trees ORDER BY skill_id, level");
  261. ResultSet skilltree6 = statement.executeQuery();
  262. int prevSkillId = -1;
  263. while (skilltree6.next())
  264. {
  265. int id = skilltree6.getInt("skill_id");
  266. int lvl = skilltree6.getInt("level");
  267. String name = skilltree6.getString("name");
  268. int costId = skilltree6.getInt("costid");
  269. int costCount = skilltree6.getInt("cost");
  270. if (prevSkillId != id)
  271. prevSkillId = id;
  272. L2SkillLearn skill = new L2SkillLearn(id, lvl, 0, name, 0, costId, costCount);
  273. _specialSkillTrees.add(skill);
  274. }
  275. skilltree6.close();
  276. statement.close();
  277. count6 = _specialSkillTrees.size();
  278. }
  279. catch (Exception e)
  280. {
  281. _log.severe("Error while creating special skill table: " + e);
  282. }
  283. }
  284. catch (Exception e)
  285. {
  286. _log.log(Level.SEVERE, "Error while skill tables ", e);
  287. }
  288. finally
  289. {
  290. try
  291. {
  292. con.close();
  293. }
  294. catch (Exception e)
  295. {
  296. }
  297. }
  298. _log.config("FishingSkillTreeTable: Loaded " + count2 + " general skills.");
  299. _log.config("DwarvenCraftSkillTreeTable: Loaded " + count3 + " dwarven skills.");
  300. _log.config("PledgeSkillTreeTable: Loaded " + count4 + " pledge skills");
  301. _log.config("TransformSkillTreeTable: Loaded " + count5 + " transform skills");
  302. _log.config("SpecialSkillTreeTable: Loaded " + count6 + " special skills");
  303. }
  304. private Map<ClassId, Map<Integer, L2SkillLearn>> getSkillTrees()
  305. {
  306. if (_skillTrees == null)
  307. _skillTrees = new FastMap<ClassId, Map<Integer, L2SkillLearn>>();
  308. return _skillTrees;
  309. }
  310. public L2SkillLearn[] getAvailableSkills(L2PcInstance cha, ClassId classId)
  311. {
  312. List<L2SkillLearn> result = new FastList<L2SkillLearn>();
  313. Collection<L2SkillLearn> skills = getSkillTrees().get(classId).values();
  314. if (skills == null)
  315. {
  316. // the skilltree for this class is undefined, so we give an empty list
  317. _log.warning("Skilltree for class " + classId + " is not defined !");
  318. return new L2SkillLearn[0];
  319. }
  320. L2Skill[] oldSkills = cha.getAllSkills();
  321. for (L2SkillLearn temp : skills)
  322. {
  323. if (temp.getMinLevel() <= cha.getLevel())
  324. {
  325. boolean knownSkill = false;
  326. for (int j = 0; j < oldSkills.length && !knownSkill; j++)
  327. {
  328. if (oldSkills[j].getId() == temp.getId())
  329. {
  330. knownSkill = true;
  331. if (oldSkills[j].getLevel() == temp.getLevel() - 1)
  332. {
  333. // this is the next level of a skill that we know
  334. result.add(temp);
  335. }
  336. }
  337. }
  338. if (!knownSkill && temp.getLevel() == 1)
  339. {
  340. // this is a new skill
  341. result.add(temp);
  342. }
  343. }
  344. }
  345. return result.toArray(new L2SkillLearn[result.size()]);
  346. }
  347. public L2SkillLearn[] getAvailableSkills(L2PcInstance cha)
  348. {
  349. List<L2SkillLearn> result = new FastList<L2SkillLearn>();
  350. List<L2SkillLearn> skills = new FastList<L2SkillLearn>();
  351. skills.addAll(_fishingSkillTrees);
  352. if (skills.size() < 1)
  353. {
  354. // the skilltree for this class is undefined, so we give an empty list
  355. _log.warning("Skilltree for fishing is not defined !");
  356. return new L2SkillLearn[0];
  357. }
  358. if (cha.hasDwarvenCraft() && _expandDwarfCraftSkillTrees != null)
  359. {
  360. skills.addAll(_expandDwarfCraftSkillTrees);
  361. }
  362. L2Skill[] oldSkills = cha.getAllSkills();
  363. for (L2SkillLearn temp : skills)
  364. {
  365. if (temp.getMinLevel() <= cha.getLevel())
  366. {
  367. boolean knownSkill = false;
  368. for (int j = 0; j < oldSkills.length && !knownSkill; j++)
  369. {
  370. if (oldSkills[j].getId() == temp.getId())
  371. {
  372. knownSkill = true;
  373. if (oldSkills[j].getLevel() == temp.getLevel() - 1)
  374. {
  375. // this is the next level of a skill that we know
  376. result.add(temp);
  377. }
  378. }
  379. }
  380. if (!knownSkill && temp.getLevel() == 1)
  381. {
  382. // this is a new skill
  383. result.add(temp);
  384. }
  385. }
  386. }
  387. return result.toArray(new L2SkillLearn[result.size()]);
  388. }
  389. public L2SkillLearn[] getAvailableSpecialSkills(L2PcInstance cha)
  390. {
  391. List<L2SkillLearn> result = new FastList<L2SkillLearn>();
  392. List<L2SkillLearn> skills = new FastList<L2SkillLearn>();
  393. skills.addAll(_specialSkillTrees);
  394. if (skills.size() < 1)
  395. {
  396. // the skilltree for this class is undefined, so we give an empty list
  397. _log.warning("Skilltree for special is not defined !");
  398. return new L2SkillLearn[0];
  399. }
  400. L2Skill[] oldSkills = cha.getAllSkills();
  401. for (L2SkillLearn temp : skills)
  402. {
  403. boolean knownSkill = false;
  404. for (int j = 0; j < oldSkills.length && !knownSkill; j++)
  405. {
  406. if (oldSkills[j].getId() == temp.getId())
  407. {
  408. knownSkill = true;
  409. if (oldSkills[j].getLevel() == temp.getLevel() - 1)
  410. {
  411. // this is the next level of a skill that we know
  412. result.add(temp);
  413. }
  414. }
  415. }
  416. if (!knownSkill && temp.getLevel() == 1)
  417. {
  418. // this is a new skill
  419. result.add(temp);
  420. }
  421. }
  422. return result.toArray(new L2SkillLearn[result.size()]);
  423. }
  424. public L2TransformSkillLearn[] getAvailableTransformSkills(L2PcInstance cha)
  425. {
  426. List<L2TransformSkillLearn> result = new FastList<L2TransformSkillLearn>();
  427. List<L2TransformSkillLearn> skills = _TransformSkillTrees;
  428. if (skills == null)
  429. {
  430. // the skilltree for this class is undefined, so we give an empty list
  431. _log.warning("No Transform skills defined!");
  432. return new L2TransformSkillLearn[0];
  433. }
  434. L2Skill[] oldSkills = cha.getAllSkills();
  435. for (L2TransformSkillLearn temp : skills)
  436. {
  437. if (temp.getMinLevel() <= cha.getLevel() && (temp.getRace() == cha.getRace().ordinal() || temp.getRace() == -1))
  438. {
  439. boolean knownSkill = false;
  440. for (int j = 0; j < oldSkills.length && !knownSkill; j++)
  441. {
  442. if (oldSkills[j].getId() == temp.getId())
  443. {
  444. knownSkill = true;
  445. if (oldSkills[j].getLevel() == temp.getLevel() - 1)
  446. {
  447. // this is the next level of a skill that we know
  448. result.add(temp);
  449. }
  450. }
  451. }
  452. if (!knownSkill && temp.getLevel() == 1)
  453. {
  454. // this is a new skill
  455. result.add(temp);
  456. }
  457. }
  458. }
  459. return result.toArray(new L2TransformSkillLearn[result.size()]);
  460. }
  461. public L2PledgeSkillLearn[] getAvailablePledgeSkills(L2PcInstance cha)
  462. {
  463. List<L2PledgeSkillLearn> result = new FastList<L2PledgeSkillLearn>();
  464. List<L2PledgeSkillLearn> skills = _pledgeSkillTrees;
  465. if (skills == null)
  466. {
  467. // the skilltree for this class is undefined, so we give an empty list
  468. _log.warning("No clan skills defined!");
  469. return new L2PledgeSkillLearn[0];
  470. }
  471. L2Skill[] oldSkills = cha.getClan().getAllSkills();
  472. for (L2PledgeSkillLearn temp : skills)
  473. {
  474. if (temp.getBaseLevel() <= cha.getClan().getLevel())
  475. {
  476. boolean knownSkill = false;
  477. for (int j = 0; j < oldSkills.length && !knownSkill; j++)
  478. {
  479. if (oldSkills[j].getId() == temp.getId())
  480. {
  481. knownSkill = true;
  482. if (oldSkills[j].getLevel() == temp.getLevel() - 1)
  483. {
  484. // this is the next level of a skill that we know
  485. result.add(temp);
  486. }
  487. }
  488. }
  489. if (!knownSkill && temp.getLevel() == 1)
  490. {
  491. // this is a new skill
  492. result.add(temp);
  493. }
  494. }
  495. }
  496. return result.toArray(new L2PledgeSkillLearn[result.size()]);
  497. }
  498. /**
  499. * Returns all allowed skills for a given class.
  500. * @param classId
  501. * @return all allowed skills for a given class.
  502. */
  503. public Collection<L2SkillLearn> getAllowedSkills(ClassId classId)
  504. {
  505. return getSkillTrees().get(classId).values();
  506. }
  507. public int getMinLevelForNewSkill(L2PcInstance cha, ClassId classId)
  508. {
  509. int minLevel = 0;
  510. Collection<L2SkillLearn> skills = getSkillTrees().get(classId).values();
  511. if (skills == null)
  512. {
  513. // the skilltree for this class is undefined, so we give an empty list
  514. _log.warning("Skilltree for class " + classId + " is not defined !");
  515. return minLevel;
  516. }
  517. for (L2SkillLearn temp : skills)
  518. {
  519. if (temp.getMinLevel() > cha.getLevel() && temp.getSpCost() != 0)
  520. if (minLevel == 0 || temp.getMinLevel() < minLevel)
  521. minLevel = temp.getMinLevel();
  522. }
  523. return minLevel;
  524. }
  525. public int getMinLevelForNewSkill(L2PcInstance cha)
  526. {
  527. int minLevel = 0;
  528. List<L2SkillLearn> skills = new FastList<L2SkillLearn>();
  529. skills.addAll(_fishingSkillTrees);
  530. if (skills.size() < 1)
  531. {
  532. // the skilltree for this class is undefined, so we give an empty list
  533. _log.warning("SkillTree for fishing is not defined !");
  534. return minLevel;
  535. }
  536. if (cha.hasDwarvenCraft() && _expandDwarfCraftSkillTrees != null)
  537. {
  538. skills.addAll(_expandDwarfCraftSkillTrees);
  539. }
  540. for (L2SkillLearn s : skills)
  541. {
  542. if (s.getMinLevel() > cha.getLevel())
  543. if (minLevel == 0 || s.getMinLevel() < minLevel)
  544. minLevel = s.getMinLevel();
  545. }
  546. return minLevel;
  547. }
  548. public int getMinLevelForNewTransformSkill(L2PcInstance cha)
  549. {
  550. int minLevel = 0;
  551. List<L2TransformSkillLearn> skills = new FastList<L2TransformSkillLearn>();
  552. skills.addAll(_TransformSkillTrees);
  553. if (skills.size() < 1)
  554. {
  555. // the skilltree for this class is undefined, so we give an empty list
  556. _log.warning("SkillTree for fishing is not defined !");
  557. return minLevel;
  558. }
  559. for (L2TransformSkillLearn s : skills)
  560. {
  561. if ((s.getMinLevel() > cha.getLevel()) && (s.getRace() == cha.getRace().ordinal()))
  562. if (minLevel == 0 || s.getMinLevel() < minLevel)
  563. minLevel = s.getMinLevel();
  564. }
  565. return minLevel;
  566. }
  567. public int getSkillCost(L2PcInstance player, L2Skill skill)
  568. {
  569. int skillCost = 100000000;
  570. ClassId classId = player.getSkillLearningClassId();
  571. int skillHashCode = SkillTable.getSkillHashCode(skill);
  572. if (getSkillTrees().get(classId).containsKey(skillHashCode))
  573. {
  574. L2SkillLearn skillLearn = getSkillTrees().get(classId).get(skillHashCode);
  575. if (skillLearn.getMinLevel() <= player.getLevel())
  576. {
  577. skillCost = skillLearn.getSpCost();
  578. if (!player.getClassId().equalsOrChildOf(classId))
  579. return skillCost;
  580. }
  581. }
  582. return skillCost;
  583. }
  584. @SuppressWarnings("synthetic-access")
  585. private static class SingletonHolder
  586. {
  587. protected static final SkillTreeTable _instance = new SkillTreeTable();
  588. }
  589. public void reload()
  590. {
  591. load();
  592. }
  593. }