Свернуть ↑
public boolean addSubClass(final int classId, boolean storeOld, int certification) { if(_classlist.size() >= (4 + Config.ALT_GAME_SUB_ADD)) return false; final ClassId newId = ClassId.VALUES[classId]; final SubClass newClass = new SubClass(); newClass.setBase(false); if(newId.getRace() == null) return false; newClass.setClassId(classId); newClass.setCertification(certification); _classlist.put(classId, newClass); Connection con = null; PreparedStatement statement = null; try { // Store the basic info about this new sub-class. con = DatabaseFactory.getInstance().getConnection(); statement = con.prepareStatement("INSERT INTO character_subclasses (char_obj_id, class_id, exp, sp, curHp, curMp, curCp, maxHp, maxMp, maxCp, level, active, isBase, death_penalty, certification) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); statement.setInt(1, getObjectId()); statement.setInt(2, newClass.getClassId()); statement.setLong(3, Experience.LEVEL[40]); statement.setInt(4, 0); statement.setDouble(5, getCurrentHp()); statement.setDouble(6, getCurrentMp()); statement.setDouble(7, getCurrentCp()); statement.setDouble(8, getCurrentHp()); statement.setDouble(9, getCurrentMp()); statement.setDouble(10, getCurrentCp()); statement.setInt(11, 40); statement.setInt(12, 0); statement.setInt(13, 0); statement.setInt(14, 0); statement.setInt(15, certification); statement.execute(); } catch(final Exception e) { _log.warn("Could not add character sub-class: " + e, e); return false; } finally { DbUtils.closeQuietly(con, statement); } setActiveSubClass(classId, storeOld); boolean countUnlearnable = true; int unLearnable = 0; Collection<SkillLearn> skills = SkillAcquireHolder.getInstance().getAvailableSkill s(this, AcquireType.NORMAL); while(skills.size() > unLearnable) { for(final SkillLearn s : skills) { final Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel()); if(sk == null || !sk.getCanLearn(newId)) { if(countUnlearnable) unLearnable++; continue; } addSkill(sk, true); } countUnlearnable = false; skills = SkillAcquireHolder.getInstance().getAvailableSkill s(this, AcquireType.NORMAL); } sendPacket(new SkillList(this)); setCurrentHpMp(getMaxHp(), getMaxMp(), true); setCurrentCp(getMaxCp()); return true; }