summaryrefslogtreecommitdiff
path: root/hercules/code/server/db/skill.py
blob: d21eb3dcca995a7e9147ab86873bc3dcc25f0912 (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
# -*- coding: utf8 -*-
#
# Copyright (C) 2015  Evol Online
# Author: Andrei Karas (4144)

from code.fileutils import readFile

def saveSkillTable(users):
    dstFile = "newdb/skill.sql"
    firstLine = True
    tpl = readFile("templates/skill.sql")
    with open(dstFile, "w") as w:
        w.write(tpl)
        w.write("INSERT INTO `skill` VALUES ")
        for userId in users:
            user = users[userId]
            for skill in user.skills:

                if firstLine == False:
                    w.write(",\n")
                else:
                    firstLine = False

                w.write(("({char_id},{id},{lv},{flag})").format(
                    char_id = user.char_id,
                    id = skill.skillId,
                    lv = skill.level,
                    flag = 0
#                    flag = skill.flags
                ))
        w.write("\n")