diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-10-31 01:08:46 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-10-31 12:19:12 +0300 |
commit | 746192af34a65504cb86a4eca068a8f0fbb361f5 (patch) | |
tree | 12d399627720f7fc72e66deb64bac7ef0d9eb71e /hercules/code/servertoclient/monsters.py | |
parent | 63f135d8af2a81a78626d6229d077e3f91a35288 (diff) | |
download | evol-tools-746192af34a65504cb86a4eca068a8f0fbb361f5.tar.gz evol-tools-746192af34a65504cb86a4eca068a8f0fbb361f5.tar.bz2 evol-tools-746192af34a65504cb86a4eca068a8f0fbb361f5.tar.xz evol-tools-746192af34a65504cb86a4eca068a8f0fbb361f5.zip |
hercules: split implimentation to many files.
Diffstat (limited to 'hercules/code/servertoclient/monsters.py')
-rw-r--r-- | hercules/code/servertoclient/monsters.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/hercules/code/servertoclient/monsters.py b/hercules/code/servertoclient/monsters.py new file mode 100644 index 0000000..d08ce66 --- /dev/null +++ b/hercules/code/servertoclient/monsters.py @@ -0,0 +1,39 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2014 Evol Online +# Author: Andrei Karas (4144) + +import re +from sets import Set + +from code.fileutils import * +from code.stringutils import * + +def convertMonsters(): + destDir = "clientdata/" + templatesDir = "templates/" + monstersDbFile = "serverdata/sql-files/mob_db_re.sql" + fieldsSplit = re.compile(",") + bracketsSplit = re.compile("[(]|[)]") + makeDir(destDir) + tpl = readFile(templatesDir + "monster.tpl") + monsters = readFile(templatesDir + "monsters.xml") + data = "" + ids = Set() + monsterSprite = """<sprite>monsters/blub.xml</sprite> + <sprite>accessories/blub-tentacle.xml|#3e4164,3a3968,544a82,64437a,7d6db4,a26392,8f99c4,d294ab,b3cdcd,e7b8b8,d9ecd1,f0e8c5</sprite>"""; + with open(monstersDbFile, "r") as f: + for line in f: + if len(line) < 10 or line[0:2] == "//" or line[0:12] != "REPLACE INTO": + continue + rows = bracketsSplit.split(line) + if len(rows) < 2: + continue + rows = fieldsSplit.split(rows[1]) + if len(rows) < 5: + continue + monsterId = rows[0] + name = strToXml(stripQuotes(rows[2])) + data = data + tpl.format(monsterId, name, monsterSprite) + + saveFile(destDir + "monsters.xml", monsters.format(data)) |