diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-02-18 20:14:54 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-18 20:14:54 +0300 |
commit | 12e0196bbf34fe878b42b4010be8c08217cf45eb (patch) | |
tree | 087d368745d32a9be06c28da3dd04d9fd01969ed /hercules | |
parent | 561c8902706feec36316c270bcad0947da2a703d (diff) | |
download | evol-tools-12e0196bbf34fe878b42b4010be8c08217cf45eb.tar.gz evol-tools-12e0196bbf34fe878b42b4010be8c08217cf45eb.tar.bz2 evol-tools-12e0196bbf34fe878b42b4010be8c08217cf45eb.tar.xz evol-tools-12e0196bbf34fe878b42b4010be8c08217cf45eb.zip |
hercules: convert to inventory.sql
Diffstat (limited to 'hercules')
-rw-r--r-- | hercules/code/server/db/inventory.py | 45 | ||||
-rw-r--r-- | hercules/code/server/evol/athena.py | 2 | ||||
-rw-r--r-- | hercules/code/server/evol/main.py | 2 | ||||
-rw-r--r-- | hercules/templates/inventory.sql | 21 |
4 files changed, 69 insertions, 1 deletions
diff --git a/hercules/code/server/db/inventory.py b/hercules/code/server/db/inventory.py new file mode 100644 index 0000000..52a2fd0 --- /dev/null +++ b/hercules/code/server/db/inventory.py @@ -0,0 +1,45 @@ +# -*- coding: utf8 -*- +# +# Copyright (C) 2015 Evol Online +# Author: Andrei Karas (4144) + +from code.fileutils import * +from code.stringutils import * + +def saveInventoryTable(users): + dstFile = "newdb/inventory.sql" + firstLine = True + tpl = readFile("templates/inventory.sql") + with open(dstFile, "w") as w: + w.write(tpl) + w.write("INSERT INTO `inventory` VALUES ") + for userId in users: + user = users[userId] + for item in user.inventory: + + if firstLine == False: + w.write(",\n") + else: + firstLine = False + + w.write(("({id},{char_id},{nameid},{amount},{equip},{identify}," + + "{refine},{attribute},{card0},{card1},{card2},{card3}," + + "{expire_time},{favorite},{bound},{unique_id})").format( + id = 0, + char_id = user.char_id, + nameid = item.itemId, + amount = item.amount, + equip = item.equip, + identify = "1", + refine = item.refine, + attribute = item.attribute, + card0 = "0", + card1 = "0", + card2 = "0", + card3 = "0", + expire_time = "0", + favorite = "0", + bound = "0", + unique_id = "0" + )) + w.write("\n") diff --git a/hercules/code/server/evol/athena.py b/hercules/code/server/evol/athena.py index 9c03202..a4bb48f 100644 --- a/hercules/code/server/evol/athena.py +++ b/hercules/code/server/evol/athena.py @@ -38,7 +38,7 @@ def parseInventory(line, data): item.uknownId = rows2[0] item.itemId = rows2[1] - item.ammount = rows2[2] + item.amount = rows2[2] item.equip = rows2[3] item.color = rows2[4] item.refine = rows2[5] diff --git a/hercules/code/server/evol/main.py b/hercules/code/server/evol/main.py index 6910bf5..bdf202b 100644 --- a/hercules/code/server/evol/main.py +++ b/hercules/code/server/evol/main.py @@ -7,6 +7,7 @@ from code.server.account import * from code.server.db.char import * from code.server.db.charregnumdb import * +from code.server.db.inventory import * from code.server.db.skill import * from code.server.evol.athena import * from code.server.evol.consts import * @@ -34,3 +35,4 @@ def dbEvolMain(): saveCharTable(users) saveCharRegNumDbTable(users) saveSkillTable(users) + saveInventoryTable(users)
\ No newline at end of file diff --git a/hercules/templates/inventory.sql b/hercules/templates/inventory.sql new file mode 100644 index 0000000..196dc5d --- /dev/null +++ b/hercules/templates/inventory.sql @@ -0,0 +1,21 @@ +CREATE TABLE IF NOT EXISTS `inventory` ( + `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `char_id` INT(11) UNSIGNED NOT NULL DEFAULT '0', + `nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0', + `amount` INT(11) UNSIGNED NOT NULL DEFAULT '0', + `equip` INT(11) UNSIGNED NOT NULL DEFAULT '0', + `identify` SMALLINT(6) NOT NULL DEFAULT '0', + `refine` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', + `attribute` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0', + `card0` SMALLINT(11) NOT NULL DEFAULT '0', + `card1` SMALLINT(11) NOT NULL DEFAULT '0', + `card2` SMALLINT(11) NOT NULL DEFAULT '0', + `card3` SMALLINT(11) NOT NULL DEFAULT '0', + `expire_time` INT(11) UNSIGNED NOT NULL DEFAULT '0', + `favorite` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', + `bound` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', + `unique_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `char_id` (`char_id`) +) ENGINE=InnoDB; + |