-
Notifications
You must be signed in to change notification settings - Fork 1
/
BCB_FFRK_Inventory_Exporter_v1.03.py
614 lines (525 loc) · 25.4 KB
/
BCB_FFRK_Inventory_Exporter_v1.03.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
# coding=utf-8
from json import dump, loads
from os import write, read, path, remove
from datetime import datetime
japan = 0
ignore_crappy_core_soul_breaks = 1
ignore_three_star_and_lower_relics = 1
soul_break_export_level = 2
only_export_level_99_magicite = 1
export_raw_json = 0
modified_id_export = 1
depricated_comma_seperated_export = 0
print("Enter your Item Inventory, and then your Vault, to export all data.")
def response(flow):
cases = {
'/dff/party/list_equipment': 'inventory_relics',
'/dff/party/list_other': 'list_other',
'/dff/party/list_buddy?part=0&split=3': 'soul_breaks0',
'/dff/party/list_buddy?part=1&split=3': 'soul_breaks1',
'/dff/party/list_buddy?part=2&split=3': 'soul_breaks2',
'/dff/beast/list1': 'main_magicite1',
'/dff/beast/list2': 'main_magicite2',
'/dff/warehouse/get_equipment_list': 'vault_relic',
'/dff/warehouse/get_record_materia_list': 'vault_rm',
'/dff/warehouse/get_beast_list': 'vault_magicite',
'/dff/equipment_reference/equipment_references?type=GET': 'equip_collection'
}
if flow.request.path not in cases.keys():
return
data = loads(flow.response.content.decode('utf-8-sig'))
if cases[flow.request.path] == 'inventory_relics':
getRelics(data['equipments'], '1-FFRK-Inventory-Relics')
if export_raw_json == 1:
exportRawJson(data, 'list_equipment','')
elif cases[flow.request.path] == 'main_magicite1':
getMagicite(data['beasts'], '5-FFRK-Magicite1')
if export_raw_json == 1:
exportRawJson(data, 'list1','')
elif cases[flow.request.path] == 'main_magicite2':
getMagicite2(data['beasts'], '5-FFRK-Magicite2')
if export_raw_json == 1:
exportRawJson(data, 'list2','')
elif cases[flow.request.path] == 'vault_relic':
getRelics(data['equipments'], '2-FFRK-Vault-Relics')
if export_raw_json == 1:
exportRawJson(data, 'get_equipment_list','')
elif cases[flow.request.path] == 'soul_breaks0':
getSBs(data['soul_strikes'], '3-FFRK-Soul-Breaks',0)
getLMs(data['legend_materias'], '7-FFRK-Legend-Materia',0)
# getCharacters(data['buddies'], 'X-FFRK-Characters') #
if export_raw_json == 1:
exportRawJson(data, 'list_buddy','0')
elif cases[flow.request.path] == 'soul_breaks1':
getSBs(data['soul_strikes'], '3-FFRK-Soul-Breaks',1)
getLMs(data['legend_materias'], '7-FFRK-Legend-Materia',1)
# getCharacters(data['buddies'], 'X-FFRK-Characters') #
if export_raw_json == 1:
exportRawJson(data, 'list_buddy','1')
elif cases[flow.request.path] == 'soul_breaks2':
getSBs(data['soul_strikes'], '3-FFRK-Soul-Breaks',2)
if export_raw_json == 1:
exportRawJson(data, 'list_buddy','2')
elif cases[flow.request.path] == 'list_other':
getAbilities(data['abilities'], '4-FFRK-Abilities')
getOrbs(data['materials'], '6-FFRK-Orbs')
# getRMs(data['record_materias'], 'X-FFRK-Inventory-Record-Materia') #
if export_raw_json == 1:
exportRawJson(data, 'list_other','')
elif cases[flow.request.path] == 'equip_collection':
# getEquipHistory(data['equipment_references'], 'X-FFRK-Equipment-Collection') #
pass
if export_raw_json == 1:
exportRawJson(data, 'equip_collection','')
elif cases[flow.request.path] == 'vault_rm':
# getRMs(data['record_materias'], 'X-FFRK-Vault-Record-Materia') #
pass
if export_raw_json == 1:
exportRawJson(data, 'get_record_materia_list','')
elif cases[flow.request.path] == 'vault_magicite':
# getVaultMagicite(data['beasts'], 'X-FFRK-Vault-Magicite') #
pass
if export_raw_json == 1:
exportRawJson(data, 'get_beast_list','')
def getRelics(data, filename):
elems = []
count = 0
for elem in data:
relic_id = elem['equipment_id']
name = elem['name'].replace(u'+', '+')
base_rarity = elem['base_rarity']
rarity = elem['rarity']
evolution_num = elem['evolution_num']
realm_id = int(str(elem['series_id'])[1:3]) if elem['series_id'] > 10 else 99
if modified_id_export == 1 and elem['rarity'] < 101:
if (rarity - base_rarity) == 1:
relic_id = relic_id*10 + 1
elif (rarity - base_rarity) == 2:
relic_id = relic_id*10 + 2
elif (rarity - base_rarity) == 3:
relic_id = relic_id*10 + 3
else:
relic_id = relic_id*10
if modified_id_export == 1 and elem['rarity'] == 101:
if (evolution_num == 3):
relic_id = relic_id*10 + 3
rarity += 3
elif (evolution_num == 2):
relic_id = relic_id*10 + 2
rarity += 2
elif (evolution_num == 1):
relic_id = relic_id*10 + 1
rarity += 1
else:
relic_id = relic_id*10
rosetta_param = elem['hammering_affect_param_key']
rosetta_value = elem['hammering_num']
rosetta_atk = rosetta_def = rosetta_matk = rosetta_mdef = rosetta_mnd = 0
if rosetta_param == 'atk':
rosetta_atk = rosetta_value
elif rosetta_param == 'def':
rosetta_def = rosetta_value
elif rosetta_param == 'matk':
rosetta_matk = rosetta_value
elif rosetta_param == 'mdef':
rosetta_mdef = rosetta_value
elif rosetta_param == 'mnd':
rosetta_mnd = rosetta_value
inherit_effect = ''
if elem['rarity'] == 101:
inherit_effect = elem['buddy_sacred_equipment_materias'][0]['record_materia']['name']
elems.append(
[relic_id, name, base_rarity, rarity, realm_id, rosetta_atk, rosetta_def, rosetta_matk, rosetta_mdef,
rosetta_mnd, inherit_effect])
elems = sorted(elems, key=lambda x: (x[0], -x[3], x[4], x[1]))
if depricated_comma_seperated_export:
with open('{}.csv'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID, Item, Base Rarity, Rarity, Realm, A.Atk, A.Def, A.Mag, A.Res, A.Mnd, Inherit Effect\n')
for elem in elems:
if ignore_three_star_and_lower_relics == 1:
if elem[3] > 3:
f.write(
'"{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}"\n'.format(elem[0], elem[1], elem[2], elem[3],
elem[4], elem[5], elem[6], elem[7],
elem[8], elem[9], elem[10]))
else:
f.write('"{}","{}","{}, {}","{}","{}","{}","{}","{}","{}","{}"\n'.format(elem[0], elem[1], elem[2], elem[3],
elem[4], elem[5], elem[6], elem[7],
elem[8], elem[9], elem[10]))
else:
with open('{}.txt'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID\tItem\tBase Rarity\tRarity\tRealm\tA.Atk\tA.Def\tA.Mag\tA.Res\tA.Mnd\tInherit Effect\n')
for elem in elems:
if ignore_three_star_and_lower_relics == 1:
if elem[3] > 3:
f.write(
'{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n'.format(elem[0], elem[1], elem[2], elem[3],
elem[4], elem[5], elem[6], elem[7],
elem[8], elem[9], elem[10]))
else:
f.write('{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n'.format(elem[0], elem[1], elem[2], elem[3],
elem[4], elem[5], elem[6], elem[7],
elem[8], elem[9], elem[10]))
def getRMs(data, filename):
elems = []
for elem in data:
rm_id = elem['record_materia_id']
name = elem['name']
elems.append([rm_id, name])
elems = sorted(elems, key=lambda x: (x[0], x[1]))
if depricated_comma_seperated_export:
with open('{}.csv'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID, RM\n')
for elem in elems:
f.write('"{}","{}"\n'.format(elem[0], elem[1]))
else:
with open('{}.txt'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID\tRM\n')
for elem in elems:
f.write('{}\t{}\n'.format(elem[0], elem[1]))
def getAbilities(data, filename):
elems = []
for elem in data:
abil_id = elem['ability_id']
name = elem['name']
category_id = elem['category_id']
category_name = elem['category_name']
rarity = elem['rarity']
rank = elem['grade']
if abil_id != 30131091:
elems.append([abil_id, name, category_name, rarity, rank, category_id])
elems = sorted(elems, key=lambda x: (x[0], -x[3], x[5], x[1]))
if depricated_comma_seperated_export:
with open('{}.csv'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID, Ability, Category_Name, Rarity, Rank, Category_ID\n')
for elem in elems:
f.write('"{}","{}","{}","{}","{}","{}"\n'.format(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5]))
else:
with open('{}.txt'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID\tAbility\tCategory_Name\tRarity\tRank\tCategory_ID\n')
for elem in elems:
f.write('{}\t{}\t{}\t{}\t{}\t{}\n'.format(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5]))
def getOrbs(data, filename):
elems = []
for elem in data:
orb_id = elem['id']
name = elem['name']
rarity = elem['rarity']
amount = elem['num']
if (
orb_id <= 40000078 and orb_id != 40000069 and orb_id != 40000020 and orb_id != 40000019 and orb_id != 40000018 and orb_id != 40000017 and orb_id != 40000016):
elems.append([orb_id, name, rarity, amount])
elems = sorted(elems, key=lambda x: (-x[2]))
if depricated_comma_seperated_export:
with open('{}.csv'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID, Orb, Rarity, Amount\n')
for elem in elems:
f.write('"{}","{}","{}","{}"\n'.format(elem[0], elem[1], elem[2], elem[3]))
else:
with open('{}.txt'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID\tOrb\tRarity\tAmount\n')
for elem in elems:
f.write('{}\t{}\t{}\t{}\n'.format(elem[0], elem[1], elem[2], elem[3]))
def getSBs(data, filename, n):
teir = {0: '???', 1: 'Default', 2: 'Shared', 3: 'Unique', 4: 'Super', 5: 'Burst', 6: 'Overstrike', 7: 'Ultra',
8: 'Chain', 9: 'Arcane Overstrike', 10: 'Glint', 11: 'Awakening', 12: 'Syncro', 13: 'Limit Break Overstrike', 14: 'Limit Break Glint', 15: 'Arcane Dyad', 16: '???', 17: '???', 18: '???', 19: '???', 20: '???', 21: '???', 22: '???'}
elems = []
for elem in data:
sb_id = elem['id']
name = elem['name']
char_id = elem['allowed_buddy_id']
char = elem['allowed_buddy_name'] if 'allowed_buddy_name' in elem.keys() else None
category_id = elem['soul_strike_category_id']
if japan != 1:
category = teir[elem['soul_strike_category_id']]
else:
category = elem['soul_strike_category_name'].title()
if ignore_crappy_core_soul_breaks == 1:
if (category_id >= soul_break_export_level) and (
char_id == 10000200 or char_id >= 10004000 or char_id == 0):
elems.append([sb_id, name, char_id, char, category_id, category])
else:
if (category_id >= soul_break_export_level) and (char_id >= 10000000 or char_id == 0):
elems.append([sb_id, name, char_id, char, category_id, category])
elems = sorted(elems, key=lambda x: (x[0], x[2], x[4]))
if depricated_comma_seperated_export:
if n == 0:
with open('{}.csv'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID, Soul Break, Character ID, Character, Type ID, Type\n')
for elem in elems:
f.write('"{}","{}","{}","{}","{}","{}"\n'.format(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5]))
else:
with open('{}.csv'.format(filename), 'a', encoding="utf-8") as f:
for elem in elems:
f.write('"{}","{}","{}","{}","{}","{}"\n'.format(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5]))
else:
if n == 0:
with open('{}.txt'.format(str(filename)+str(n)), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID\tSoul Break\tCharacter ID\tCharacter\tType ID\tType\n')
for elem in elems:
f.write('{}\t{}\t{}\t{}\t{}\t{}\n'.format(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5]))
else:
with open('{}.txt'.format(str(filename)+str(n)), 'w', encoding="utf-8") as f:
for elem in elems:
f.write('{}\t{}\t{}\t{}\t{}\t{}\n'.format(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5]))
if path.exists('3-FFRK-Soul-Breaks0.txt') and path.exists('3-FFRK-Soul-Breaks1.txt') and path.exists('3-FFRK-Soul-Breaks2.txt'):
sbdata0 = sbdata1 = sbdata2 = ""
with open('3-FFRK-Soul-Breaks0.txt') as fp:
sbdata0 = fp.read()
with open('3-FFRK-Soul-Breaks1.txt') as fp:
sbdata1 = fp.read()
with open('3-FFRK-Soul-Breaks2.txt') as fp:
sbdata2 = fp.read()
print(sbdata0)
print(sbdata1)
print(sbdata2)
sbdata0 += sbdata1
sbdata0 += sbdata2
with open ('3-FFRK-Soul-Breaks.txt', 'w') as fp:
fp.write(sbdata0)
remove('3-FFRK-Soul-Breaks0.txt')
remove('3-FFRK-Soul-Breaks1.txt')
remove('3-FFRK-Soul-Breaks2.txt')
def getMagicite(data, filename):
elems = []
for elem in data:
magicite_id = elem['beast_id']
name = elem['name']
rarity = elem['rarity']
level = elem['level']
max_level = elem['max_level']
elementid = elem['elements'][0]['id']
element = elem['elements'][0]['name']
if level == 99 and only_export_level_99_magicite != 0:
elems.append([magicite_id, name, rarity, level, max_level, elementid, element])
elif only_export_level_99_magicite == 0:
elems.append([magicite_id, name, rarity, level, max_level, elementid, element])
elems = sorted(elems, key=lambda x: (x[0], x[1], x[5]))
if depricated_comma_seperated_export:
with open('{}.csv'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID, Name, Rarity, Level, Max Level, Element_id, Element')
for elem in elems:
f.write('\n"{}","{}","{}","{}","{}","{}","{}"'.format(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5],
elem[6]))
if path.exists('5-FFRK-Magicite2.csv') and path.exists('5-FFRK-Magicite1.csv'):
data = data2 = ""
with open('5-FFRK-Magicite1.csv') as fp:
data = fp.read()
with open('5-FFRK-Magicite2.csv') as fp:
data2 = fp.read()
data += "\n"
data += data2
with open ('5-FFRK-Magicite.csv', 'w') as fp:
fp.write(data)
remove('5-FFRK-Magicite1.csv')
remove('5-FFRK-Magicite2.csv')
else:
with open('{}.txt'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID\tName\tRarity\tLevel\tMax Level\tElement_id\tElement')
for elem in elems:
f.write('\n{}\t{}\t{}\t{}\t{}\t{}\t{}'.format(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5],
elem[6]))
if path.exists('5-FFRK-Magicite2.txt') and path.exists('5-FFRK-Magicite1.txt'):
data = data2 = ""
with open('5-FFRK-Magicite1.txt') as fp:
data = fp.read()
with open('5-FFRK-Magicite2.txt') as fp:
data2 = fp.read()
data += '\n'
data += data2
with open ('5-FFRK-Magicite.txt', 'w') as fp:
fp.write(data)
remove('5-FFRK-Magicite1.txt')
remove('5-FFRK-Magicite2.txt')
def getMagicite2(data, filename):
elems = []
for elem in data:
magicite_id = elem['beast_id']
name = elem['name']
rarity = elem['rarity']
level = elem['level']
max_level = elem['max_level']
elementid = elem['elements'][0]['id']
element = elem['elements'][0]['name']
if level == 99 and only_export_level_99_magicite != 0:
elems.append([magicite_id, name, rarity, level, max_level, elementid, element])
elif only_export_level_99_magicite == 0:
elems.append([magicite_id, name, rarity, level, max_level, elementid, element])
elems = sorted(elems, key=lambda x: (x[0], x[1], x[5]))
if depricated_comma_seperated_export:
with open('{}.csv'.format(filename), 'w', encoding="utf-8") as f:
for elem in elems:
f.write('"{}","{}","{}","{}","{}","{}","{}"\n'.format(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5],
elem[6]))
if path.exists('5-FFRK-Magicite2.csv') and path.exists('5-FFRK-Magicite1.csv'):
data = data2 = ""
with open('5-FFRK-Magicite1.csv') as fp:
data = fp.read()
with open('5-FFRK-Magicite2.csv') as fp:
data2 = fp.read()
data += "\n"
data += data2
with open ('5-FFRK-Magicite.csv', 'w') as fp:
fp.write(data)
remove('5-FFRK-Magicite1.csv')
remove('5-FFRK-Magicite2.csv')
else:
with open('{}.txt'.format(filename), 'w', encoding="utf-8") as f:
for elem in elems:
f.write('{}\t{}\t{}\t{}\t{}\t{}\t{}\n'.format(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5],
elem[6]))
if path.exists('5-FFRK-Magicite2.txt') and path.exists('5-FFRK-Magicite1.txt'):
data = data2 = ""
with open('5-FFRK-Magicite1.txt') as fp:
data = fp.read()
with open('5-FFRK-Magicite2.txt') as fp:
data2 = fp.read()
data += "\n"
data += data2
with open ('5-FFRK-Magicite.txt', 'w') as fp:
fp.write(data)
remove('5-FFRK-Magicite1.txt')
remove('5-FFRK-Magicite2.txt')
def getVaultMagicite(data, filename):
elems = []
for elem in data:
magicite_id = elem['beast_id']
name = elem['name']
rarity = elem['rarity']
level = elem['level']
elems.append([magicite_id, name, rarity, level])
elems = sorted(elems, key=lambda x: (-x[3], x[0], x[1]))
if depricated_comma_seperated_export:
with open('{}.csv'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID, Name, Rarity, Level\n')
for elem in elems:
f.write('"{}","{}","{}","{}"\n'.format(elem[0], elem[1], elem[2], elem[3]))
else:
with open('{}.txt'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID\tName\tRarity\tLevel\n')
for elem in elems:
f.write('{}\t{}\t{}\t{}\n'.format(elem[0], elem[1], elem[2], elem[3]))
def getCharacters(data, filename):
elems = []
for elem in data:
buddy_id = elem['buddy_id']
realm_id = int(str(elem['series_id'])[1:3]) if elem['series_id'] < 200000 else 99
if realm_id == 99:
realm = 'CORE'
elif realm_id == 50:
realm = 'FFT'
elif realm_id == 60:
realm = 'Type-0'
elif realm_id == 70:
realm = 'KH'
elif realm_id == 90:
realm = 'Beyond'
else:
realm = str(realm_id)
name = elem['name']
job = elem['job_name']
level = elem['level']
max_level = elem['level_max']
s_levels = elem['sphere_skill_level']
hp = elem['hp']
accuracy = elem['acc']
attack = elem['atk']
defense = elem['def']
magic = elem['matk']
resistance = elem['mdef']
mind = elem['mnd']
speed = elem['spd']
evasion = elem['eva']
elems.append(
[buddy_id, realm, name, job, level, max_level, s_levels, hp, accuracy, attack, defense, magic, resistance,
mind,
speed, evasion])
elems = sorted(elems, key=lambda x: (x[0], x[2], x[1]))
if depricated_comma_seperated_export:
with open('{}.csv'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write(
'#ID, Series, Name, Job, Level, Max Level, Sphere Levels, HP, Accuracy, Attack, Defense, Magic, Resistance, Mind, Speed, Evasion\n')
for elem in elems:
f.write('"{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}"\n'.format(
elem[0], elem[1], elem[2], elem[3], elem[4], elem[5], elem[6], elem[7], elem[8], elem[9], elem[10],
elem[11], elem[12], elem[13], elem[14], elem[15]))
else:
with open('{}.txt'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write(
'#ID\tSeries\tName\tJob\tLevel\tMax Level\tSphere Levels\tHP\tAccuracy\tAttack\tDefense\tMagic\tResistance\tMind\tSpeed\tEvasion\n')
for elem in elems:
f.write('{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n'.format(
elem[0], elem[1], elem[2], elem[3], elem[4], elem[5], elem[6], elem[7], elem[8], elem[9], elem[10],
elem[11], elem[12], elem[13], elem[14], elem[15]))
def getLMs(data, filename, n):
elems = []
for elem in data:
lm_id = elem['id']
charname = elem['buddy_name']
name = elem['name']
description = '"{}"'.format(elem['description'])
elems.append([lm_id, charname, name, description])
elems = sorted(elems, key=lambda x: (x[0], x[1], x[2]))
if depricated_comma_seperated_export:
if n == 0:
with open('{}.csv'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID, Character, LM Name, Effect\n')
for elem in elems:
f.write('"{}","{}","{}","{}"\n'.format(elem[0], elem[1], elem[2], elem[3]))
else:
with open('{}.csv'.format(filename), 'a', encoding="utf-8") as f:
for elem in elems:
f.write('"{}","{}","{}","{}"\n'.format(elem[0], elem[1], elem[2], elem[3]))
else:
if n == 0:
with open('{}.txt'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID\tCharacter\tLM Name\tEffect\n')
for elem in elems:
f.write('{}\t{}\t{}\t{}\n'.format(elem[0], elem[1], elem[2], elem[3]))
else:
with open('{}.txt'.format(filename), 'a', encoding="utf-8") as f:
for elem in elems:
f.write('{}\t{}\t{}\t{}\n'.format(elem[0], elem[1], elem[2], elem[3]))
def getEquipHistory(data, filename):
elems = []
for elem in data:
history_id = elem['id']
name = elem['name']
rarity = elem['rarity']
created_at = elem['created_at']
date_aqu = datetime.utcfromtimestamp(float(created_at)).strftime('%Y-%m-%d %H:%M UTC')
elems.append([history_id, name, rarity, created_at, date_aqu])
elems = sorted(elems, key=lambda x: (x[0], x[3], x[2]))
if depricated_comma_seperated_export:
with open('{}.csv'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID, Name, Rarity, Acquired\n')
for elem in elems:
f.write('"{}","{}","{}","{}"\n'.format(elem[0], elem[1], elem[2], elem[4]))
else:
with open('{}.txt'.format(filename), 'w', encoding="utf-8") as f:
f.write('\ufeff')
f.write('#ID\tName\tRarity\tAcquired\n')
for elem in elems:
f.write('{}\t{}\t{}\t{}\n'.format(elem[0], elem[1], elem[2], elem[4]))
def exportRawJson(data, filename, part):
with open(part+('{}.json'.format(filename)), 'w', encoding="utf-8") as json_file:
dump(data, json_file)