log-profile.py 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  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. attribute = mon["attribute"]
  331. source = mon["source"]
  332. create_time = mon["create_time"]
  333. homunculus = mon["homunculus"]
  334. homunculus_name = mon["homunculus_name"]
  335. lock = 0
  336. if id in lock_list:
  337. lock = 1
  338. 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, attribute, source, create_time, homunculus, homunculus_name, lock))
  339. for skill in mon["skills"]:
  340. skill_id = skill[0]
  341. skill_level = skill[1]
  342. insert(db, "unit_skill", (id, skill_id, skill_level))
  343. db.commit()
  344. """
  345. Parses inventory data (table inventory).
  346. :param db: Sqlite database connection.
  347. :param data: Data in json format.
  348. """
  349. def parseInventory(db, data):
  350. print("Parsing inventory...")
  351. uid = data["wizard_info"]["wizard_id"]
  352. for item in data["inventory_info"]:
  353. id = item["item_master_id"]
  354. type = item["item_master_type"]
  355. # TODO: Master id?
  356. amount = item["item_quantity"]
  357. insert(db, "inventory", (uid, id, type, amount))
  358. # Fix rune craft item type.
  359. cursor = db.cursor()
  360. cursor.execute("UPDATE inventory SET type = 27 WHERE type = 29 AND id IN (2001, 4001, 4002, 4003, 9001, 9002, 9003, 8001);")
  361. cursor.close()
  362. """
  363. Parses summon stone list (table summon_special).
  364. :param db: Sqlite database connection.
  365. :param data: Data in json format.
  366. """
  367. def parseSummonSpecial(db, data):
  368. print("Parsing Summon stone monster list...")
  369. uid = data["wizard_info"]["wizard_id"]
  370. for unit in data["summon_special_info"]["this"]:
  371. insert(db, "summon_special", (0, unit))
  372. for unit in data["summon_special_info"]["next"]:
  373. insert(db, "summon_special", (1, unit))
  374. for unit in data["summon_special_info"]["third"]:
  375. insert(db, "summon_special", (2, unit))
  376. for unit in data["summon_special_info"]["fourth"]:
  377. insert(db, "summon_special", (3, unit))
  378. """
  379. Parses rune data (table rune).
  380. :param db: Sqlite database connection.
  381. :param data: Data in json format.
  382. """
  383. def parseRunes(db, data):
  384. print("Parsing runes...")
  385. STAT_HP = 1
  386. STAT_HP_PCT = 2
  387. STAT_ATK = 3
  388. STAT_ATK_PCT = 4
  389. STAT_DEF = 5
  390. STAT_DEF_PCT = 6
  391. STAT_SPD = 8
  392. STAT_CRIT_RATE_PCT = 9
  393. STAT_CRIT_DMG_PCT = 10
  394. STAT_RESIST_PCT = 11
  395. STAT_ACCURACY_PCT = 12
  396. MAIN_STAT_VALUES = {
  397. # [stat][stars][level]: value
  398. STAT_HP: {
  399. 1: [40, 85, 130, 175, 220, 265, 310, 355, 400, 445, 490, 535, 580, 625, 670, 804],
  400. 2: [70, 130, 190, 250, 310, 370, 430, 490, 550, 610, 670, 730, 790, 850, 910, 1092],
  401. 3: [100, 175, 250, 325, 400, 475, 550, 625, 700, 775, 850, 925, 1000, 1075, 1150, 1380],
  402. 4: [160, 250, 340, 430, 520, 610, 700, 790, 880, 970, 1060, 1150, 1240, 1330, 1420, 1704],
  403. 5: [270, 375, 480, 585, 690, 795, 900, 1005, 1110, 1215, 1320, 1425, 1530, 1635, 1740, 2088],
  404. 6: [360, 480, 600, 720, 840, 960, 1080, 1200, 1320, 1440, 1560, 1680, 1800, 1920, 2040, 2448],
  405. },
  406. STAT_HP_PCT: {
  407. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  408. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  409. 3: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 38],
  410. 4: [5, 7, 9, 11, 13, 16, 18, 20, 22, 24, 27, 29, 31, 33, 36, 43],
  411. 5: [8, 10, 12, 15, 17, 20, 22, 24, 27, 29, 32, 34, 37, 40, 43, 51],
  412. 6: [11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 63],
  413. },
  414. STAT_ATK: {
  415. 1: [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 54],
  416. 2: [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 73],
  417. 3: [7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77, 92],
  418. 4: [10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 112],
  419. 5: [15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99, 106, 113, 135],
  420. 6: [22, 30, 38, 46, 54, 62, 70, 78, 86, 94, 102, 110, 118, 126, 134, 160],
  421. },
  422. STAT_ATK_PCT: {
  423. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  424. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  425. 3: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 38],
  426. 4: [5, 7, 9, 11, 13, 16, 18, 20, 22, 24, 27, 29, 31, 33, 36, 43],
  427. 5: [8, 10, 12, 15, 17, 20, 22, 24, 27, 29, 32, 34, 37, 40, 43, 51],
  428. 6: [11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 63],
  429. },
  430. STAT_DEF: {
  431. 1: [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 54],
  432. 2: [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 73],
  433. 3: [7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77, 92],
  434. 4: [10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 112],
  435. 5: [15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99, 106, 113, 135],
  436. 6: [22, 30, 38, 46, 54, 62, 70, 78, 86, 94, 102, 110, 118, 126, 134, 160],
  437. },
  438. STAT_DEF_PCT: {
  439. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  440. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  441. 3: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 38],
  442. 4: [5, 7, 9, 11, 13, 16, 18, 20, 22, 24, 27, 29, 31, 33, 36, 43],
  443. 5: [8, 10, 12, 15, 17, 20, 22, 24, 27, 29, 32, 34, 37, 40, 43, 51],
  444. 6: [11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 63],
  445. },
  446. STAT_SPD: {
  447. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  448. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  449. 3: [3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 19, 21, 25],
  450. 4: [4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 30],
  451. 5: [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 39],
  452. 6: [7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 42],
  453. },
  454. STAT_CRIT_RATE_PCT: {
  455. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  456. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  457. 3: [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 37],
  458. 4: [4, 6, 8, 11, 13, 15, 17, 19, 22, 24, 26, 28, 30, 33, 35, 41],
  459. 5: [5, 7, 10, 12, 15, 17, 19, 22, 24, 27, 29, 31, 34, 36, 39, 47],
  460. 6: [7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 58],
  461. },
  462. STAT_CRIT_DMG_PCT: {
  463. 1: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  464. 2: [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 37],
  465. 3: [4, 6, 9, 11, 13, 16, 18, 20, 22, 25, 27, 29, 32, 34, 36, 43],
  466. 4: [6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 57],
  467. 5: [8, 11, 15, 18, 21, 25, 28, 31, 34, 38, 41, 44, 48, 51, 54, 65],
  468. 6: [11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 80],
  469. },
  470. STAT_RESIST_PCT: {
  471. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  472. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  473. 3: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 38],
  474. 4: [6, 8, 10, 13, 15, 17, 19, 21, 24, 26, 28, 30, 32, 35, 37, 44],
  475. 5: [9, 11, 14, 16, 19, 21, 23, 26, 28, 31, 33, 35, 38, 40, 43, 51],
  476. 6: [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 64],
  477. },
  478. STAT_ACCURACY_PCT: {
  479. 1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
  480. 2: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19],
  481. 3: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 38],
  482. 4: [6, 8, 10, 13, 15, 17, 19, 21, 24, 26, 28, 30, 32, 35, 37, 44],
  483. 5: [9, 11, 14, 16, 19, 21, 23, 26, 28, 31, 33, 35, 38, 40, 43, 51],
  484. 6: [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 64],
  485. },
  486. }
  487. SUBSTAT_INCREMENTS = {
  488. # [stat][stars]: value
  489. # Max possible substat value can be found by multiplying by 5
  490. STAT_HP: {
  491. 1: 60,
  492. 2: 105,
  493. 3: 165,
  494. 4: 225,
  495. 5: 300,
  496. 6: 375,
  497. },
  498. STAT_HP_PCT: {
  499. 1: 2,
  500. 2: 3,
  501. 3: 5,
  502. 4: 6,
  503. 5: 7,
  504. 6: 8,
  505. },
  506. STAT_ATK: {
  507. 1: 4,
  508. 2: 5,
  509. 3: 8,
  510. 4: 10,
  511. 5: 15,
  512. 6: 20,
  513. },
  514. STAT_ATK_PCT: {
  515. 1: 2,
  516. 2: 3,
  517. 3: 5,
  518. 4: 6,
  519. 5: 7,
  520. 6: 8,
  521. },
  522. STAT_DEF: {
  523. 1: 4,
  524. 2: 5,
  525. 3: 8,
  526. 4: 10,
  527. 5: 15,
  528. 6: 20,
  529. },
  530. STAT_DEF_PCT: {
  531. 1: 2,
  532. 2: 3,
  533. 3: 5,
  534. 4: 6,
  535. 5: 7,
  536. 6: 8,
  537. },
  538. STAT_SPD: {
  539. 1: 1,
  540. 2: 2,
  541. 3: 3,
  542. 4: 4,
  543. 5: 5,
  544. 6: 6,
  545. },
  546. STAT_CRIT_RATE_PCT: {
  547. 1: 1,
  548. 2: 2,
  549. 3: 3,
  550. 4: 4,
  551. 5: 5,
  552. 6: 6,
  553. },
  554. STAT_CRIT_DMG_PCT: {
  555. 1: 2,
  556. 2: 3,
  557. 3: 4,
  558. 4: 5,
  559. 5: 6,
  560. 6: 7,
  561. },
  562. STAT_RESIST_PCT: {
  563. 1: 2,
  564. 2: 3,
  565. 3: 5,
  566. 4: 6,
  567. 5: 7,
  568. 6: 8,
  569. },
  570. STAT_ACCURACY_PCT: {
  571. 1: 2,
  572. 2: 3,
  573. 3: 5,
  574. 4: 6,
  575. 5: 7,
  576. 6: 8,
  577. },
  578. }
  579. uid = data["wizard_info"]["wizard_id"]
  580. # Unequipped runes
  581. for rune in data["runes"]:
  582. id = rune["rune_id"]
  583. assigned_to = rune["occupied_id"]
  584. if assigned_to == 0:
  585. assigned_to = None
  586. runeset = rune["set_id"]
  587. slot = rune["slot_no"]
  588. stars = rune["class"]
  589. ancient = 0
  590. level = rune["upgrade_curr"]
  591. original_quality = rune["extra"]
  592. value = rune["sell_value"]
  593. if stars > 10:
  594. ancient = 1
  595. stars = stars - 10
  596. original_quality = original_quality - 10
  597. if level >= 12:
  598. quality = 5
  599. elif level >= 9:
  600. quality = 4
  601. elif level >= 6:
  602. quality = 3
  603. elif level >= 3:
  604. quality = 2
  605. else:
  606. quality = 1
  607. if original_quality > quality:
  608. quality = original_quality
  609. # TODO: Calculate
  610. #efficiency = rune["efficiency"]
  611. #max_efficiency = rune["max_efficiency"]
  612. efficiency = 0
  613. max_efficiency = 0
  614. main_stat = rune["pri_eff"][0]
  615. main_stat_value = rune["pri_eff"][1]
  616. if rune["prefix_eff"][0] > 0:
  617. innate_stat = rune["prefix_eff"][0]
  618. innate_stat_value = rune["prefix_eff"][1]
  619. else:
  620. innate_stat = None
  621. innate_stat_value = 0
  622. if len(rune["sec_eff"]) > 0:
  623. substat_1 = rune["sec_eff"][0][0]
  624. substat_1_value = rune["sec_eff"][0][1]
  625. substat_1_enchant = rune["sec_eff"][0][2]
  626. substat_1_grind = rune["sec_eff"][0][3]
  627. else:
  628. substat_1 = None
  629. substat_1_value = 0
  630. substat_1_enchant = 0
  631. substat_1_grind = 0
  632. if len(rune["sec_eff"]) > 1:
  633. substat_2 = rune["sec_eff"][1][0]
  634. substat_2_value = rune["sec_eff"][1][1]
  635. substat_2_enchant = rune["sec_eff"][1][2]
  636. substat_2_grind = rune["sec_eff"][1][3]
  637. else:
  638. substat_2 = None
  639. substat_2_value = 0
  640. substat_2_enchant = 0
  641. substat_2_grind = 0
  642. if len(rune["sec_eff"]) > 2:
  643. substat_3 = rune["sec_eff"][2][0]
  644. substat_3_value = rune["sec_eff"][2][1]
  645. substat_3_enchant = rune["sec_eff"][2][2]
  646. substat_3_grind = rune["sec_eff"][2][3]
  647. else:
  648. substat_3 = None
  649. substat_3_value = 0
  650. substat_3_enchant = 0
  651. substat_3_grind = 0
  652. if len(rune["sec_eff"]) > 3:
  653. substat_4 = rune["sec_eff"][3][0]
  654. substat_4_value = rune["sec_eff"][3][1]
  655. substat_4_enchant = rune["sec_eff"][3][2]
  656. substat_4_grind = rune["sec_eff"][3][3]
  657. else:
  658. substat_4 = None
  659. substat_4_value = 0
  660. substat_4_enchant = 0
  661. substat_4_grind = 0
  662. # Calculate efficiences
  663. efficiency = 0
  664. substats = []
  665. efficiency += float(MAIN_STAT_VALUES[main_stat][stars][15]) / float(MAIN_STAT_VALUES[main_stat][6][15])
  666. if innate_stat is not None:
  667. efficiency += innate_stat_value / float(SUBSTAT_INCREMENTS[innate_stat][6] * 5)
  668. if substat_1 is not None:
  669. substats.append(substat_1)
  670. efficiency += substat_1_value / float(SUBSTAT_INCREMENTS[substat_1][6] * 5)
  671. if substat_2 is not None:
  672. substats.append(substat_2)
  673. efficiency += substat_2_value / float(SUBSTAT_INCREMENTS[substat_2][6] * 5)
  674. if substat_3 is not None:
  675. substats.append(substat_3)
  676. efficiency += substat_3_value / float(SUBSTAT_INCREMENTS[substat_3][6] * 5)
  677. if substat_4 is not None:
  678. substats.append(substat_4)
  679. efficiency += substat_4_value / float(SUBSTAT_INCREMENTS[substat_4][6] * 5)
  680. efficiency = efficiency / 2.8 * 100
  681. max_efficiency = get_max_efficiency(substats, efficiency, level, stars, original_quality)
  682. if efficiency > 100:
  683. efficiency = 100;
  684. if max_efficiency > 100:
  685. max_efficiency = 100;
  686. 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))
  687. # Equipped runes
  688. for mon in data["unit_list"]:
  689. for rune in mon["runes"]:
  690. id = rune["rune_id"]
  691. assigned_to = rune["occupied_id"]
  692. if assigned_to == 0:
  693. assigned_to = None
  694. runeset = rune["set_id"]
  695. slot = rune["slot_no"]
  696. stars = rune["class"]
  697. ancient = 0
  698. level = rune["upgrade_curr"]
  699. original_quality = rune["extra"]
  700. value = rune["sell_value"]
  701. if stars > 10:
  702. ancient = 1
  703. stars = stars - 10
  704. original_quality = original_quality - 10
  705. if level >= 12:
  706. quality = 4
  707. elif level >= 9:
  708. quality = 3
  709. elif level >= 6:
  710. quality = 2
  711. elif level >= 3:
  712. quality = 1
  713. else:
  714. quality = 0
  715. if original_quality > quality:
  716. quality = original_quality
  717. # TODO: Calculate
  718. #efficiency = rune["efficiency"]
  719. #max_efficiency = rune["max_efficiency"]
  720. efficiency = 0
  721. max_efficiency = 0
  722. main_stat = rune["pri_eff"][0]
  723. main_stat_value = rune["pri_eff"][1]
  724. if rune["prefix_eff"][0] > 0:
  725. innate_stat = rune["prefix_eff"][0]
  726. innate_stat_value = rune["prefix_eff"][1]
  727. else:
  728. innate_stat = None
  729. innate_stat_value = 0
  730. if len(rune["sec_eff"]) > 0:
  731. substat_1 = rune["sec_eff"][0][0]
  732. substat_1_value = rune["sec_eff"][0][1]
  733. substat_1_enchant = rune["sec_eff"][0][2]
  734. substat_1_grind = rune["sec_eff"][0][3]
  735. else:
  736. substat_1 = None
  737. substat_1_value = 0
  738. substat_1_enchant = 0
  739. substat_1_grind = 0
  740. if len(rune["sec_eff"]) > 1:
  741. substat_2 = rune["sec_eff"][1][0]
  742. substat_2_value = rune["sec_eff"][1][1]
  743. substat_2_enchant = rune["sec_eff"][1][2]
  744. substat_2_grind = rune["sec_eff"][1][3]
  745. else:
  746. substat_2 = None
  747. substat_2_value = 0
  748. substat_2_enchant = 0
  749. substat_2_grind = 0
  750. if len(rune["sec_eff"]) > 2:
  751. substat_3 = rune["sec_eff"][2][0]
  752. substat_3_value = rune["sec_eff"][2][1]
  753. substat_3_enchant = rune["sec_eff"][2][2]
  754. substat_3_grind = rune["sec_eff"][2][3]
  755. else:
  756. substat_3 = None
  757. substat_3_value = 0
  758. substat_3_enchant = 0
  759. substat_3_grind = 0
  760. if len(rune["sec_eff"]) > 3:
  761. substat_4 = rune["sec_eff"][3][0]
  762. substat_4_value = rune["sec_eff"][3][1]
  763. substat_4_enchant = rune["sec_eff"][3][2]
  764. substat_4_grind = rune["sec_eff"][3][3]
  765. else:
  766. substat_4 = None
  767. substat_4_value = 0
  768. substat_4_enchant = 0
  769. substat_4_grind = 0
  770. # Calculate efficiences
  771. efficiency = 0
  772. substats = []
  773. efficiency += float(MAIN_STAT_VALUES[main_stat][stars][15]) / float(MAIN_STAT_VALUES[main_stat][6][15])
  774. if innate_stat is not None:
  775. efficiency += innate_stat_value / float(SUBSTAT_INCREMENTS[innate_stat][6] * 5)
  776. if substat_1 is not None:
  777. substats.append(substat_1)
  778. efficiency += substat_1_value / float(SUBSTAT_INCREMENTS[substat_1][6] * 5)
  779. if substat_2 is not None:
  780. substats.append(substat_2)
  781. efficiency += substat_2_value / float(SUBSTAT_INCREMENTS[substat_2][6] * 5)
  782. if substat_3 is not None:
  783. substats.append(substat_3)
  784. efficiency += substat_3_value / float(SUBSTAT_INCREMENTS[substat_3][6] * 5)
  785. if substat_4 is not None:
  786. substats.append(substat_4)
  787. efficiency += substat_4_value / float(SUBSTAT_INCREMENTS[substat_4][6] * 5)
  788. efficiency = efficiency / 2.8 * 100
  789. max_efficiency = get_max_efficiency(substats, efficiency, level, stars, original_quality)
  790. if efficiency > 100:
  791. efficiency = 100;
  792. if max_efficiency > 100:
  793. max_efficiency = 100;
  794. 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))
  795. db.commit()
  796. """
  797. calculates the max efficiency of a rune.
  798. :param substats: Array of substat types, dont include empty ones.
  799. :param efficiency: Current rune efficiency.
  800. :param level: Current rune level.
  801. :param stars: Rune stars.
  802. :param quality: Rune original quality.
  803. :return Max. efficiency.
  804. """
  805. def get_max_efficiency(substats, efficiency, level, stars, quality):
  806. STAT_HP = 1
  807. STAT_HP_PCT = 2
  808. STAT_ATK = 3
  809. STAT_ATK_PCT = 4
  810. STAT_DEF = 5
  811. STAT_DEF_PCT = 6
  812. STAT_SPD = 8
  813. STAT_CRIT_RATE_PCT = 9
  814. STAT_CRIT_DMG_PCT = 10
  815. STAT_RESIST_PCT = 11
  816. STAT_ACCURACY_PCT = 12
  817. SUBSTAT_INCREMENTS = {
  818. # [stat][stars]: value
  819. STAT_HP: {
  820. 1: 60,
  821. 2: 105,
  822. 3: 165,
  823. 4: 225,
  824. 5: 300,
  825. 6: 375,
  826. },
  827. STAT_HP_PCT: {
  828. 1: 2,
  829. 2: 3,
  830. 3: 5,
  831. 4: 6,
  832. 5: 7,
  833. 6: 8,
  834. },
  835. STAT_ATK: {
  836. 1: 4,
  837. 2: 5,
  838. 3: 8,
  839. 4: 10,
  840. 5: 15,
  841. 6: 20,
  842. },
  843. STAT_ATK_PCT: {
  844. 1: 2,
  845. 2: 3,
  846. 3: 5,
  847. 4: 6,
  848. 5: 7,
  849. 6: 8,
  850. },
  851. STAT_DEF: {
  852. 1: 4,
  853. 2: 5,
  854. 3: 8,
  855. 4: 10,
  856. 5: 15,
  857. 6: 20,
  858. },
  859. STAT_DEF_PCT: {
  860. 1: 2,
  861. 2: 3,
  862. 3: 5,
  863. 4: 6,
  864. 5: 7,
  865. 6: 8,
  866. },
  867. STAT_SPD: {
  868. 1: 1,
  869. 2: 2,
  870. 3: 3,
  871. 4: 4,
  872. 5: 5,
  873. 6: 6,
  874. },
  875. STAT_CRIT_RATE_PCT: {
  876. 1: 1,
  877. 2: 2,
  878. 3: 3,
  879. 4: 4,
  880. 5: 5,
  881. 6: 6,
  882. },
  883. STAT_CRIT_DMG_PCT: {
  884. 1: 2,
  885. 2: 3,
  886. 3: 4,
  887. 4: 5,
  888. 5: 6,
  889. 6: 7,
  890. },
  891. STAT_RESIST_PCT: {
  892. 1: 2,
  893. 2: 3,
  894. 3: 5,
  895. 4: 6,
  896. 5: 7,
  897. 6: 8,
  898. },
  899. STAT_ACCURACY_PCT: {
  900. 1: 2,
  901. 2: 3,
  902. 3: 5,
  903. 4: 6,
  904. 5: 7,
  905. 6: 8,
  906. },
  907. }
  908. UPGRADE_VALUES = {
  909. rune_type: {
  910. stars: value/level_data[6]
  911. for stars, value in level_data.items()
  912. }
  913. for rune_type, level_data in SUBSTAT_INCREMENTS.items()
  914. }
  915. #substat_upgrades_remaining = (4 - math.floor((min(level, 12) / 3))) - (3 - quality)
  916. substat_upgrades_remaining = (4 - math.floor((min(level, 12) / 3))) - max((3 - quality), 0)
  917. new_stats = max(min(4 - len(substats), substat_upgrades_remaining), 0)
  918. old_stats = substat_upgrades_remaining - new_stats
  919. if old_stats > 0:
  920. # we can repeatedly upgrade the most value of the existing stats
  921. best_stat = max(
  922. 0, # ensure max() doesn't error if we only have one stat
  923. *[UPGRADE_VALUES[stat][stars] for stat in substats]
  924. )
  925. efficiency += best_stat * old_stats * 0.2 / 2.8 * 100
  926. if new_stats:
  927. # add the top N stats
  928. available_upgrades = sorted(
  929. [
  930. upgrade_value[stars]
  931. for stat, upgrade_value in UPGRADE_VALUES.items()
  932. if stat not in substats
  933. ],
  934. reverse=True
  935. )
  936. efficiency += sum(available_upgrades[:new_stats]) * 0.2 / 2.8 * 100
  937. return efficiency
  938. """
  939. Parses rune craft item data (table rune_craft).
  940. :param db: Sqlite database connection.
  941. :param data: Data in json format.
  942. """
  943. def parseRuneCraft(db, data):
  944. print("Parsing rune craft itmes...")
  945. uid = data["wizard_info"]["wizard_id"]
  946. for item in data["rune_craft_item_list"]:
  947. id = item["craft_item_id"]
  948. type = item["craft_type"]
  949. value = item["sell_value"]
  950. info = str(item["craft_type_id"])
  951. """
  952. info : 5 or 6 digit number: RRSSQ
  953. RR: Rune
  954. SS: Stat
  955. Q: Quality
  956. """
  957. quality = int(info[-1:])
  958. stat = int(info[-4:-2])
  959. rune = int(info[:-4])
  960. insert(db, "rune_craft", (uid, id, type, quality, rune, stat, value))
  961. """
  962. Parses guild data (tables guild, guild_member).
  963. :param db: Sqlite database connection.
  964. :param data: Data in json format.
  965. """
  966. def parseGuild(db, data):
  967. print("Parsing guild...")
  968. if len(data["guild"]["guild_info"]) < 1:
  969. return
  970. guild = data["guild"]["guild_info"]
  971. id = guild["guild_id"]
  972. name = guild["name"]
  973. level = guild["level"]
  974. experience = guild["experience"]
  975. recruiting = guild["recruit_status"]
  976. members = guild["member_now"]
  977. leader = guild["master_wizard_id"]
  978. comment = guild["comment"]
  979. notice = guild["notice"]
  980. insert(db, "guild", (id, name, level, experience, recruiting, members, leader, comment, notice))
  981. # Single quates ahead, dirty fix
  982. for k, member in data["guild"]["guild_members"].items():
  983. m = json.loads(str(member).replace("'", '"'))
  984. id = m["wizard_id"]
  985. guild = member["guild_id"]
  986. grade = member["grade"]
  987. name = member["wizard_name"]
  988. level = member["wizard_level"]
  989. rating = member["rating_id"]
  990. arena_score = member["arena_score"]
  991. joined = member["join_timestamp"]
  992. last_login = member["last_login_timestamp"]
  993. in_war = 0 # Checked later
  994. has_defense = 0 # Checked later
  995. insert(db, "guild_member", (id, guild, grade, name, level, rating, arena_score, joined, last_login, in_war, has_defense))
  996. cursor = db.cursor()
  997. for war in data["guildwar_member_list"]:
  998. cursor.execute("UPDATE guild_member SET in_war = 1 WHERE guild = ? AND id = ?;", (war["guild_id"], war["wizard_id"]))
  999. for defense in data["guild_member_defense_list"]:
  1000. if len(defense["unit_list"]) > 0:
  1001. cursor.execute("UPDATE guild_member SET has_defense = 1 WHERE id = '" + str(defense["wizard_id"]) + "';")
  1002. db.commit()
  1003. cursor.close()
  1004. """
  1005. Deletes teams whose members no longer exists.
  1006. :param db: Sqlite database connection.
  1007. """
  1008. def reconfigureTeams(db):
  1009. print("Fixing teams...")
  1010. uid = data["wizard_info"]["wizard_id"]
  1011. cursor = db.cursor()
  1012. 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) + ";")
  1013. cursor.execute("DELETE FROM team_unit WHERE unit NOT IN (SELECT DISTINCT id FROM unit) OR team NOT IN (SELECT DISTINCT id FROM team);")
  1014. db.commit()
  1015. cursor.close()
  1016. """
  1017. Begin script
  1018. """
  1019. data = readData()
  1020. key = readKey()
  1021. db = openDatabase()
  1022. if verifyKey(db, data, key) == False:
  1023. print("Invalid API KEY...")
  1024. sys.exit(-1)
  1025. else:
  1026. clearData(db, data)
  1027. parsePlayer(db, data)
  1028. parseScenarios(db, data)
  1029. parseDefense(db, data)
  1030. parseBuildings(db, data)
  1031. parseDecorations(db, data)
  1032. # TODO homunculus_skill_list
  1033. parseUnits(db, data)
  1034. parseSummonSpecial(db, data)
  1035. parseInventory(db, data)
  1036. parseRunes(db, data)
  1037. parseRuneCraft(db, data)
  1038. parseGuild(db, data)
  1039. reconfigureTeams(db)
  1040. closeDatabase(db)
  1041. sys.exit(0);