log-profile.py 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  1. #!/usr/bin/python3
  2. import sys
  3. import os
  4. import sqlite3
  5. import json
  6. import math
  7. """
  8. Reads the API KEY, that must be passed as first command line argument.
  9. :returns: Recovered API KEY.
  10. :raises Exception: Th KEY couldn't be red.
  11. """
  12. def readKey():
  13. try:
  14. #print(sys.argv[1])
  15. key = sys.argv[1]
  16. return key
  17. except Exception as e:
  18. print("Error parsing API KEY: " + str(e))
  19. raise
  20. """
  21. Reads the JSON data, that must be passed as second command line argument.
  22. :returns: Recovered data, in JSON format.
  23. :raises Exception: The data couldn't be red or converted to JSON.
  24. """
  25. def readData():
  26. try:
  27. #print(sys.argv[1])
  28. #data = json.loads(sys.argv[1])
  29. with open(sys.argv[2], 'r') as f:
  30. content = f.read()
  31. data = json.loads(content)
  32. return data
  33. except Exception as e:
  34. print("Error parsing data: " + str(e))
  35. raise
  36. """
  37. Verifies that the API key matches the player data and that it exists in th DB.
  38. :param db: Connection to the database.
  39. :returns: Connection to the database.
  40. :param data: Data in json format.
  41. :param key: API KEY.
  42. :returns: True if key and player match, False otherwise.
  43. :raises IntegrityError: The queryes couldn't bre executed.
  44. """
  45. def verifyKey(db, data, key):
  46. print('Verifying KEY...')
  47. status = False
  48. try:
  49. uid = data["wizard_info"]["wizard_id"]
  50. cursor = db.cursor()
  51. cursor.execute('SELECT count(uid) AS c FROM player WHERE uid = ? AND api_key = ?;', (uid, key))
  52. if cursor.fetchone()[0] == 1:
  53. status = True
  54. cursor.close()
  55. except sqlite3.IntegrityError as e:
  56. print("Error executing statement: " + str(e))
  57. raise
  58. return status
  59. """
  60. Opens the database file and cleans the user tables.
  61. It also disables referencial integrity.
  62. :param name: The path to the sqlite database.
  63. :returns: Connection to the database.
  64. :raises IntegrityError: The queryes couldn't bre executed.
  65. :raises IOError: The sqlite file couldn't be created.
  66. """
  67. def openDatabase():
  68. kdb = os.path.dirname(os.path.realpath(sys.argv[0])) + '/../sw.sqlite'
  69. udb = os.path.dirname(os.path.realpath(sys.argv[0])) + '/../../data/sw.sqlite'
  70. print('Configuring database...')
  71. try:
  72. db = sqlite3.connect(kdb)
  73. cursor = db.cursor()
  74. cursor.execute("attach '" + udb + "' as data;")
  75. cursor.close()
  76. return db
  77. except sqlite3.IntegrityError as e:
  78. print("Error executing statement: " + str(e))
  79. raise
  80. except IOError as e:
  81. print("I/O Error creating database " + name + ": " + str(e))
  82. raise
  83. """
  84. Clears the user tables.
  85. It also disables referencial integrity.
  86. :param db: Sqlite database connection.
  87. :param data: Data in json format.
  88. :raises IntegrityError: The queryes couldn't bre executed.
  89. """
  90. def clearData(db, data):
  91. print('Clearing previous data...')
  92. try:
  93. uid = str(data["wizard_info"]["wizard_id"])
  94. print('UID: ' + str(uid))
  95. cursor = db.cursor()
  96. cursor.execute('PRAGMA foreign_keys = OFF;')
  97. cursor.execute('DELETE FROM scenario WHERE uid = ?', [uid])
  98. cursor.execute('DELETE FROM defense WHERE uid = ?', [uid])
  99. cursor.execute('DELETE FROM unit_skill WHERE unit IN (SELECT id FROM unit WHERE uid = ?)', [uid])
  100. cursor.execute('DELETE FROM unit WHERE uid = ?', [uid])
  101. cursor.execute('DELETE FROM rune WHERE uid = ?', [uid])
  102. cursor.execute('DELETE FROM building WHERE uid = ?', [uid])
  103. cursor.execute('DELETE FROM decoration WHERE uid = ?', [uid])
  104. cursor.execute('DELETE FROM inventory WHERE uid = ?', [uid])
  105. cursor.execute('DELETE FROM summon_special') # For every player
  106. cursor.execute('DELETE FROM guild') # TODO: Dont delete all guilds
  107. cursor.execute('DELETE FROM guild_member') # TODO: Dont delete all guilds, fix table
  108. cursor.execute('DELETE FROM rune_craft WHERE uid = ?', [uid])
  109. db.commit()
  110. cursor.close();
  111. except sqlite3.IntegrityError as e:
  112. print("Error executing statement: " + str(e))
  113. raise
  114. return
  115. """
  116. Closes the database.
  117. Before doing so, it also disables referencial integrity.
  118. :param db: Connection to the database.
  119. :returns: Connection to the database.
  120. :raises IntegrityError: The queryes couldn't bre executed.
  121. """
  122. def closeDatabase(name):
  123. print('Closing database connection...')
  124. try:
  125. cursor = db.cursor()
  126. cursor.execute('PRAGMA foreign_keys = ON;')
  127. cursor.close()
  128. db.commit()
  129. db.close()
  130. except sqlite3.IntegrityError as e:
  131. print("Error executing statement: " + str(e))
  132. raise
  133. """
  134. Inserts a row into the database.
  135. :param db: Connection to the database.
  136. :param table: Name of the table to insert into.
  137. :param values: List of values to insert.
  138. :raises IntegrityError: The insert query was unsuccesfull.
  139. """
  140. def insert(db, table, values):
  141. cursor = db.cursor()
  142. db.execute('PRAGMA foreign_keys = OFF;')
  143. placeholders = ''
  144. for x in range(0, len(values)):
  145. placeholders = placeholders + '?, '
  146. placeholders = placeholders[:len(placeholders) - 2]
  147. query = 'INSERT INTO ' + table + ' VALUES (' + placeholders + ')'
  148. try:
  149. cursor.execute(query, values)
  150. except sqlite3.IntegrityError as e:
  151. print('Error Inserting into ' + table + ' with values (' + str(values) + '): ' + str(e))
  152. raise
  153. cursor.close;
  154. """
  155. Parses player (table player).
  156. :param db: Sqlite database connection.
  157. :param data: Data in json format.
  158. """
  159. def parsePlayer(db, data):
  160. print("Parsing player...")
  161. cursor = db.cursor()
  162. uid = data["wizard_info"]["wizard_id"]
  163. name = data["wizard_info"]["wizard_name"]
  164. # TODO: Generate data
  165. mail = data["wizard_info"]["wizard_name"]
  166. password = data["wizard_info"]["wizard_name"]
  167. api_key = data["wizard_info"]["wizard_name"]
  168. mana = data["wizard_info"]["wizard_mana"]
  169. crystal = data["wizard_info"]["wizard_crystal"]
  170. country = data["wizard_info"]["wizard_last_country"]
  171. lang = data["wizard_info"]["wizard_last_lang"]
  172. level = data["wizard_info"]["wizard_level"]
  173. experience = data["wizard_info"]["experience"]
  174. energy = data["wizard_info"]["wizard_energy"]
  175. energy_max = data["wizard_info"]["energy_max"]
  176. energy_per_min = data["wizard_info"]["energy_per_min"]
  177. arena_energy = data["wizard_info"]["arena_energy"]
  178. arena_energy_max = data["wizard_info"]["arena_energy_max"]
  179. rep = data["wizard_info"]["rep_unit_id"]
  180. social_point = data["wizard_info"]["social_point_current"]
  181. honor_point = data["wizard_info"]["honor_point"]
  182. guild_point = data["wizard_info"]["guild_point"]
  183. darkportal_energy = data["wizard_info"]["darkportal_energy"]
  184. darkportal_energy_max = data["wizard_info"]["darkportal_energy_max"]
  185. dimension_energy = data["dimension_hole_info"]["energy"]
  186. dimension_energy_max = data["dimension_hole_info"]["energy_max"]
  187. costume_point = data["wizard_info"]["costume_point"]
  188. costume_point_max = data["wizard_info"]["costume_point_max"]
  189. honor_medal = data["wizard_info"]["honor_medal"]
  190. honor_mark = data["wizard_info"]["honor_mark"]
  191. event_coin = data["wizard_info"]["event_coin"]
  192. storage_slots = data["unit_depository_slots"]["number"]
  193. island_upgrade = 0
  194. for island in data["island_info"]:
  195. if island["id"] <= 7 and island["open"] == 1:
  196. island_upgrade = island["id"]
  197. query = '''
  198. UPDATE player
  199. SET mana = ?,
  200. crystal = ?,
  201. country = ?,
  202. lang = ?,
  203. level = ?,
  204. experience = ?,
  205. energy = ?,
  206. energy_max = ?,
  207. energy_per_min = ?,
  208. arena_energy = ?,
  209. arena_energy_max = ?,
  210. rep = ?,
  211. social_point = ?,
  212. honor_point = ?,
  213. guild_point = ?,
  214. darkportal_energy = ?,
  215. darkportal_energy_max = ?,
  216. dimension_energy = ?,
  217. dimension_energy_max = ?,
  218. costume_point = ?,
  219. costume_point_max = ?,
  220. honor_medal = ?,
  221. honor_medal = ?,
  222. event_coin = ?,
  223. storage_slots = ?,
  224. island = ?
  225. WHERE uid = ?;
  226. '''
  227. values = (
  228. mana, crystal, country,
  229. lang, level, experience,
  230. energy, energy_max, energy_per_min,
  231. arena_energy, arena_energy_max, rep,
  232. social_point, honor_point, guild_point,
  233. darkportal_energy, darkportal_energy_max, dimension_energy,
  234. dimension_energy_max, costume_point, costume_point_max,
  235. honor_medal, honor_medal, event_coin,
  236. storage_slots, island_upgrade, uid
  237. )
  238. try:
  239. cursor.execute(query, values)
  240. db.commit()
  241. except sqlite3.IntegrityError as e:
  242. print('Error updating player table with: ' + str(query) + ' <== ' + str(values) + ' || Error message:' + str(e))
  243. raise
  244. """
  245. Parses scenarios (table scenario).
  246. :param db: Sqlite database connection.
  247. :param data: Data in json format.
  248. """
  249. def parseScenarios(db, data):
  250. print("Parsing scenarios...")
  251. uid = data["wizard_info"]["wizard_id"]
  252. for sce in data["scenario_list"]:
  253. region = sce["region_id"]
  254. difficulty = sce["difficulty"]
  255. cleared = sce["cleared"]
  256. max_cleared = 0
  257. for stage in sce["stage_list"]:
  258. if stage["cleared"] == 1:
  259. max_cleared = stage["stage_no"]
  260. insert(db, "scenario", (uid, region, difficulty, cleared, max_cleared))
  261. db.commit()
  262. """
  263. Parses arena defense units (table defense).
  264. :param db: Sqlite database connection.
  265. :param data: Data in json format.
  266. """
  267. def parseDefense(db, data):
  268. print("Parsing arena defense...")
  269. uid = data["wizard_info"]["wizard_id"]
  270. for defense in data["defense_unit_list"]:
  271. unit = defense["unit_id"]
  272. position = defense["pos_id"]
  273. insert(db, "defense", (uid, unit, position))
  274. db.commit()
  275. """
  276. Parses buildings (table building).
  277. :param db: Sqlite database connection.
  278. :param data: Data in json format.
  279. """
  280. def parseBuildings(db, data):
  281. print("Parsing buildings...")
  282. uid = data["wizard_info"]["wizard_id"]
  283. for bui in data["building_list"]:
  284. id = bui["building_id"]
  285. building = bui["building_master_id"]
  286. gain = bui["gain_per_hour"]
  287. insert(db, "building", (uid, id, building, gain))
  288. db.commit()
  289. """
  290. Parses decoration buildings (table dcoration).
  291. :param db: Sqlite database connection.
  292. :param data: Data in json format.
  293. """
  294. def parseDecorations(db, data):
  295. print("Parsing decorations...")
  296. uid = data["wizard_info"]["wizard_id"]
  297. for bui in data["deco_list"]:
  298. id = bui["deco_id"]
  299. building = bui["master_id"]
  300. level = bui["level"]
  301. insert(db, "decoration", (uid, id, building, level))
  302. db.commit()
  303. """
  304. Parses unit data (tables unit, unit_skill).
  305. :param db: Sqlite database connection.
  306. :param data: Data in json format.
  307. """
  308. def parseUnits(db, data):
  309. print("Parsing monsters...")
  310. uid = data["wizard_info"]["wizard_id"]
  311. lock_list = data["unit_lock_list"]
  312. for mon in data["unit_list"]:
  313. id = mon["unit_id"]
  314. building = mon["building_id"]
  315. monster = mon["unit_master_id"]
  316. level = mon["unit_level"]
  317. stars = mon["class"]
  318. hp = mon["con"] * 15 # Always x15
  319. attack = mon["atk"]
  320. defense = mon["def"]
  321. speed = mon["spd"]
  322. crit_rate = mon["critical_rate"]
  323. crit_damage = mon["critical_damage"]
  324. resistance = mon["resist"]
  325. accuracy = mon["accuracy"]
  326. experience = mon["experience"]
  327. exp_gained = mon["exp_gained"]
  328. exp_gain_rate = mon["exp_gain_rate"]
  329. costume = mon["costume_master_id"]
  330. source = mon["source"]
  331. create_time = mon["create_time"]
  332. homunculus_name = mon["homunculus_name"]
  333. lock = 0
  334. if id in lock_list:
  335. lock = 1
  336. insert(db, "unit", (uid, id, building, monster, level, stars, hp, attack, defense, speed, crit_rate, crit_damage, resistance, accuracy, experience, exp_gained, exp_gain_rate, costume, source, create_time, homunculus_name, lock))
  337. for skill in mon["skills"]:
  338. skill_id = skill[0]
  339. skill_level = skill[1]
  340. insert(db, "unit_skill", (id, skill_id, skill_level))
  341. db.commit()
  342. """
  343. Parses inventory data (table inventory).
  344. :param db: Sqlite database connection.
  345. :param data: Data in json format.
  346. """
  347. def parseInventory(db, data):
  348. print("Parsing inventory...")
  349. uid = data["wizard_info"]["wizard_id"]
  350. for item in data["inventory_info"]:
  351. id = item["item_master_id"]
  352. type = item["item_master_type"]
  353. # TODO: Master id?
  354. amount = item["item_quantity"]
  355. insert(db, "inventory", (uid, id, type, amount))
  356. # Fix rune craft item type.
  357. cursor = db.cursor()
  358. cursor.execute("UPDATE inventory SET type = 27 WHERE type = 29 AND id IN (2001, 4001, 4002, 4003, 9001, 9002, 9003, 8001);")
  359. cursor.close()
  360. """
  361. Parses summon stone list (table summon_special).
  362. :param db: Sqlite database connection.
  363. :param data: Data in json format.
  364. """
  365. def parseSummonSpecial(db, data):
  366. print("Parsing Summon stone monster list...")
  367. uid = data["wizard_info"]["wizard_id"]
  368. for unit in data["summon_special_info"]["this"]:
  369. insert(db, "summon_special", (0, unit))
  370. for unit in data["summon_special_info"]["next"]:
  371. insert(db, "summon_special", (1, unit))
  372. for unit in data["summon_special_info"]["third"]:
  373. insert(db, "summon_special", (2, unit))
  374. for unit in data["summon_special_info"]["fourth"]:
  375. insert(db, "summon_special", (3, unit))
  376. """
  377. Parses rune data (table rune).
  378. :param db: Sqlite database connection.
  379. :param data: Data in json format.
  380. """
  381. def parseRunes(db, data):
  382. print("Parsing runes...")
  383. STAT_HP = 1
  384. STAT_HP_PCT = 2
  385. STAT_ATK = 3
  386. STAT_ATK_PCT = 4
  387. STAT_DEF = 5
  388. STAT_DEF_PCT = 6
  389. STAT_SPD = 8
  390. STAT_CRIT_RATE_PCT = 9
  391. STAT_CRIT_DMG_PCT = 10
  392. STAT_RESIST_PCT = 11
  393. STAT_ACCURACY_PCT = 12
  394. MAIN_STAT_VALUES = {
  395. # [stat][stars][level]: value
  396. STAT_HP: {
  397. 1: [40, 85, 130, 175, 220, 265, 310, 355, 400, 445, 490, 535, 580, 625, 670, 804],
  398. 2: [70, 130, 190, 250, 310, 370, 430, 490, 550, 610, 670, 730, 790, 850, 910, 1092],
  399. 3: [100, 175, 250, 325, 400, 475, 550, 625, 700, 775, 850, 925, 1000, 1075, 1150, 1380],
  400. 4: [160, 250, 340, 430, 520, 610, 700, 790, 880, 970, 1060, 1150, 1240, 1330, 1420, 1704],
  401. 5: [270, 375, 480, 585, 690, 795, 900, 1005, 1110, 1215, 1320, 1425, 1530, 1635, 1740, 2088],
  402. 6: [360, 480, 600, 720, 840, 960, 1080, 1200, 1320, 1440, 1560, 1680, 1800, 1920, 2040, 2448],
  403. },
  404. STAT_HP_PCT: {
  405. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  406. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  407. 3: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 38],
  408. 4: [5, 7, 9, 11, 13, 16, 18, 20, 22, 24, 27, 29, 31, 33, 36, 43],
  409. 5: [8, 10, 12, 15, 17, 20, 22, 24, 27, 29, 32, 34, 37, 40, 43, 51],
  410. 6: [11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 63],
  411. },
  412. STAT_ATK: {
  413. 1: [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 54],
  414. 2: [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 73],
  415. 3: [7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77, 92],
  416. 4: [10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 112],
  417. 5: [15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99, 106, 113, 135],
  418. 6: [22, 30, 38, 46, 54, 62, 70, 78, 86, 94, 102, 110, 118, 126, 134, 160],
  419. },
  420. STAT_ATK_PCT: {
  421. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  422. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  423. 3: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 38],
  424. 4: [5, 7, 9, 11, 13, 16, 18, 20, 22, 24, 27, 29, 31, 33, 36, 43],
  425. 5: [8, 10, 12, 15, 17, 20, 22, 24, 27, 29, 32, 34, 37, 40, 43, 51],
  426. 6: [11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 63],
  427. },
  428. STAT_DEF: {
  429. 1: [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 54],
  430. 2: [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 73],
  431. 3: [7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77, 92],
  432. 4: [10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 112],
  433. 5: [15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99, 106, 113, 135],
  434. 6: [22, 30, 38, 46, 54, 62, 70, 78, 86, 94, 102, 110, 118, 126, 134, 160],
  435. },
  436. STAT_DEF_PCT: {
  437. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  438. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  439. 3: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 38],
  440. 4: [5, 7, 9, 11, 13, 16, 18, 20, 22, 24, 27, 29, 31, 33, 36, 43],
  441. 5: [8, 10, 12, 15, 17, 20, 22, 24, 27, 29, 32, 34, 37, 40, 43, 51],
  442. 6: [11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 63],
  443. },
  444. STAT_SPD: {
  445. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  446. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  447. 3: [3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 19, 21, 25],
  448. 4: [4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 30],
  449. 5: [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 39],
  450. 6: [7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 42],
  451. },
  452. STAT_CRIT_RATE_PCT: {
  453. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  454. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  455. 3: [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 37],
  456. 4: [4, 6, 8, 11, 13, 15, 17, 19, 22, 24, 26, 28, 30, 33, 35, 41],
  457. 5: [5, 7, 10, 12, 15, 17, 19, 22, 24, 27, 29, 31, 34, 36, 39, 47],
  458. 6: [7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 58],
  459. },
  460. STAT_CRIT_DMG_PCT: {
  461. 1: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  462. 2: [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 37],
  463. 3: [4, 6, 9, 11, 13, 16, 18, 20, 22, 25, 27, 29, 32, 34, 36, 43],
  464. 4: [6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 57],
  465. 5: [8, 11, 15, 18, 21, 25, 28, 31, 34, 38, 41, 44, 48, 51, 54, 65],
  466. 6: [11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 80],
  467. },
  468. STAT_RESIST_PCT: {
  469. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  470. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  471. 3: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 38],
  472. 4: [6, 8, 10, 13, 15, 17, 19, 21, 24, 26, 28, 30, 32, 35, 37, 44],
  473. 5: [9, 11, 14, 16, 19, 21, 23, 26, 28, 31, 33, 35, 38, 40, 43, 51],
  474. 6: [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 64],
  475. },
  476. STAT_ACCURACY_PCT: {
  477. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  478. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  479. 3: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 38],
  480. 4: [6, 8, 10, 13, 15, 17, 19, 21, 24, 26, 28, 30, 32, 35, 37, 44],
  481. 5: [9, 11, 14, 16, 19, 21, 23, 26, 28, 31, 33, 35, 38, 40, 43, 51],
  482. 6: [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 64],
  483. },
  484. }
  485. SUBSTAT_INCREMENTS = {
  486. # [stat][stars]: value
  487. # Max possible substat value can be found by multiplying by 5
  488. STAT_HP: {
  489. 1: 60,
  490. 2: 105,
  491. 3: 165,
  492. 4: 225,
  493. 5: 300,
  494. 6: 375,
  495. },
  496. STAT_HP_PCT: {
  497. 1: 2,
  498. 2: 3,
  499. 3: 5,
  500. 4: 6,
  501. 5: 7,
  502. 6: 8,
  503. },
  504. STAT_ATK: {
  505. 1: 4,
  506. 2: 5,
  507. 3: 8,
  508. 4: 10,
  509. 5: 15,
  510. 6: 20,
  511. },
  512. STAT_ATK_PCT: {
  513. 1: 2,
  514. 2: 3,
  515. 3: 5,
  516. 4: 6,
  517. 5: 7,
  518. 6: 8,
  519. },
  520. STAT_DEF: {
  521. 1: 4,
  522. 2: 5,
  523. 3: 8,
  524. 4: 10,
  525. 5: 15,
  526. 6: 20,
  527. },
  528. STAT_DEF_PCT: {
  529. 1: 2,
  530. 2: 3,
  531. 3: 5,
  532. 4: 6,
  533. 5: 7,
  534. 6: 8,
  535. },
  536. STAT_SPD: {
  537. 1: 1,
  538. 2: 2,
  539. 3: 3,
  540. 4: 4,
  541. 5: 5,
  542. 6: 6,
  543. },
  544. STAT_CRIT_RATE_PCT: {
  545. 1: 1,
  546. 2: 2,
  547. 3: 3,
  548. 4: 4,
  549. 5: 5,
  550. 6: 6,
  551. },
  552. STAT_CRIT_DMG_PCT: {
  553. 1: 2,
  554. 2: 3,
  555. 3: 4,
  556. 4: 5,
  557. 5: 6,
  558. 6: 7,
  559. },
  560. STAT_RESIST_PCT: {
  561. 1: 2,
  562. 2: 3,
  563. 3: 5,
  564. 4: 6,
  565. 5: 7,
  566. 6: 8,
  567. },
  568. STAT_ACCURACY_PCT: {
  569. 1: 2,
  570. 2: 3,
  571. 3: 5,
  572. 4: 6,
  573. 5: 7,
  574. 6: 8,
  575. },
  576. }
  577. uid = data["wizard_info"]["wizard_id"]
  578. # Unequipped runes
  579. for rune in data["runes"]:
  580. id = rune["rune_id"]
  581. assigned_to = rune["occupied_id"]
  582. if assigned_to == 0:
  583. assigned_to = None
  584. runeset = rune["set_id"]
  585. slot = rune["slot_no"]
  586. stars = rune["class"]
  587. ancient = 0
  588. level = rune["upgrade_curr"]
  589. original_quality = rune["extra"]
  590. value = rune["sell_value"]
  591. if stars > 10:
  592. ancient = 1
  593. stars = stars - 10
  594. original_quality = original_quality - 10
  595. if level >= 12:
  596. quality = 5
  597. elif level >= 9:
  598. quality = 4
  599. elif level >= 6:
  600. quality = 3
  601. elif level >= 3:
  602. quality = 2
  603. else:
  604. quality = 1
  605. if original_quality > quality:
  606. quality = original_quality
  607. # TODO: Calculate
  608. #efficiency = rune["efficiency"]
  609. #max_efficiency = rune["max_efficiency"]
  610. efficiency = 0
  611. max_efficiency = 0
  612. main_stat = rune["pri_eff"][0]
  613. main_stat_value = rune["pri_eff"][1]
  614. if rune["prefix_eff"][0] > 0:
  615. innate_stat = rune["prefix_eff"][0]
  616. innate_stat_value = rune["prefix_eff"][1]
  617. else:
  618. innate_stat = None
  619. innate_stat_value = 0
  620. if len(rune["sec_eff"]) > 0:
  621. substat_1 = rune["sec_eff"][0][0]
  622. substat_1_value = rune["sec_eff"][0][1]
  623. substat_1_enchant = rune["sec_eff"][0][2]
  624. substat_1_grind = rune["sec_eff"][0][3]
  625. else:
  626. substat_1 = None
  627. substat_1_value = 0
  628. substat_1_enchant = 0
  629. substat_1_grind = 0
  630. if len(rune["sec_eff"]) > 1:
  631. substat_2 = rune["sec_eff"][1][0]
  632. substat_2_value = rune["sec_eff"][1][1]
  633. substat_2_enchant = rune["sec_eff"][1][2]
  634. substat_2_grind = rune["sec_eff"][1][3]
  635. else:
  636. substat_2 = None
  637. substat_2_value = 0
  638. substat_2_enchant = 0
  639. substat_2_grind = 0
  640. if len(rune["sec_eff"]) > 2:
  641. substat_3 = rune["sec_eff"][2][0]
  642. substat_3_value = rune["sec_eff"][2][1]
  643. substat_3_enchant = rune["sec_eff"][2][2]
  644. substat_3_grind = rune["sec_eff"][2][3]
  645. else:
  646. substat_3 = None
  647. substat_3_value = 0
  648. substat_3_enchant = 0
  649. substat_3_grind = 0
  650. if len(rune["sec_eff"]) > 3:
  651. substat_4 = rune["sec_eff"][3][0]
  652. substat_4_value = rune["sec_eff"][3][1]
  653. substat_4_enchant = rune["sec_eff"][3][2]
  654. substat_4_grind = rune["sec_eff"][3][3]
  655. else:
  656. substat_4 = None
  657. substat_4_value = 0
  658. substat_4_enchant = 0
  659. substat_4_grind = 0
  660. # Calculate efficiences
  661. efficiency = 0
  662. substats = []
  663. efficiency += float(MAIN_STAT_VALUES[main_stat][stars][15]) / float(MAIN_STAT_VALUES[main_stat][6][15])
  664. if innate_stat is not None:
  665. efficiency += innate_stat_value / float(SUBSTAT_INCREMENTS[innate_stat][6] * 5)
  666. if substat_1 is not None:
  667. substats.append(substat_1)
  668. efficiency += substat_1_value / float(SUBSTAT_INCREMENTS[substat_1][6] * 5)
  669. if substat_2 is not None:
  670. substats.append(substat_2)
  671. efficiency += substat_2_value / float(SUBSTAT_INCREMENTS[substat_2][6] * 5)
  672. if substat_3 is not None:
  673. substats.append(substat_3)
  674. efficiency += substat_3_value / float(SUBSTAT_INCREMENTS[substat_3][6] * 5)
  675. if substat_4 is not None:
  676. substats.append(substat_4)
  677. efficiency += substat_4_value / float(SUBSTAT_INCREMENTS[substat_4][6] * 5)
  678. efficiency = efficiency / 2.8 * 100
  679. max_efficiency = get_max_efficiency(substats, efficiency, level, stars, original_quality)
  680. if efficiency > 100:
  681. efficiency = 100;
  682. if max_efficiency > 100:
  683. max_efficiency = 100;
  684. insert(db, "rune", (uid, id, assigned_to, runeset, slot, stars, ancient, level, quality, original_quality, value, efficiency, max_efficiency, main_stat, main_stat_value, innate_stat, innate_stat_value, substat_1, substat_1_value, substat_1_enchant, substat_1_grind, substat_2, substat_2_value, substat_2_enchant, substat_2_grind, substat_3, substat_3_value, substat_3_enchant, substat_3_grind, substat_4, substat_4_value, substat_4_enchant, substat_4_grind))
  685. # Equipped runes
  686. for mon in data["unit_list"]:
  687. for rune in mon["runes"]:
  688. id = rune["rune_id"]
  689. assigned_to = rune["occupied_id"]
  690. if assigned_to == 0:
  691. assigned_to = None
  692. runeset = rune["set_id"]
  693. slot = rune["slot_no"]
  694. stars = rune["class"]
  695. ancient = 0
  696. level = rune["upgrade_curr"]
  697. original_quality = rune["extra"]
  698. value = rune["sell_value"]
  699. if stars > 10:
  700. ancient = 1
  701. stars = stars - 10
  702. original_quality = original_quality - 10
  703. if level >= 12:
  704. quality = 4
  705. elif level >= 9:
  706. quality = 3
  707. elif level >= 6:
  708. quality = 2
  709. elif level >= 3:
  710. quality = 1
  711. else:
  712. quality = 0
  713. if original_quality > quality:
  714. quality = original_quality
  715. # TODO: Calculate
  716. #efficiency = rune["efficiency"]
  717. #max_efficiency = rune["max_efficiency"]
  718. efficiency = 0
  719. max_efficiency = 0
  720. main_stat = rune["pri_eff"][0]
  721. main_stat_value = rune["pri_eff"][1]
  722. if rune["prefix_eff"][0] > 0:
  723. innate_stat = rune["prefix_eff"][0]
  724. innate_stat_value = rune["prefix_eff"][1]
  725. else:
  726. innate_stat = None
  727. innate_stat_value = 0
  728. if len(rune["sec_eff"]) > 0:
  729. substat_1 = rune["sec_eff"][0][0]
  730. substat_1_value = rune["sec_eff"][0][1]
  731. substat_1_enchant = rune["sec_eff"][0][2]
  732. substat_1_grind = rune["sec_eff"][0][3]
  733. else:
  734. substat_1 = None
  735. substat_1_value = 0
  736. substat_1_enchant = 0
  737. substat_1_grind = 0
  738. if len(rune["sec_eff"]) > 1:
  739. substat_2 = rune["sec_eff"][1][0]
  740. substat_2_value = rune["sec_eff"][1][1]
  741. substat_2_enchant = rune["sec_eff"][1][2]
  742. substat_2_grind = rune["sec_eff"][1][3]
  743. else:
  744. substat_2 = None
  745. substat_2_value = 0
  746. substat_2_enchant = 0
  747. substat_2_grind = 0
  748. if len(rune["sec_eff"]) > 2:
  749. substat_3 = rune["sec_eff"][2][0]
  750. substat_3_value = rune["sec_eff"][2][1]
  751. substat_3_enchant = rune["sec_eff"][2][2]
  752. substat_3_grind = rune["sec_eff"][2][3]
  753. else:
  754. substat_3 = None
  755. substat_3_value = 0
  756. substat_3_enchant = 0
  757. substat_3_grind = 0
  758. if len(rune["sec_eff"]) > 3:
  759. substat_4 = rune["sec_eff"][3][0]
  760. substat_4_value = rune["sec_eff"][3][1]
  761. substat_4_enchant = rune["sec_eff"][3][2]
  762. substat_4_grind = rune["sec_eff"][3][3]
  763. else:
  764. substat_4 = None
  765. substat_4_value = 0
  766. substat_4_enchant = 0
  767. substat_4_grind = 0
  768. # Calculate efficiences
  769. efficiency = 0
  770. substats = []
  771. efficiency += float(MAIN_STAT_VALUES[main_stat][stars][15]) / float(MAIN_STAT_VALUES[main_stat][6][15])
  772. if innate_stat is not None:
  773. efficiency += innate_stat_value / float(SUBSTAT_INCREMENTS[innate_stat][6] * 5)
  774. if substat_1 is not None:
  775. substats.append(substat_1)
  776. efficiency += substat_1_value / float(SUBSTAT_INCREMENTS[substat_1][6] * 5)
  777. if substat_2 is not None:
  778. substats.append(substat_2)
  779. efficiency += substat_2_value / float(SUBSTAT_INCREMENTS[substat_2][6] * 5)
  780. if substat_3 is not None:
  781. substats.append(substat_3)
  782. efficiency += substat_3_value / float(SUBSTAT_INCREMENTS[substat_3][6] * 5)
  783. if substat_4 is not None:
  784. substats.append(substat_4)
  785. efficiency += substat_4_value / float(SUBSTAT_INCREMENTS[substat_4][6] * 5)
  786. efficiency = efficiency / 2.8 * 100
  787. max_efficiency = get_max_efficiency(substats, efficiency, level, stars, original_quality)
  788. if efficiency > 100:
  789. efficiency = 100;
  790. if max_efficiency > 100:
  791. max_efficiency = 100;
  792. insert(db, "rune", (uid, id, assigned_to, runeset, slot, stars, ancient, level, quality, original_quality, value, efficiency, max_efficiency, main_stat, main_stat_value, innate_stat, innate_stat_value, substat_1, substat_1_value, substat_1_enchant, substat_1_grind, substat_2, substat_2_value, substat_2_enchant, substat_2_grind, substat_3, substat_3_value, substat_3_enchant, substat_3_grind, substat_4, substat_4_value, substat_4_enchant, substat_4_grind))
  793. db.commit()
  794. """
  795. calculates the max efficiency of a rune.
  796. :param substats: Array of substat types, dont include empty ones.
  797. :param efficiency: Current rune efficiency.
  798. :param level: Current rune level.
  799. :param stars: Rune stars.
  800. :param quality: Rune original quality.
  801. :return Max. efficiency.
  802. """
  803. def get_max_efficiency(substats, efficiency, level, stars, quality):
  804. STAT_HP = 1
  805. STAT_HP_PCT = 2
  806. STAT_ATK = 3
  807. STAT_ATK_PCT = 4
  808. STAT_DEF = 5
  809. STAT_DEF_PCT = 6
  810. STAT_SPD = 8
  811. STAT_CRIT_RATE_PCT = 9
  812. STAT_CRIT_DMG_PCT = 10
  813. STAT_RESIST_PCT = 11
  814. STAT_ACCURACY_PCT = 12
  815. SUBSTAT_INCREMENTS = {
  816. # [stat][stars]: value
  817. STAT_HP: {
  818. 1: 60,
  819. 2: 105,
  820. 3: 165,
  821. 4: 225,
  822. 5: 300,
  823. 6: 375,
  824. },
  825. STAT_HP_PCT: {
  826. 1: 2,
  827. 2: 3,
  828. 3: 5,
  829. 4: 6,
  830. 5: 7,
  831. 6: 8,
  832. },
  833. STAT_ATK: {
  834. 1: 4,
  835. 2: 5,
  836. 3: 8,
  837. 4: 10,
  838. 5: 15,
  839. 6: 20,
  840. },
  841. STAT_ATK_PCT: {
  842. 1: 2,
  843. 2: 3,
  844. 3: 5,
  845. 4: 6,
  846. 5: 7,
  847. 6: 8,
  848. },
  849. STAT_DEF: {
  850. 1: 4,
  851. 2: 5,
  852. 3: 8,
  853. 4: 10,
  854. 5: 15,
  855. 6: 20,
  856. },
  857. STAT_DEF_PCT: {
  858. 1: 2,
  859. 2: 3,
  860. 3: 5,
  861. 4: 6,
  862. 5: 7,
  863. 6: 8,
  864. },
  865. STAT_SPD: {
  866. 1: 1,
  867. 2: 2,
  868. 3: 3,
  869. 4: 4,
  870. 5: 5,
  871. 6: 6,
  872. },
  873. STAT_CRIT_RATE_PCT: {
  874. 1: 1,
  875. 2: 2,
  876. 3: 3,
  877. 4: 4,
  878. 5: 5,
  879. 6: 6,
  880. },
  881. STAT_CRIT_DMG_PCT: {
  882. 1: 2,
  883. 2: 3,
  884. 3: 4,
  885. 4: 5,
  886. 5: 6,
  887. 6: 7,
  888. },
  889. STAT_RESIST_PCT: {
  890. 1: 2,
  891. 2: 3,
  892. 3: 5,
  893. 4: 6,
  894. 5: 7,
  895. 6: 8,
  896. },
  897. STAT_ACCURACY_PCT: {
  898. 1: 2,
  899. 2: 3,
  900. 3: 5,
  901. 4: 6,
  902. 5: 7,
  903. 6: 8,
  904. },
  905. }
  906. UPGRADE_VALUES = {
  907. rune_type: {
  908. stars: value/level_data[6]
  909. for stars, value in level_data.items()
  910. }
  911. for rune_type, level_data in SUBSTAT_INCREMENTS.items()
  912. }
  913. #substat_upgrades_remaining = (4 - math.floor((min(level, 12) / 3))) - (3 - quality)
  914. substat_upgrades_remaining = (4 - math.floor((min(level, 12) / 3))) - max((3 - quality), 0)
  915. new_stats = max(min(4 - len(substats), substat_upgrades_remaining), 0)
  916. old_stats = substat_upgrades_remaining - new_stats
  917. if old_stats > 0:
  918. # we can repeatedly upgrade the most value of the existing stats
  919. best_stat = max(
  920. 0, # ensure max() doesn't error if we only have one stat
  921. *[UPGRADE_VALUES[stat][stars] for stat in substats]
  922. )
  923. efficiency += best_stat * old_stats * 0.2 / 2.8 * 100
  924. if new_stats:
  925. # add the top N stats
  926. available_upgrades = sorted(
  927. [
  928. upgrade_value[stars]
  929. for stat, upgrade_value in UPGRADE_VALUES.items()
  930. if stat not in substats
  931. ],
  932. reverse=True
  933. )
  934. efficiency += sum(available_upgrades[:new_stats]) * 0.2 / 2.8 * 100
  935. return efficiency
  936. """
  937. Parses rune craft item data (table rune_craft).
  938. :param db: Sqlite database connection.
  939. :param data: Data in json format.
  940. """
  941. def parseRuneCraft(db, data):
  942. print("Parsing rune craft itmes...")
  943. uid = data["wizard_info"]["wizard_id"]
  944. for item in data["rune_craft_item_list"]:
  945. id = item["craft_item_id"]
  946. type = item["craft_type"]
  947. value = item["sell_value"]
  948. info = str(item["craft_type_id"])
  949. """
  950. info : 5 or 6 digit number: RRSSQ
  951. RR: Rune
  952. SS: Stat
  953. Q: Quality
  954. """
  955. quality = int(info[-1:])
  956. stat = int(info[-4:-2])
  957. rune = int(info[:-4])
  958. insert(db, "rune_craft", (uid, id, type, quality, rune, stat, value))
  959. """
  960. Parses guild data (tables guild, guild_member).
  961. :param db: Sqlite database connection.
  962. :param data: Data in json format.
  963. """
  964. def parseGuild(db, data):
  965. print("Parsing guild...")
  966. if (data["guild"]["guild_info"] == None):
  967. # No guild
  968. return
  969. if len(data["guild"]["guild_info"]) < 1:
  970. return
  971. guild = data["guild"]["guild_info"]
  972. id = guild["guild_id"]
  973. name = guild["name"]
  974. level = guild["level"]
  975. experience = guild["experience"]
  976. recruiting = guild["recruit_status"]
  977. members = guild["member_now"]
  978. leader = guild["master_wizard_id"]
  979. comment = guild["comment"]
  980. notice = guild["notice"]
  981. insert(db, "guild", (id, name, level, experience, recruiting, members, leader, comment, notice))
  982. # Single quates ahead, dirty fix
  983. for k, member in data["guild"]["guild_members"].items():
  984. m = json.loads(str(member).replace("'", '"'))
  985. id = m["wizard_id"]
  986. guild = member["guild_id"]
  987. grade = member["grade"]
  988. name = member["wizard_name"]
  989. level = member["wizard_level"]
  990. rating = member["rating_id"]
  991. arena_score = member["arena_score"]
  992. joined = member["join_timestamp"]
  993. last_login = member["last_login_timestamp"]
  994. in_war = 0 # Checked later
  995. has_defense = 0 # Checked later
  996. insert(db, "guild_member", (id, guild, grade, name, level, rating, arena_score, joined, last_login, in_war, has_defense))
  997. cursor = db.cursor()
  998. for war in data["guildwar_member_list"]:
  999. cursor.execute("UPDATE guild_member SET in_war = 1 WHERE guild = ? AND id = ?;", (war["guild_id"], war["wizard_id"]))
  1000. for defense in data["guild_member_defense_list"]:
  1001. if len(defense["unit_list"]) > 0:
  1002. cursor.execute("UPDATE guild_member SET has_defense = 1 WHERE id = '" + str(defense["wizard_id"]) + "';")
  1003. db.commit()
  1004. cursor.close()
  1005. """
  1006. Deletes teams whose members no longer exists.
  1007. :param db: Sqlite database connection.
  1008. """
  1009. def reconfigureTeams(db):
  1010. print("Fixing teams...")
  1011. uid = data["wizard_info"]["wizard_id"]
  1012. cursor = db.cursor()
  1013. cursor.execute("DELETE FROM team WHERE id IN (SELECT DISTINCT team FROM team_unit WHERE unit NOT IN (SELECT DISTINCT id FROM unit WHERE uid = " + str(uid) + ")) AND uid = " + str(uid) + ";")
  1014. cursor.execute("DELETE FROM team_unit WHERE unit NOT IN (SELECT DISTINCT id FROM unit) OR team NOT IN (SELECT DISTINCT id FROM team);")
  1015. db.commit()
  1016. cursor.close()
  1017. """
  1018. Begin script
  1019. """
  1020. data = readData()
  1021. key = readKey()
  1022. db = openDatabase()
  1023. if verifyKey(db, data, key) == False:
  1024. print("Invalid API KEY...")
  1025. sys.exit(-1)
  1026. else:
  1027. clearData(db, data)
  1028. parsePlayer(db, data)
  1029. parseScenarios(db, data)
  1030. parseDefense(db, data)
  1031. parseBuildings(db, data)
  1032. parseDecorations(db, data)
  1033. # TODO homunculus_skill_list
  1034. parseUnits(db, data)
  1035. parseSummonSpecial(db, data)
  1036. parseInventory(db, data)
  1037. parseRunes(db, data)
  1038. parseRuneCraft(db, data)
  1039. parseGuild(db, data)
  1040. reconfigureTeams(db)
  1041. closeDatabase(db)
  1042. sys.exit(0);