-
Notifications
You must be signed in to change notification settings - Fork 0
/
gbfpib.pyw
1931 lines (1810 loc) · 116 KB
/
gbfpib.pyw
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
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import asyncio
from contextlib import asynccontextmanager
from typing import Generator, Optional, Union
import time
import os
import sys
import shutil
import traceback
import re
from urllib.parse import quote
from base64 import b64decode, b64encode
import json
from io import BytesIO
import importlib.util
from tkinter import messagebox, filedialog, simpledialog
import tkinter as Tk
import tkinter.ttk as ttk
import subprocess
from zipfile import ZipFile
class PartyBuilder():
NULL_CHARACTER = [3030182000, 3020072000] # null character id list (lyria, cat...), need to be hardcoded
COLORS = { # color for estimated advantage
1:(243, 48, 33),
2:(85, 176, 250),
3:(227, 124, 32),
4:(55, 232, 16),
5:(253, 216, 67),
6:(176, 84, 251)
}
COLORS_EN = { # color string
1:"Fire",
2:"Water",
3:"Earth",
4:"Wind",
5:"Light",
6:"Dark"
}
COLORS_JP = { # color string
1:"火",
2:"水",
3:"土",
4:"風",
5:"光",
6:"闇"
}
AUXILIARY_CLS = [100401, 300301, 300201, 120401, 140401] # aux classes
DARK_OPUS_IDS = [
"1040310600","1040310700","1040415000","1040415100","1040809400","1040809500","1040212500","1040212600","1040017000","1040017100","1040911000","1040911100",
"1040310600_02","1040310700_02","1040415000_02","1040415100_02","1040809400_02","1040809500_02","1040212500_02","1040212600_02","1040017000_02","1040017100_02","1040911000_02","1040911100_02",
"1040310600_03","1040310700_03","1040415000_03","1040415100_03","1040809400_03","1040809500_03","1040212500_03","1040212600_03","1040017000_03","1040017100_03","1040911000_03","1040911100_03"
]
ULTIMA_OPUS_IDS = [
"1040011900","1040012000","1040012100","1040012200","1040012300","1040012400",
"1040109700","1040109800","1040109900","1040110000","1040110100","1040110200",
"1040208800","1040208900","1040209000","1040209100","1040209200","1040209300",
"1040307800","1040307900","1040308000","1040308100","1040308200","1040308300",
"1040410800","1040410900","1040411000","1040411100","1040411200","1040411300",
"1040507400","1040507500","1040507600","1040507700","1040507800","1040507900",
"1040608100","1040608200","1040608300","1040608400","1040608500","1040608600",
"1040706900","1040707000","1040707100","1040707200","1040707300","1040707400",
"1040807000","1040807100","1040807200","1040807300","1040807400","1040807500",
"1040907500","1040907600","1040907700","1040907800","1040907900","1040908000"
]
ORIGIN_DRACONIC_IDS = [
"1040815900","1040316500","1040712800","1040422200","1040915600","1040516500"
]
USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Rosetta/Dev'
def __init__(self, debug : bool = False) -> None:
self.debug = debug
if self.debug: print("DEBUG enabled")
self.japanese = False # True if the data is japanese, False if not
self.classes = None
self.class_modified = False
self.prev_lang = None # Language used in the previous run
self.babyl = False # True if the data contains more than 5 allies
self.sandbox = False # True if the data contains more than 10 weapons
self.cache = {} # memory cache
self.emp_cache = {} # emp cache
self.sumcache = {} # wiki summon cache
self.fonts = {'mini':None, 'small':None, 'medium':None, 'big':None} # font to use during the processing
self.quality = 1 # quality ratio in use currently
self.definition = None # image size
self.running = False # True if the image building is in progress
self.settings = {} # settings.json data
self.manifest = {} # manifest.json data
self.startup_check()
self.load() # loading settings.json
self.dummy_layer = self.make_canvas()
self.gbftmr = None
if self.importGBFTMR(self.settings.get('gbftmr_path', '')):
print("GBFTMR imported with success")
self.wtm = b64decode("TWl6YSdzIEdCRlBJQiA=").decode('utf-8')+self.manifest.get('version', '')
self.client = None
if self.manifest.get('pending', False):
self.manifest['pending'] = False
self.saveManifest()
@asynccontextmanager
async def init_client(self) -> Generator['aiohttp.ClientSession', None, None]:
try:
self.client = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=20))
yield self.client
finally:
await self.client.close()
def pexc(self, e : Exception) -> str:
return "".join(traceback.format_exception(type(e), e, e.__traceback__))
def loadManifest(self) -> None: # load manifest.json
try:
with open("manifest.json") as f:
self.manifest = json.load(f)
except:
pass
def saveManifest(self) -> None: # save manifest.json
try:
with open("manifest.json", 'w') as outfile:
json.dump(self.manifest, outfile)
except:
pass
def loadClasses(self) -> None:
try:
self.class_modified = False
with open("classes.json", mode="r", encoding="utf-8") as f:
self.classes = json.load(f)
except:
self.classes = {}
def saveClasses(self) -> None:
try:
if self.class_modified:
with open("classes.json", mode='w', encoding='utf-8') as outfile:
json.dump(self.classes, outfile)
except:
pass
def importRequirements(self) -> None:
global aiohttp
import aiohttp
global Image
global ImageFont
global ImageDraw
from PIL import Image, ImageFont, ImageDraw
global pyperclip
import pyperclip
def startup_check(self) -> None:
self.loadManifest()
if self.manifest.get('pending', False):
if messagebox.askyesno(title="Info", message="I will now attempt to update required dependencies.\nDo you accept?\nElse it will be ignored if the application can start."):
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
self.importRequirements()
messagebox.showinfo("Info", "Installation successful.")
except Exception as e:
print(self.pexc(e))
if sys.platform == "win32":
import ctypes
try: is_admin = ctypes.windll.shell32.IsUserAnAdmin()
except: is_admin = False
if not is_admin:
if messagebox.askyesno(title="Error", message="An error occured: {}\nDo you want to restart the application with administrator permissions?".format(e)):
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1) # restart as admin
else:
messagebox.showerror("Error", "An error occured: {}\nFurther troubleshooting is needed.\nYou might need to install the dependancies manually, check the README for details.")
else:
messagebox.showerror("Error", "An error occured: {}\nFurther troubleshooting is needed.\nYou might need to install the dependancies manually, check the README for details.")
exit(0)
else:
try:
self.importRequirements()
except Exception as e:
print(self.pexc(e))
if messagebox.askyesno(title="Error", message="An error occured while importing the dependencies: {}\nThey might be outdated or missing.\nRestart and attempt to install them now?".format(e)):
self.manifest['pending'] = True
self.saveManifest()
self.restart()
exit(0)
print("Granblue Fantasy Party Image Builder", self.manifest.get('version', ''))
def load(self) -> None: # load settings.json
try:
with open('settings.json') as f:
self.settings = json.load(f)
except:
print("Failed to load settings.json")
while True:
print("An empty settings.json file will be created, continue? (y/n)")
i = input()
if i.lower() == 'n': exit(0)
elif i.lower() == 'y': break
self.save()
def save(self) -> None: # save settings.json
try:
with open('settings.json', 'w') as outfile:
json.dump(self.settings, outfile)
except:
pass
async def retrieveImage(self, path : str, remote : bool = True, forceDownload : bool = False) -> bytes:
if self.japanese: path = path.replace('assets_en', 'assets')
if forceDownload or path not in self.cache:
try: # get from disk cache if enabled
if forceDownload: raise Exception()
if self.settings.get('caching', False):
with open("cache/" + b64encode(path.encode('utf-8')).decode('utf-8'), "rb") as f:
self.cache[path] = f.read()
await asyncio.sleep(0)
else:
raise Exception()
except: # else request it from gbf
if remote:
print("[GET] *Downloading File", path)
response = await self.client.get('https://' + self.settings.get('endpoint', 'prd-game-a-granbluefantasy.akamaized.net/') + path, headers={'connection':'keep-alive'})
async with response:
if response.status != 200: raise Exception("HTTP Error code {} for url: {}".format(response.status, 'https://' + self.settings.get('endpoint', 'prd-game-a-granbluefantasy.akamaized.net/') + path))
self.cache[path] = await response.read()
if self.settings.get('caching', False):
try:
with open("cache/" + b64encode(path.encode('utf-8')).decode('utf-8'), "wb") as f:
f.write(self.cache[path])
await asyncio.sleep(0)
except Exception as e:
print(e)
pass
else:
with open(path, "rb") as f:
self.cache[path] = f.read()
await asyncio.sleep(0)
return self.cache[path]
async def pasteImage(self, imgs : list, file : Union[str, BytesIO], offset : tuple, resize : Optional[tuple] = None, transparency : bool = False, start : int = 0, end : int = 99999999, crop : Optional[tuple] = None) -> list: # paste an image onto another
if isinstance(file, str):
if self.japanese: file = file.replace('_EN', '')
file = BytesIO(await self.retrieveImage(file, remote=False))
buffers = [Image.open(file)]
if crop is not None:
if len(crop) == 4:
buffers.append(buffers[-1].crop(crop))
else:
buffers.append(buffers[-1].crop((0, 0, crop[0], crop[1])))
buffers.append(buffers[-1].convert('RGBA'))
if resize is not None: buffers.append(buffers[-1].resize(resize, Image.Resampling.LANCZOS))
if not transparency:
for i in range(start, min(len(imgs), end)):
imgs[i].paste(buffers[-1], offset, buffers[-1])
else:
layer = self.dummy_layer.copy()
layer.paste(buffers[-1], offset, buffers[-1])
for i in range(start, min(len(imgs), end)):
tmp = Image.alpha_composite(imgs[i], layer)
imgs[i].close()
imgs[i] = tmp
layer.close()
await asyncio.sleep(0)
for buf in buffers: buf.close()
del buffers
file.close()
return imgs
async def dlAndPasteImage(self, imgs : list, path : str, offset : tuple, resize : Optional[tuple] = None, transparency : bool = False, start : int = 0, end : int = 99999999, crop : Optional[tuple] = None) -> list: # dl an image and call pasteImage()
with BytesIO(await self.retrieveImage(path)) as file_jpgdata:
return await self.pasteImage(imgs, file_jpgdata, offset, resize, transparency, start, end, crop)
def add(self, A:tuple, B:tuple):
return (A[0]+B[0], A[1]+B[1])
def fixCase(self, terms : str) -> str: # function to fix the case (for wiki search requests)
terms = terms.split(' ')
fixeds = []
for term in terms:
fixed = ""
up = False
special = {"and":"and", "of":"of", "de":"de", "for":"for", "the":"the", "(sr)":"(SR)", "(ssr)":"(SSR)", "(r)":"(R)"} # case where we don't don't fix anything and return it
if term.lower() in special:
return special[term.lower()]
for i in range(0, len(term)): # for each character
if term[i].isalpha(): # if letter
if term[i].isupper(): # is uppercase
if not up: # we haven't encountered an uppercase letter
up = True
fixed += term[i] # save
else: # we have
fixed += term[i].lower() # make it lowercase and save
elif term[i].islower(): # is lowercase
if not up: # we haven't encountered an uppercase letter
fixed += term[i].upper() # make it uppercase and save
up = True
else: # we have
fixed += term[i] # save
else: # other characters
fixed += term[i] # we just save
elif term[i] == "/" or term[i] == ":" or term[i] == "#" or term[i] == "-": # we reset the uppercase detection if we encounter those
up = False
fixed += term[i]
else: # everything else,
fixed += term[i] # we save
fixeds.append(fixed)
return "_".join(fixeds) # return the result
async def get_support_summon_from_wiki(self, name : str) -> Optional[str]: # search on gbf.wiki to match a summon name to its id
try:
name = name.lower()
if name in self.sumcache: return self.sumcache[name]
response = await self.client.get("https://gbf.wiki/index.php?title=Special:CargoExport&tables=summons&fields=id,name&format=json&limit=20000", headers={'connection':'close', 'User-Agent':self.USER_AGENT})
async with response:
if response.status != 200: raise Exception()
data = await response.json()
for summon in data:
if summon["name"].lower() == name:
self.sumcache[name] = summon["id"]
return summon["id"]
return None
except:
return None
def get_uncap_id(self, cs : int) -> str: # to get character portraits based on uncap levels
return {2:'02', 3:'02', 4:'02', 5:'03', 6:'04'}.get(cs, '01')
def get_uncap_star(self, cs : int, cl : int) -> str: # to get character star based on uncap levels
match cs:
case 4: return "assets/star_1.png"
case 5: return "assets/star_2.png"
case 6:
if cl <= 110: return "assets/star_4_1.png"
elif cl <= 120: return "assets/star_4_2.png"
elif cl <= 130: return "assets/star_4_3.png"
elif cl <= 140: return "assets/star_4_4.png"
elif cl <= 150: return "assets/star_4_5.png"
case _: return "assets/star_0.png"
def get_summon_star(self, se : int, sl : int) -> str: # to get summon star based on uncap levels
match se:
case 3: return "assets/star_1.png"
case 4: return "assets/star_2.png"
case 5: return "assets/star_3.png"
case 6:
if sl <= 210: return "assets/star_4_1.png"
elif sl <= 220: return "assets/star_4_2.png"
elif sl <= 230: return "assets/star_4_3.png"
elif sl <= 240: return "assets/star_4_4.png"
elif sl <= 250: return "assets/star_4_5.png"
case _: return "assets/star_0.png"
def fix_character_look(self, export : dict, i : int) -> str:
style = ("" if str(export['cst'][i]) == '1' else "_st{}".format(export['cst'][i])) # style
if style != "":
uncap = "01"
else:
uncap = self.get_uncap_id(export['cs'][i])
cid = export['c'][i]
# SKIN FIX START ##################
if str(cid).startswith('371'):
match cid:
case 3710098000: # seox skin
if export['cl'][i] > 80: cid = 3040035000 # eternal seox
else: cid = 3040262000 # event seox
case 3710122000: # seofon skin
cid = 3040036000 # eternal seofon
case 3710143000: # vikala skin
if export['ce'][i] == 3: cid = 3040408000 # apply earth vikala
elif export['ce'][i] == 6:
if export['cl'][i] > 50: cid = 3040252000 # SSR dark vikala
else: cid = 3020073000 # R dark vikala
case 3710154000: # clarisse skin
match export['ce'][i]:
case 2: cid = 3040413000 # water
case 3: cid = 3040067000 # earth
case 5: cid = 3040121000 # light
case 6: cid = 3040206000 # dark
case _: cid = 3040046000 # fire
case 3710165000: # diantha skin
match export['ce'][i]:
case 2:
if export['cl'][i] > 70: cid = 3040129000 # water SSR
else: cid = 3030150000 # water SR
case 3: cid = 3040296000 # earth
case 3710172000: # tsubasa skin
cid = 3040180000
case 3710176000: # mimlemel skin
if export['ce'][i] == 1: cid = 3040292000 # apply fire mimlemel
elif export['ce'][i] == 3: cid = 3030220000 # apply earth halloween mimlemel
elif export['ce'][i] == 4:
if export['cn'][i] in ['Mimlemel', 'ミムルメモル']: cid = 3030043000 # first sr wind mimlemel
else: cid = 3030166000 # second sr wind mimlemel
case 3710191000: # cidala skin 1
if export['ce'][i] == 3: cid = 3040377000 # apply earth cidala
case 3710195000: # cidala skin 2
if export['ce'][i] == 3: cid = 3040377000 # apply earth cidala
# SKIN FIX END ##################
if cid in self.NULL_CHARACTER:
if export['ce'][i] == 99:
return "{}_{}{}_0{}".format(cid, uncap, style, export['pce'])
else:
return "{}_{}{}_0{}".format(cid, uncap, style, export['ce'][i])
else:
return "{}_{}{}".format(cid, uncap, style)
async def get_mc_job_look(self, skin : str, job : int) -> str: # get the MC unskined filename based on id
sjob = str((job//100) * 100 + 1)
if sjob in self.classes:
return "{}_{}_{}".format(sjob, self.classes[sjob], '_'.join(skin.split('_')[2:]))
else:
tasks = []
for mh in ["sw", "kn", "sp", "ax", "wa", "gu", "me", "bw", "mc", "kr"]:
tasks.append(self.get_mc_job_look_sub(sjob, mh))
for r in await asyncio.gather(*tasks):
if r is not None:
self.class_modified = True
self.classes[sjob] = r
return "{}_{}_{}".format(sjob, self.classes[sjob], '_'.join(skin.split('_')[2:]))
return ""
async def get_mc_job_look_sub(self, job : str, mh : str) -> Optional[str]:
response = await self.client.head("https://prd-game-a5-granbluefantasy.akamaized.net/assets_en/img/sp/assets/leader/s/{}_{}_0_01.jpg".format(job, mh))
async with response:
if response.status != 200:
return None
return mh
def process_special_weapon(self, export : dict, i : int, j : int) -> bool:
if export['wsn'][i][j] is not None and export['wsn'][i][j] == "skill_job_weapon":
if j == 2: # skill 3, ultima, opus
if export['w'][i] in self.DARK_OPUS_IDS:
bar_gain = 0
hp_cut = 0
turn_dmg = 0
prog = 0
ca_dmg = 0
ca_dmg_cap = 0
auto_amp_sp = 0
skill_amp_sp = 0
ca_amp_sp = 0
for m in export['mods']:
try:
match m['icon_img']:
case '04_icon_ca_gage.png':
bar_gain = float(m['value'].replace('%', ''))
case '03_icon_hp_cut.png':
hp_cut = float(m['value'].replace('%', ''))
case '03_icon_turn_dmg.png':
turn_dmg = float(m['value'].replace('%', ''))
case '01_icon_e_atk_01.png':
prog = float(m['value'].replace('%', ''))
case '04_icon_ca_dmg.png':
ca_dmg = float(m['value'].replace('%', ''))
case '04_icon_ca_dmg_cap.png':
ca_dmg_cap = float(m['value'].replace('%', ''))
case '04_icon_normal_dmg_amp_other.png':
auto_amp_sp = float(m['value'].replace('%', ''))
case '04_icon_ability_dmg_amplify_other.png':
skill_amp_sp = float(m['value'].replace('%', ''))
case '04_icon_ca_dmg_amplify_other.png':
ca_amp_sp = float(m['value'].replace('%', ''))
except:
pass
if hp_cut >= 30: # temptation
export['wsn'][i][j] = "assets_en/img/sp/assets/item/skillplus/s/14014.jpg"
return True
elif auto_amp_sp >= 10: # extremity
export['wsn'][i][j] = "assets_en/img/sp/assets/item/skillplus/s/14005.jpg"
return True
elif skill_amp_sp >= 10: # sagacity
export['wsn'][i][j] = "assets_en/img/sp/assets/item/skillplus/s/14006.jpg"
return True
elif ca_amp_sp >= 10: # supremacy
export['wsn'][i][j] = "assets_en/img/sp/assets/item/skillplus/s/14007.jpg"
return True
elif bar_gain <= -50 and bar_gain > -200: # falsehood
export['wsn'][i][j] = "assets_en/img/sp/assets/item/skillplus/s/14017.jpg"
return True
elif prog > 0: # progression
export['wsn'][i][j] = "assets_en/img/sp/assets/item/skillplus/s/14004.jpg"
return True
elif ca_dmg >= 100 and ca_dmg_cap >= 30: # forbiddance
export['wsn'][i][j] = "assets_en/img/sp/assets/item/skillplus/s/14015.jpg"
return True
elif turn_dmg >= 5: # depravity
export['wsn'][i][j] = "assets_en/img/sp/assets/item/skillplus/s/14016.jpg"
return True
elif export['w'][i] in self.ULTIMA_OPUS_IDS:
seraphic = 0
heal_cap = 0
bar_gain = 0
cap_up = 0
for m in export['mods']:
try:
match m['icon_img']:
case '04_icon_elem_amplify.png':
seraphic = float(m['value'].replace('%', ''))
case '04_icon_dmg_cap.png':
cap_up = float(m['value'].replace('%', ''))
case '04_icon_ca_gage.png':
bar_gain = float(m['value'].replace('%', ''))
case '03_icon_heal_cap.png':
heal_cap = float(m['value'].replace('%', ''))
except:
pass
if seraphic >= 25: # tria
export['wsn'][i][2] = "assets_en/img/sp/assets/item/skillplus/s/17003.jpg"
return True
elif heal_cap >= 50 and bar_gain >= 10: # dio / tessera better guess (EXPERIMENTAL)
count = 0
for a in export['wsn']:
for b in a:
if b is None: continue
elif "heal_limit_m" in b: count += 1
elif "heal_limit" in b: count += 1
if count >= 3: export['wsn'][i][2] = "assets_en/img/sp/assets/item/skillplus/s/17004.jpg"
elif count == 2: return False # unsure
else: export['wsn'][i][2] = "assets_en/img/sp/assets/item/skillplus/s/17002.jpg"
return True
elif heal_cap >= 50: # dio
export['wsn'][i][2] = "assets_en/img/sp/assets/item/skillplus/s/17002.jpg"
return True
elif bar_gain >= 10: # tessera
export['wsn'][i][2] = "assets_en/img/sp/assets/item/skillplus/s/17004.jpg"
return True
elif cap_up >= 10: # ena
export['wsn'][i][2] = "assets_en/img/sp/assets/item/skillplus/s/17001.jpg"
return True
elif j == 1: # skill 2, hexa draconic
if export['w'][i] in self.ORIGIN_DRACONIC_IDS:
seraphic = 0
for m in export['mods']:
try:
match m['icon_img']:
case '04_icon_plain_amplify.png':
seraphic = float(m['value'].replace('%', ''))
except:
pass
if seraphic >= 10: # oblivion teluma
export['wsn'][i][j] = "assets_en/img/sp/assets/item/skillplus/s/15009.jpg"
return True
return False
def make_canvas(self, size : tuple = (1800, 2160)) -> 'Image':
i = Image.new('RGB', size, "black")
im_a = Image.new("L", size, "black")
i.putalpha(im_a)
im_a.close()
return i
async def make_party(self, export : dict) -> Union[str, tuple]:
try:
imgs = [self.make_canvas(), self.make_canvas()]
print("[CHA] * Drawing Party...")
if self.babyl:
offset = (15, 10)
nchara = 12
csize = (180, 180)
skill_width = 420
pos = self.add(offset, (30, 0))
jsize = (54, 45)
roffset = (-6, -6)
rsize = (60, 60)
ssize = (50, 50)
soffset = self.add(csize, (-csize[0], -ssize[1]*5//3))
poffset = self.add(csize, (-105, -45))
ssoffset = self.add(pos, (0, 10+csize[1]))
stoffset = self.add(ssoffset, (3, 3))
plsoffset = self.add(ssoffset, (447, 0))
# background
await self.pasteImage(imgs, "assets/bg.png", self.add(pos, (-15, -15)), (csize[0]*8+40, csize[1]*2+55), transparency=True, start=0, end=1)
else:
offset = (15, 10)
nchara = 5
csize = (250, 250)
skill_width = 420
pos = self.add(offset, (skill_width-csize[0], 0))
jsize = (72, 60)
roffset = (-10, -10)
rsize = (90, 90)
ssize = (66, 66)
soffset = self.add(csize, (-csize[0]+ssize[0]//2, -ssize[1]))
poffset = self.add(csize, (-110, -40))
noffset = (9, csize[1]+10)
loffset = (10, csize[1]+6+60)
ssoffset = self.add(offset, (0, csize[1]))
stoffset = self.add(ssoffset, (3, 3))
plsoffset = self.add(ssoffset, (0, -150))
# background
await self.pasteImage(imgs, "assets/bg.png", self.add(pos, (-15, -10)), (25+csize[0]*6+30, csize[1]+175), transparency=True, start=0, end=1)
# mc
print("[CHA] |--> MC Skin:", export['pcjs'])
print("[CHA] |--> MC Job:", export['p'])
print("[CHA] |--> MC Master Level:", export['cml'])
print("[CHA] |--> MC Proof Level:", export['cbl'])
# class
class_id = await self.get_mc_job_look(export['pcjs'], export['p'])
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/leader/s/{}.jpg".format(class_id), pos, csize, start=0, end=1)
# job icon
await self.dlAndPasteImage(imgs, "assets_en/img/sp/ui/icon/job/{}.png".format(export['p']), pos, jsize, transparency=True, start=0, end=1)
if export['cbl'] == '6':
await self.dlAndPasteImage(imgs, "assets_en/img/sp/ui/icon/job/ico_perfection.png", self.add(pos, (0, jsize[1])), jsize, transparency=True, start=0, end=1)
# skin
if class_id != export['pcjs']:
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/leader/s/{}.jpg".format(export['pcjs']), pos, csize, start=1, end=2)
await self.dlAndPasteImage(imgs, "assets_en/img/sp/ui/icon/job/{}.png".format(export['p']), pos, jsize, transparency=True, start=1, end=2)
# allies
for i in range(0, nchara):
await asyncio.sleep(0)
if self.babyl:
if i < 4: pos = self.add(offset, (csize[0]*i+30, 0))
elif i < 8: pos = self.add(offset, (csize[0]*i+40, 0))
else: pos = self.add(offset, (csize[0]*(i-4)+40, 10+csize[1]*(i//8)))
if i == 0: continue # quirk of babyl party, mc is counted
else:
pos = self.add(offset, (skill_width+csize[0]*(i+1-1), 0))
if i >= 3: pos = self.add(pos, (25, 0))
# portrait
if i >= len(export['c']) or export['c'][i] is None: # empty
await self.dlAndPasteImage(imgs, "assets_en/img/sp/tower/assets/npc/s/3999999999.jpg", pos, csize, start=0, end=1)
continue
print("[CHA] |--> Ally #{}:".format(i+1), export['c'][i], export['cn'][i], "Lv {}".format(export['cl'][i]), "Uncap-{}".format(export['cs'][i]), "+{}".format(export['cp'][i]), "Has Ring" if export['cwr'][i] else "No Ring")
# portrait
cid = self.fix_character_look(export, i)
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/npc/s/{}.jpg".format(cid), pos, csize, start=0, end=1)
# skin
if cid != export['ci'][i]:
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/npc/s/{}.jpg".format(export['ci'][i]), pos, csize, start=1, end=2)
has_skin = True
else:
has_skin = False
# star
await self.pasteImage(imgs, self.get_uncap_star(export['cs'][i], export['cl'][i]), self.add(pos, soffset), ssize, transparency=True, start=0, end=2 if has_skin else 1)
# rings
if export['cwr'][i] == True:
await self.dlAndPasteImage(imgs, "assets_en/img/sp/ui/icon/augment2/icon_augment2_l.png", self.add(pos, roffset), rsize, transparency=True, start=0, end=2 if has_skin else 1)
# plus
if export['cp'][i] > 0:
self.text(imgs, self.add(pos, poffset), "+{}".format(export['cp'][i]), fill=(255, 255, 95), font=self.fonts['small'], stroke_width=6, stroke_fill=(0, 0, 0), start=0, end=2 if has_skin else 1)
if not self.babyl:
# name
await self.pasteImage(imgs, "assets/chara_stat.png", self.add(pos, (0, csize[1])), (csize[0], 60), transparency=True, start=0, end=1)
if len(export['cn'][i]) > 11: name = export['cn'][i][:11] + ".."
else: name = export['cn'][i]
self.text(imgs, self.add(pos, noffset), name, fill=(255, 255, 255), font=self.fonts['mini'], start=0, end=1)
# skill count
await self.pasteImage(imgs, "assets/skill_count_EN.png", self.add(pos, (0, csize[1]+60)), (csize[0], 60), transparency=True, start=0, end=1)
self.text(imgs, self.add(self.add(pos, loffset), (150, 0)), str(export['cb'][i+1]), fill=(255, 255, 255), font=self.fonts['medium'], stroke_width=4, stroke_fill=(0, 0, 0), start=0, end=1)
await asyncio.sleep(0)
# mc sub skills
await self.pasteImage(imgs, "assets/subskills.png", ssoffset, (420, 147), transparency=True)
count = 0
for i in range(len(export['ps'])):
if export['ps'][i] is not None:
print("[CHA] |--> MC Skill #{}:".format(i), export['ps'][i])
if len(export['ps'][i]) > 20:
f = 'mini'
voff = 5
elif len(export['ps'][i]) > 15:
f = 'small'
voff = 2
else:
f = 'medium'
voff = 0
self.text(imgs, self.add(stoffset, (0, 48*count+voff)), export['ps'][i], fill=(255, 255, 255), font=self.fonts[f])
count += 1
await asyncio.sleep(0)
# paladin shield/manadiver familiar
if export['cpl'][0] is not None:
print("[CHA] |--> Paladin shields:", export['cpl'][0], "|", export['cpl'][1])
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/shield/s/{}.jpg".format(export['cpl'][0]), plsoffset, (150, 150), start=0, end=1)
if export['cpl'][1] is not None and export['cpl'][1] != export['cpl'][0] and export['cpl'][1] > 0: # skin
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/shield/s/{}.jpg".format(export['cpl'][1]), plsoffset, (150, 150), start=1, end=2)
await self.pasteImage(imgs, "assets/skin.png", self.add(plsoffset, (0, -70)), (153, 171), start=1, end=2)
elif export['fpl'][0] is not None:
print("[CHA] |--> Manadiver Manatura:", export['fpl'][0], "|", export['fpl'][1])
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/familiar/s/{}.jpg".format(export['fpl'][0]), plsoffset, (150, 150), start=0, end=1)
if export['fpl'][1] is not None and export['fpl'][1] != export['fpl'][0] and export['fpl'][1] > 0: # skin
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/familiar/s/{}.jpg".format(export['fpl'][1]), plsoffset, (150, 150), start=1, end=2)
await self.pasteImage(imgs, "assets/skin.png", self.add(plsoffset, (0, -45)), (76, 85), start=1, end=2)
elif self.babyl: # to fill the blank space
await self.pasteImage(imgs, "assets/characters_EN.png", self.add(ssoffset, (skill_width, 0)), (276, 75), transparency=True)
return ('party', imgs)
except Exception as e:
imgs[0].close()
imgs[1].close()
return self.pexc(e)
async def make_summon(self, export : dict) -> Union[str, tuple]:
try:
imgs = [self.make_canvas(), self.make_canvas()]
print("[SUM] * Drawing Summons...")
offset = (170, 425)
sizes = [(271, 472), (266, 200), (273, 155)]
durls = ["assets_en/img/sp/assets/summon/ls/2999999999.jpg","assets_en/img/sp/assets/summon/m/2999999999.jpg", "assets_en/img/sp/assets/summon/m/2999999999.jpg"]
surls = ["assets_en/img/sp/assets/summon/party_main/{}.jpg", "assets_en/img/sp/assets/summon/party_sub/{}.jpg", "assets_en/img/sp/assets/summon/m/{}.jpg"]
# background setup
await self.pasteImage(imgs, "assets/bg.png", self.add(offset, (-15, -15)), (100+sizes[0][0]+sizes[1][0]*2+sizes[0][0]+48, sizes[0][1]+143), transparency=True, start=0, end=1)
for i in range(0, 7):
await asyncio.sleep(0)
if i == 0:
pos = self.add(offset, (0, 0))
idx = 0
elif i < 5:
pos = self.add(offset, (sizes[0][0]+50+((i-1)%2)*sizes[1][0]+18, 266*((i-1)//2)))
idx = 1
else:
pos = self.add(offset, (sizes[0][0]+100+2*sizes[1][0]+18, 102+(i-5)*(sizes[2][1]+60)))
idx = 2
if i == 5: await self.pasteImage(imgs, "assets/subsummon_EN.png", (pos[0]+45, pos[1]-72-30), (180, 72), transparency=True, start=0, end=1)
# portraits
if export['s'][i] is None:
await self.dlAndPasteImage(imgs, durls[idx], pos, sizes[idx], start=0, end=1)
continue
else:
print("[SUM] |--> Summon #{}:".format(i+1), export['ss'][i], "Uncap Lv{}".format(export['se'][i]), "Lv{}".format(export['sl'][i]))
await self.dlAndPasteImage(imgs, surls[idx].format(export['ss'][i]), pos, sizes[idx], start=0, end=1)
# main summon skin
if i == 0 and export['ssm'] is not None:
await self.dlAndPasteImage(imgs, surls[idx].format(export['ssm']), pos, sizes[idx], start=1, end=2)
await self.pasteImage(imgs, "assets/skin.png", self.add(pos, (sizes[idx][0]-85, 15)), (76, 85), start=1, end=2)
has_skin = True
else:
has_skin = False
# star
await self.pasteImage(imgs, self.get_summon_star(export['se'][i], export['sl'][i]), pos, (66, 66), transparency=True, start=0, end=2 if has_skin else 1)
# quick summon
if export['qs'] is not None and export['qs'] == i:
await self.pasteImage(imgs, "assets/quick.png", self.add(pos, (0, 66)), (66, 66), transparency=True, start=0, end=2 if has_skin else 1)
# level
await self.pasteImage(imgs, "assets/chara_stat.png", self.add(pos, (0, sizes[idx][1])), (sizes[idx][0], 60), transparency=True, start=0, end=1)
self.text(imgs, self.add(pos, (6,sizes[idx][1]+9)), "Lv{}".format(export['sl'][i]), fill=(255, 255, 255), font=self.fonts['small'], start=0, end=1)
# plus
if export['sp'][i] > 0:
self.text(imgs, (pos[0]+sizes[idx][0]-95, pos[1]+sizes[idx][1]-50), "+{}".format(export['sp'][i]), fill=(255, 255, 95), font=self.fonts['medium'], stroke_width=6, stroke_fill=(0, 0, 0), start=0, end=2 if has_skin else 1)
await asyncio.sleep(0)
# stats
spos = self.add(offset, (sizes[0][0]+50+18, sizes[0][1]+60))
await self.pasteImage(imgs, "assets/chara_stat.png", spos, (sizes[1][0]*2, 60), transparency=True, start=0, end=1)
await self.pasteImage(imgs, "assets/atk.png", self.add(spos, (9, 9)), (90, 39), transparency=True, start=0, end=1)
await self.pasteImage(imgs, "assets/hp.png", self.add(spos, (sizes[1][0]+9, 9)), (66, 39), transparency=True, start=0, end=1)
self.text(imgs, self.add(spos, (120, 9)), "{}".format(export['satk']), fill=(255, 255, 255), font=self.fonts['small'], start=0, end=1)
self.text(imgs, self.add(spos, (sizes[1][0]+80, 9)), "{}".format(export['shp']), fill=(255, 255, 255), font=self.fonts['small'], start=0, end=1)
return ('summon', imgs)
except Exception as e:
imgs[0].close()
imgs[1].close()
return self.pexc(e)
async def make_weapon(self, export : dict, do_hp : bool, do_opus : bool) -> Union[str, tuple]:
try:
imgs = [self.make_canvas(), self.make_canvas()]
print("[WPN] * Drawing Weapons...")
if self.sandbox: offset = (25, 1050)
else: offset = (170, 1050)
skill_box_height = 144
skill_icon_size = 72
ax_icon_size = 86
ax_separator = skill_box_height
mh_size = (300, 630)
sub_size = (288, 165)
self.multiline_text(imgs, (1425, 2125), self.wtm, fill=(120, 120, 120, 255), font=self.fonts['mini'])
await self.pasteImage(imgs, "assets/grid_bg.png", self.add(offset, (-15, -15)), (mh_size[0]+(4 if self.sandbox else 3)*sub_size[0]+60, 1425+(240 if self.sandbox else 0)), transparency=True, start=0, end=1)
if self.sandbox:
await self.pasteImage(imgs, "assets/grid_bg_extra.png", (offset[0]+mh_size[0]+30+sub_size[0]*3, offset[1]), (288, 1145), transparency=True, start=0, end=1)
for i in range(0, len(export['w'])):
await asyncio.sleep(0)
wt = "ls" if i == 0 else "m"
if i == 0: # mainhand
pos = (offset[0], offset[1])
size = mh_size
bsize = size
elif i >= 10: # sandbox
if not self.sandbox: break
x = 3
y = (i-1) % 3
size = sub_size
pos = (offset[0]+bsize[0]+30+size[0]*x, offset[1]+(size[1]+skill_box_height)*y)
else: # others
x = (i-1) % 3
y = (i-1) // 3
size = sub_size
pos = (offset[0]+bsize[0]+30+size[0]*x, offset[1]+(size[1]+skill_box_height)*y)
# dual blade class
if i <= 1 and export['p'] in self.AUXILIARY_CLS:
await self.pasteImage(imgs, ("assets/mh_dual.png" if i == 0 else "assets/aux_dual.png"), self.add(pos, (-2, -2)), self.add(size, (5, 5+skill_box_height)), transparency=True, start=0, end=1)
# portrait
if export['w'][i] is None or export['wl'][i] is None:
if i >= 10:
await self.pasteImage(imgs, "assets/arca_slot.png", pos, size, start=0, end=1)
else:
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/weapon/{}/1999999999.jpg".format(wt), pos, size, start=0, end=1)
continue
# ax and awakening check
has_ax = len(export['waxt'][i]) > 0
has_awakening = (export['wakn'][i] is not None and export['wakn'][i]['is_arousal_weapon'] and export['wakn'][i]['level'] is not None and export['wakn'][i]['level'] > 1)
pos_shift = - skill_icon_size if (has_ax and has_awakening) else 0 # vertical shift of the skill boxes (if both ax and awk are presents)
# portrait draw
print("[WPN] |--> Weapon #{}".format(i+1), str(export['w'][i]), ", AX:", has_ax, ", Awakening:", has_awakening)
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/weapon/{}/{}.jpg".format(wt, export['w'][i]), pos, size, start=0, end=1)
# skin
has_skin = False
if i <= 1 and export['wsm'][i] is not None:
if i == 0 or (i == 1 and export['p'] in self.AUXILIARY_CLS): # aux class check for 2nd weapon
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/weapon/{}/{}.jpg".format(wt, export['wsm'][i]), pos, size, start=1, end=2)
await self.pasteImage(imgs, "assets/skin.png", self.add(pos, (size[0]-76, 0)), (76, 85), transparency=True, start=1, end=2)
has_skin = True
# skill box
nbox = 1 # number of skill boxes to draw
if has_ax: nbox += 1
if has_awakening: nbox += 1
for j in range(nbox):
if i != 0 and j == 0 and nbox == 3: # if 3 boxes and we aren't on the mainhand, we draw half of one for the first box
await self.pasteImage(imgs, "assets/skill.png", (pos[0]+size[0]//2, pos[1]+size[1]+pos_shift+skill_icon_size*j), (size[0]//2, skill_icon_size), transparency=True, start=0, end=2 if (has_skin and j == 0) else 1)
else:
await self.pasteImage(imgs, "assets/skill.png", (pos[0], pos[1]+size[1]+pos_shift+skill_icon_size*j), (size[0], skill_icon_size), transparency=True, start=0, end=2 if (has_skin and j == 0) else 1)
# plus
if export['wp'][i] > 0:
# calculate shift of the position if AX and awakening are present
if pos_shift != 0:
if i > 0: shift = (- size[0]//2, 0)
else: shift = (0, pos_shift)
else:
shift = (0, 0)
# draw plus text
self.text(imgs, (pos[0]+size[0]-105+shift[0], pos[1]+size[1]-60+shift[1]), "+{}".format(export['wp'][i]), fill=(255, 255, 95), font=self.fonts['medium'], stroke_width=6, stroke_fill=(0, 0, 0), start=0, end=2 if has_skin else 1)
# skill level
if export['wl'][i] is not None and export['wl'][i] > 1:
self.text(imgs, (pos[0]+skill_icon_size*3-51, pos[1]+size[1]+pos_shift+15), "SL {}".format(export['wl'][i]), fill=(255, 255, 255), font=self.fonts['small'], start=0, end=2 if has_skin else 1)
if i == 0 or not has_ax or not has_awakening: # don't draw if ax and awakening and not mainhand
# skill icon
for j in range(3):
if export['wsn'][i][j] is not None:
if do_opus and self.process_special_weapon(export, i, j): # 3rd skill guessing
await self.dlAndPasteImage(imgs, export['wsn'][i][j], (pos[0]+skill_icon_size*j, pos[1]+size[1]+pos_shift), (skill_icon_size, skill_icon_size), start=0, end=2 if has_skin else 1)
else:
await self.dlAndPasteImage(imgs, "assets_en/img/sp/ui/icon/skill/{}.png".format(export['wsn'][i][j]), (pos[0]+skill_icon_size*j, pos[1]+size[1]+pos_shift), (skill_icon_size, skill_icon_size), start=0, end=2 if has_skin else 1)
pos_shift += skill_icon_size
main_ax_icon_size = int(ax_icon_size * (1.5 if i == 0 else 1) * (0.75 if (has_ax and has_awakening) else 1)) # size of the big AX/Awakening icon
# ax skills
if has_ax:
await self.dlAndPasteImage(imgs, "assets_en/img/sp/ui/icon/augment_skill/{}.png".format(export['waxt'][i][0]), pos, (main_ax_icon_size, main_ax_icon_size), start=0, end=2 if has_skin else 1)
for j in range(len(export['waxi'][i])):
await self.dlAndPasteImage(imgs, "assets_en/img/sp/ui/icon/skill/{}.png".format(export['waxi'][i][j]), (pos[0]+ax_separator*j, pos[1]+size[1]+pos_shift), (skill_icon_size, skill_icon_size), start=0, end=1)
self.text(imgs, (pos[0]+ax_separator*j+skill_icon_size+6, pos[1]+size[1]+pos_shift+15), "{}".format(export['wax'][i][0][j]['show_value']).replace('%', '').replace('+', ''), fill=(255, 255, 255), font=self.fonts['small'], start=0, end=1)
pos_shift += skill_icon_size
# awakening
if has_awakening:
shift = main_ax_icon_size//2 if has_ax else 0 # shift the icon right a bit if also has AX icon
await self.dlAndPasteImage(imgs, "assets_en/img/sp/ui/icon/arousal_type/type_{}.png".format(export['wakn'][i]['form']), self.add(pos, (shift, 0)), (main_ax_icon_size, main_ax_icon_size), start=0, end=2 if has_skin else 1)
await self.dlAndPasteImage(imgs, "assets_en/img/sp/ui/icon/arousal_type/type_{}.png".format(export['wakn'][i]['form']), (pos[0]+skill_icon_size, pos[1]+size[1]+pos_shift), (skill_icon_size, skill_icon_size), start=0, end=1)
self.text(imgs, (pos[0]+skill_icon_size*3-51, pos[1]+size[1]+pos_shift+15), "LV {}".format(export['wakn'][i]['level']), fill=(255, 255, 255), font=self.fonts['small'], start=0, end=1)
if self.sandbox:
await self.pasteImage(imgs, "assets/sandbox.png", (pos[0], offset[1]+(skill_box_height+sub_size[1])*3), (size[0], int(66*size[0]/159)), transparency=True, start=0, end=1)
# stats
pos = (offset[0], offset[1]+bsize[1]+150)
await self.pasteImage(imgs, "assets/skill.png", (pos[0], pos[1]), (bsize[0], 75), transparency=True, start=0, end=1)
await self.pasteImage(imgs, "assets/skill.png", (pos[0], pos[1]+75), (bsize[0], 75), transparency=True, start=0, end=1)
await self.pasteImage(imgs, "assets/atk.png", (pos[0]+9, pos[1]+15), (90, 39), transparency=True, start=0, end=1)
await self.pasteImage(imgs, "assets/hp.png", (pos[0]+9, pos[1]+15+75), (66, 39), transparency=True, start=0, end=1)
self.text(imgs, (pos[0]+111, pos[1]+15), "{}".format(export['watk']), fill=(255, 255, 255), font=self.fonts['medium'], start=0, end=1)
self.text(imgs, (pos[0]+111, pos[1]+15+75), "{}".format(export['whp']), fill=(255, 255, 255), font=self.fonts['medium'], start=0, end=1)
await asyncio.sleep(0)
# estimated damage
pos = (pos[0]+bsize[0]+15, pos[1]+165)
if (export['sps'] is not None and export['sps'] != '') or export['spsid'] is not None:
await asyncio.sleep(0)
# support summon
if export['spsid'] is not None:
supp = export['spsid']
else:
print("[WPN] |--> Looking up summon ID of", export['sps'], "on the wiki")
supp = await self.get_support_summon_from_wiki(export['sps'])
if supp is None:
print("[WPN] |--> Support summon is", export['sps'], "(Note: searching its ID on gbf.wiki failed)")
await self.pasteImage(imgs, "assets/big_stat.png", (pos[0]-bsize[0]-15, pos[1]+9*2-15), (bsize[0], 150), transparency=True, start=0, end=1)
self.text(imgs, (pos[0]-bsize[0], pos[1]+9*2), ("サポーター" if self.japanese else "Support"), fill=(255, 255, 255), font=self.fonts['medium'], start=0, end=1)
if len(export['sps']) > 10: supp = export['sps'][:10] + "..."
else: supp = export['sps']
self.text(imgs, (pos[0]-bsize[0], pos[1]+9*2+60), supp, fill=(255, 255, 255), font=self.fonts['medium'], start=0, end=1)
else:
print("[WPN] |--> Support summon ID is", supp)
await self.dlAndPasteImage(imgs, "assets_en/img/sp/assets/summon/m/{}.jpg".format(supp), (pos[0]-bsize[0]-15+9, pos[1]), (261, 150), start=0, end=1)
# weapon grid stats
est_width = ((size[0]*3)//2)
for i in range(0, 2):
await asyncio.sleep(0)
await self.pasteImage(imgs, "assets/big_stat.png", (pos[0]+est_width*i , pos[1]), (est_width-15, 150), transparency=True, start=0, end=1)
self.text(imgs, (pos[0]+9+est_width*i, pos[1]+9), "{}".format(export['est'][i+1]), fill=self.COLORS[int(export['est'][0])], font=self.fonts['big'], stroke_width=6, stroke_fill=(0, 0, 0), start=0, end=1)
if i == 0:
self.text(imgs, (pos[0]+est_width*i+15 , pos[1]+90), ("予測ダメ一ジ" if self.japanese else "Estimated"), fill=(255, 255, 255), font=self.fonts['medium'], start=0, end=1)
elif i == 1:
if int(export['est'][0]) <= 4: vs = (int(export['est'][0]) + 2) % 4 + 1
else: vs = (int(export['est'][0]) - 5 + 1) % 2 + 5
if self.japanese:
self.text(imgs, (pos[0]+est_width*i+15 , pos[1]+90), "対", fill=(255, 255, 255), font=self.fonts['medium'], start=0, end=1)
self.text(imgs, (pos[0]+est_width*i+54 , pos[1]+90), "{}属性".format(self.COLORS_JP[vs]), fill=self.COLORS[vs], font=self.fonts['medium'], start=0, end=1)
self.text(imgs, (pos[0]+est_width*i+162 , pos[1]+90), "予測ダメ一ジ", fill=(255, 255, 255), font=self.fonts['medium'], start=0, end=1)
else:
self.text(imgs, (pos[0]+est_width*i+15 , pos[1]+90), "vs", fill=(255, 255, 255), font=self.fonts['medium'], start=0, end=1)
self.text(imgs, (pos[0]+est_width*i+66 , pos[1]+90), "{}".format(self.COLORS_EN[vs]), fill=self.COLORS[vs], font=self.fonts['medium'], start=0, end=1)
# hp gauge
if do_hp:
await asyncio.sleep(0)
hpratio = 100
for et in export['estx']:
if et[0].replace('txt-gauge-num ', '') == 'hp':
hpratio = et[1]
break
await self.pasteImage(imgs, "assets/big_stat.png", (pos[0] ,pos[1]), (est_width-15, 150), transparency=True, start=1, end=2)
if self.japanese:
self.text(imgs, (pos[0]+25 , pos[1]+25), "HP{}%".format(hpratio), fill=(255, 255, 255), font=self.fonts['medium'], start=1, end=2)
else:
self.text(imgs, (pos[0]+25 , pos[1]+25), "{}% HP".format(hpratio), fill=(255, 255, 255), font=self.fonts['medium'], start=1, end=2)
await self.pasteImage(imgs, "assets/hp_bottom.png", (pos[0]+25 , pos[1]+90), (363, 45), transparency=True, start=1, end=2)
await self.pasteImage(imgs, "assets/hp_mid.png", (pos[0]+25 , pos[1]+90), (int(363*int(hpratio)/100), 45), transparency=True, start=1, end=2, crop=(int(484*int(hpratio)/100), 23))
await self.pasteImage(imgs, "assets/hp_top.png", (pos[0]+25 , pos[1]+90), (363, 45), transparency=True, start=1, end=2)
return ('weapon', imgs)
except Exception as e:
imgs[0].close()
imgs[1].close()
return self.pexc(e)
async def make_modifier(self, export : dict) -> Union[str, tuple]:
try:
imgs = [self.make_canvas()]
print("[MOD] * Drawing Modifiers...")
if self.babyl:
offset = (1560, 10)
limit = [32, 25, 20]
else:
offset = (1560, 410)
limit = [27, 20, 16]
print("[MOD] |--> Found", len(export['mods']), "modifier(s)...")
# weapon modifier list
if len(export['mods']) > 0:
mod_font = ['mini', 'mini', 'small', 'medium']
mod_off =[15, 15, 27, 15]
mod_bg_size = [(258, 114), (185, 114), (222, 114), (258, 114)]
mod_size = [(80, 40), (150, 38), (174, 45), (241, 60)]
mod_img_off = [(-10, 0), (0, 0), (0, 0), (0, 0)]
mod_text_off = [(80, 5), (0, 35), (0, 45), (0, 60)]
mod_step = [42, 66, 84, 105]
mod_crop = [(68, 34), None, None, None]
# auto sizing
if len(export['mods']) >= limit[0]: idx = 0 # compact mode
elif len(export['mods']) >= limit[1]: idx = 1 # smallest size
elif len(export['mods']) >= limit[2]: idx = 2
else: idx = 3 # biggest size
print("[MOD] |--> Display mode:", idx)
await asyncio.sleep(0)
# background
await self.pasteImage(imgs, "assets/mod_bg.png", (offset[0]-mod_off[idx], offset[1]-mod_off[idx]//2), mod_bg_size[idx])
try:
await self.pasteImage(imgs, "assets/mod_bg_supp.png", (offset[0]-mod_off[idx], offset[1]-mod_off[idx]+mod_bg_size[idx][1]), (mod_bg_size[idx][0], mod_step[idx] * (len(export['mods'])-1)))
await self.pasteImage(imgs, "assets/mod_bg_bot.png", (offset[0]-mod_off[idx], offset[1]+mod_step[idx]*(len(export['mods'])-1)), mod_bg_size[idx])
except:
await self.pasteImage(imgs, "assets/mod_bg_bot.png", (offset[0]-mod_off[idx], offset[1]+50), mod_bg_size[idx])
offset = (offset[0], offset[1])
# modifier draw
for m in export['mods']:
await asyncio.sleep(0)
await self.dlAndPasteImage(imgs, "assets_en/img/sp/ui/icon/weapon_skill_label/" + m['icon_img'], self.add(offset, mod_img_off[idx]), mod_size[idx], transparency=True, crop=mod_crop[idx])
self.text(imgs, self.add(offset, mod_text_off[idx]), str(m['value']), fill=((255, 168, 38, 255) if m['is_max'] else (255, 255, 255, 255)), font=self.fonts[mod_font[idx]])
offset = (offset[0], offset[1]+mod_step[idx])
return ('modifier', imgs)
except Exception as e:
imgs[0].close()
return self.pexc(e)
async def loadEMP(self, id):
try:
if id in self.emp_cache:
return self.emp_cache[id]
else:
with open("emp/{}.json".format(id), mode="r", encoding="utf-8") as f:
self.emp_cache[id] = json.load(f)
await asyncio.sleep(0)
return self.emp_cache[id]
except: