summaryrefslogtreecommitdiff
path: root/hercules/code/servertoclient/skills.py
blob: 6affb7258e6cd82847940e9aec9d51823274b3bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf8 -*-
#
# Copyright (C) 2014  Evol Online
# Author: Andrei Karas (4144)

import re

from code.fileutils import makeDir, readFile, saveFile

def convertSkillsToXml():
    destDir = "clientdata/"
    templatesDir = "templates/"
    skillsDbFile = "serverdata/db/re/skill_db.txt"
    fieldsSplit = re.compile(",")
    makeDir(destDir)
    tpl = readFile(templatesDir + "skill.tpl")
    skills = readFile(templatesDir + "skills.xml")
    data = ""
    with open(skillsDbFile, "r") as f:
        for line in f:
            if line == "" or line[0:2] == "//":
                continue
            rows = fieldsSplit.split(line)
            if len(rows) < 9:
                continue
            skillId = rows[0]
            name = rows[15].strip()
            description = rows[16].strip()
            idx = description.find ("//")
            if idx > 1:
                description = description[:idx]
            data = data + tpl.format(skillId, name, description)
    saveFile(destDir + "skills.xml", skills.format(data))