diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-09-21 18:07:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-09-21 18:07:31 +0300 |
commit | 29c95b266b64690c636bef31360a17e0f95ba909 (patch) | |
tree | 520d314055147c9f41d052fbbc171b3936f058bf /hercules/maptool.py | |
parent | 7113c2d2c52c670067704a8f4e9d8b45da14fc52 (diff) | |
download | tools-29c95b266b64690c636bef31360a17e0f95ba909.tar.gz tools-29c95b266b64690c636bef31360a17e0f95ba909.tar.bz2 tools-29c95b266b64690c636bef31360a17e0f95ba909.tar.xz tools-29c95b266b64690c636bef31360a17e0f95ba909.zip |
hercules: add mercenaries.xml generation.
Diffstat (limited to 'hercules/maptool.py')
-rwxr-xr-x | hercules/maptool.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/hercules/maptool.py b/hercules/maptool.py index 6d9d51a..fa3ecc8 100755 --- a/hercules/maptool.py +++ b/hercules/maptool.py @@ -33,6 +33,8 @@ def detectCommand(): return "itemstoxml" elif sys.argv[0][-17:] == "/monsterstoxml.py": return "monsterstoxml" + elif sys.argv[0][-20:] == "/mercenariestoxml.py": + return "mercenariestoxml" return "help" def makeDir(path): @@ -371,6 +373,27 @@ def convertMonsters(): saveFile(destDir + "monsters.xml", monsters.format(data)) +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 + mercenaryId = rows[0] + data = data + tpl.format(mercenaryId, mercenarySprite) + saveFile(destDir + "mercenaries.xml", mercenaries.format(data)) + def readMapCache(path, cmd): if cmd == "help": @@ -384,6 +407,9 @@ def readMapCache(path, cmd): elif cmd == "monsterstoxml": convertMonsters(); return + elif cmd == "mercenariestoxml": + convertMercenaries(); + return with open(path, "rb") as f: size = readInt32(f) |