diff options
Diffstat (limited to 'hercules/code/servertoclient/mercenaries.py')
-rw-r--r-- | hercules/code/servertoclient/mercenaries.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/hercules/code/servertoclient/mercenaries.py b/hercules/code/servertoclient/mercenaries.py new file mode 100644 index 0000000..481f66c --- /dev/null +++ b/hercules/code/servertoclient/mercenaries.py @@ -0,0 +1,31 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2014 Evol Online +# Author: Andrei Karas (4144) + +import re + +from code.fileutils import makeDir, readFile, saveFile + +def convertMercenaries(): + destDir = "clientdata/" + templatesDir = "templates/" + mercenariesDbFile = "serverdata/db/mercenary_db.txt" + fieldsSplit = re.compile(",") + makeDir(destDir) + tpl = readFile(templatesDir + "mercenary.tpl") + mercenaries = readFile(templatesDir + "mercenaries.xml") + data = "" + mercenarySprite = "<sprite>monsters/croc.xml</sprite>"; + with open(mercenariesDbFile, "r") as f: + for line in f: + if line == "" or line[0:2] == "//": + continue + rows = fieldsSplit.split(line) + if len(rows) < 9: + continue + data = data + tpl.format( + id = rows[0], + sprite = mercenarySprite, + name = rows[2]) + saveFile(destDir + "mercenaries.xml", mercenaries.format(data)) |