}
String ename = enchant.getAttributes().getNamedItem("name").getNodeValue();
for(int r = 1; r <= eLevels; r++)
{
short level = (short) (lastLvl + eLevels * count + r);
L2EnchantSkillLearn e = new L2EnchantSkillLearn(skillId, 100 * (count + 1) + r, skillName, "+" + r + " " + ename, (r == 1 ? lastLvl : 100 * (count + 1) + r - 1), lastLvl, eLevels);
GArray<L2EnchantSkillLearn> t = EnchantTable._enchant.get(skillId);
if(t == null)
{
t = new GArray<L2EnchantSkillLearn>();
}
t.add(e);
EnchantTable._enchant.put(skillId, t);
displayLevels.put(level, (short) ((count + 1) * 100 + r));
}
count++;
Node first = enchant.getFirstChild();
Node curr = null;
for(curr = first; curr != null; curr = curr.getNextSibling())
{
if("table".equalsIgnoreCase(curr.getNodeName()))
{
NamedNodeMap a = curr.getAttributes();
String name = a.getNamedItem("name").getNodeValue();
Object[] table = parseTable(curr);
table = fillTableToSize(table, eLevels);
Object[] fulltable = etables.get(name);
if(fulltable == null)
{
fulltable = new Object[lastLvl + eLevels * 8 + 1];
}
System.arraycopy(table, 0, fulltable, lastLvl + (count - 1) * eLevels, eLevels);
etables.put(name, fulltable);
}
}
}
lastLvl += eLevels * count;
currentSkill.id = skillId;
currentSkill.name = skillName;
currentSkill.sets = new StatsSet[lastLvl];
for(int i = 0; i < lastLvl; i++)
{
currentSkill.sets[i] = new StatsSet();
currentSkill.sets[i].set("skill_id", currentSkill.id);
currentSkill.sets[i].set("level", i + 1);
currentSkill.sets[i].set("name", currentSkill.name);
}
if(currentSkill.sets.length != lastLvl)
{
throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + lastLvl + " levels expected");
}
Node first = n.getFirstChild();
for(n = first; n != null; n = n.getNextSibling())
{
if("table".equalsIgnoreCase(n.getNodeName()))
{
parseTable(n);
}
}
// обрабатываем таблицы сливая их с энчантами
for(String tn : tables.keySet())
{
Object[] et = etables.get(tn);
if(et != null)
{
Object[] t = tables.get(tn);
Object max = t[t.length - 1];
System.arraycopy(t, 0, et, 0, t.length);
for(int j = 0; j < et.length; j++)
{
if(et[j] == null)
{
et[j] = max;
}
}
tables.put(tn, et);
}
}
for(int i = 1; i <= lastLvl; i++)
{
for(n = first; n != null; n = n.getNextSibling())
{
if("set".equalsIgnoreCase(n.getNodeName()))
{
parseBeanSet(n, currentSkill.sets[i - 1], i);
}
}
}
makeSkills();
for(int i = 0; i < lastLvl; i++)
{
currentSkill.currentLevel = i;
L2Skill current = currentSkill.currentSkills.get(i);
if(displayLevels.get(current.getLevel()) != null)
{
current.setDisplayLevel(displayLevels.get(current.getLevel()).shortValue());
}
current.setEnchantLevelCount(eLevels);
//System.out.println(current.getLevel() + ":" + displayLevels.get(current.getLevel()));
for(n = first; n != null; n = n.getNextSibling())
{
if("cond".equalsIgnoreCase(n.getNodeName()))
{
Condition condition = parseCondition(n.getFirstChild());
if(condition != null)
{
Node msg = n.getAttributes().getNamedItem("msg");
if(msg != null)
{
condition.setMessage(msg.getNodeValue());
}
current.attach(condition);
}
}
if("for".equalsIgnoreCase(n.getNodeName()))
{
parseTemplate(n, current);
}
}
}
currentSkill.skills.addAll(currentSkill.currentSkills);
}
catch(Exception e)
{
_log.severe("Error loading skill " + skillId);
e.printStackTrace();
}
}