From 29c95b266b64690c636bef31360a17e0f95ba909 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 21 Sep 2014 18:07:31 +0300 Subject: hercules: add mercenaries.xml generation. --- hercules/maptool.py | 26 ++++++++++++++++++++++++++ hercules/mercenariestoxml.py | 1 + hercules/templates/mercenaries.xml | 6 ++++++ hercules/templates/mercenary.tpl | 3 +++ 4 files changed, 36 insertions(+) create mode 120000 hercules/mercenariestoxml.py create mode 100644 hercules/templates/mercenaries.xml create mode 100644 hercules/templates/mercenary.tpl 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 = "monsters/croc.xml"; + 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) diff --git a/hercules/mercenariestoxml.py b/hercules/mercenariestoxml.py new file mode 120000 index 0000000..df2b3e6 --- /dev/null +++ b/hercules/mercenariestoxml.py @@ -0,0 +1 @@ +maptool.py \ No newline at end of file diff --git a/hercules/templates/mercenaries.xml b/hercules/templates/mercenaries.xml new file mode 100644 index 0000000..cfc801c --- /dev/null +++ b/hercules/templates/mercenaries.xml @@ -0,0 +1,6 @@ + + + +{0} + diff --git a/hercules/templates/mercenary.tpl b/hercules/templates/mercenary.tpl new file mode 100644 index 0000000..e17f281 --- /dev/null +++ b/hercules/templates/mercenary.tpl @@ -0,0 +1,3 @@ + + {1} + -- cgit v1.2.3-70-g09d2