summaryrefslogtreecommitdiff
path: root/hercules/code/server/db/inventory.py
blob: e5c1e6ac19c63a012ce9e1974976192c71052cf2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf8 -*-
#
# Copyright (C) 2015  Evol Online
# Author: Andrei Karas (4144)

from code.fileutils import readFile

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")