-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomized Program 11 - Count Recently Player Summoners.py
More file actions
3674 lines (3629 loc) · 358 KB
/
Customized Program 11 - Count Recently Player Summoners.py
File metadata and controls
3674 lines (3629 loc) · 358 KB
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
from lcu_driver import Connector
from lcu_driver.connection import Connection
import argparse, datetime, json, math, os, pandas, requests, time, traceback
import matplotlib.pyplot as plt
from typing import Any, Optional
from src.utils.summoner import print_summoner_info, get_info, get_info_name
from src.utils.logger import LogManager
from src.utils.format import format_df, addDefaultStyle, verify_uuid
from src.utils.patch import Patch
from src.utils.webRequest import requestUrl, SGPSession
from src.utils.excel_workbook import create_workbook_win32
from src.core.config.conditional_formatting import addFormat_LoLGame_summary_wb, addFormat_LoLGame_summary_wb_transpose
from src.core.config.const import BOT_UUID
from src.core.config.servers import valid_platformIds, set_platform_folder, set_summonerInfo_folder, save_platform_info
from src.core.config.localization import language_ddragon, language_dict, language_cdragon
from src.core.config.headers import LoLGame_summary_header, LoLGame_summary_sgp_header, TFTHistory_header
from src.core.dataframes.matchHistory import get_LoLHistory, get_matchSummary_sgp, sort_LoLHistory, sort_LoLHistory_sgp, sort_LoLGame_stats, sort_LoLGame_stats_sgp, sort_TFTHistory, sort_TFTGame_stats, sort_LoLGame_summary, sort_LoLGame_summary_sgp, sort_TFTGame_summary, get_game_summary_sgp, get_LoLGame_summary
from src.core.dataframes.gameflow import sort_multiChampSelect_players
parser = argparse.ArgumentParser()
parser.add_argument("-a", "--lol-api", help = "指定通过什么接口获取英雄联盟对局概要和时间轴(Specify the interface used to fetch LoL game summary and timeline)", action = "store", type = str, choices = ["lcu", "sgp"], default = "sgp")
parser.add_argument("-r", "--reserve", help = "在对局不包含主玩家的情况下仍然加载该对局(Load a match even if it doesn't contain the main player)", action = "store_true")
parser.add_argument("-ss", "--save-self", help = "在对局包含主玩家的情况下仍然保存其数据(Save the main summoner's data even if they're contained in a match)", action = "store_true")
args = parser.parse_args()
use_sgp: bool = args.lol_api == "sgp"
#=============================================================================
# * 声明(Declaration)
#=============================================================================
# 作者(Author): WordlessMeteor
# 主页(Home page): https://github.com/WordlessMeteor/LoL-DIY-Programs/
# 鸣谢(Acknowledgement): XHXIAIEIN, Awesome丶ABC
# 更新(Last update): 2026/04/29
#=============================================================================
#-----------------------------------------------------------------------------
# 工具库(Tool library)
#-----------------------------------------------------------------------------
# - lcu-driver
# https://github.com/sousa-andre/lcu-driver
#-----------------------------------------------------------------------------
session: requests.Session = requests.Session()
sgpSession: SGPSession = SGPSession()
URLPatch: str = ""
patches_initial: list[str] = []
bigPatches: list[Patch] = []
queues_initial: dict[int, dict[str, Any]] = {}
spells_initial: dict[int, dict[str, Any]] = {}
LoLChampions_initial: dict[int, dict[str, Any]] = {}
LoLItems_initial: dict[int, dict[str, Any]] = {}
summonerIcons_initial: dict[int, dict[str, Any]] = {}
perks_initial: dict[int, dict[str, Any]] = {}
perkstyles_initial: dict[int, dict[str, Any]] = {}
TFTAugments_initial: dict[str, dict[str, Any]] = {}
TFTChampions_initial: dict[str, dict[str, Any]] = {}
TFTItems_initial: dict[str, dict[str, Any]] = {}
TFTCompanions_initial: dict[str, dict[str, Any]] = {}
TFTTraits_initial: dict[str, dict[str, Any]] = {}
CherryAugments_initial: dict[int, dict[str, Any]] = {}
wardSkins: dict[int, dict[str, Any]] = {}
championSkins: dict[int, dict[str, Any]] = {}
log: LogManager = LogManager()
platformId: str = ""
AllAccounts: list[dict[str, Any]] = []
champ_select_session_cache: dict[int, dict[str, Any]] = {}
error_header = {"errorCode": "异常代码", "httpStatus": "HTTP状态码", "implementationDetails": "细节", "message": "消息"}
error_header_keys = list(error_header.keys())
connector: Connector = Connector()
#-----------------------------------------------------------------------------
# 查找最近一起并肩作战的召唤师并给出统计信息(Find recently played summoners and give statistics of it)
#-----------------------------------------------------------------------------
def prepare_data_resources(platformId: str, locale: str) -> tuple[bool, bool]:
'''
准备全局数据资源。<br>Prepare global data resources.
:param platformId: 服务器代号。决定使用正式服还是测试服的数据资源。<br>PlatformId, which determines one of Live and PBE data resources will be used.
服务器代号可以通过以下LCU接口获取:<br>PlatformId can be obtained through the following LCU endpoint:
- `GET /lol-lobby/v1/parties/player`
:type platformId: str
:param locale: 语言文化代码。决定了数据资源的语言。<br>Language code, which determines the language of the data resources.
:type locale
:return: 是否切换语言,以及是否退出程序。<br>Whether to switch language and whether to exit the program.
:rtype: tuple[bool, bool]
'''
global session, URLPatch, patches_initial, bigPatches, queues_initial, spells_initial, LoLChampions_initial, LoLItems_initial, summonerIcons_initial, perks_initial, perkstyles_initial, TFTAugments_initial, TFTChampions_initial, TFTItems_initial, TFTCompanions_initial, TFTTraits_initial, CherryAugments_initial
#下面声明一些数据资源的地址(The following code declare some data resources' URLs)
URLPatch = "pbe" if platformId == "PBE1" or platformId == "PBE" else "latest"
patches_url: str = "https://ddragon.leagueoflegends.com/api/versions.json"
queue_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/queues.json" %(URLPatch, language_cdragon[locale]) #CommunityDragon数据库只存储第7赛季及以后的数据(CommunityDragon database only stores data including and after Season 7)
spell_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/summoner-spells.json" %(URLPatch, language_cdragon[locale])
LoLChampion_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/champion-summary.json" %(URLPatch, language_cdragon[locale])
LoLItem_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/items.json" %(URLPatch, language_cdragon[locale])
summonerIcon_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/summoner-icons.json" %(URLPatch, language_cdragon[locale])
perk_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/perks.json" %(URLPatch, language_cdragon[locale])
perkstyle_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/perkstyles.json" %(URLPatch, language_cdragon[locale])
TFTBasic_url: str = "https://raw.communitydragon.org/%s/cdragon/tft/%s.json" %(URLPatch, locale.lower())
TFTChampion_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/tftchampions.json" %(URLPatch, language_cdragon[locale])
TFTItem_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/tftitems.json" %(URLPatch, language_cdragon[locale])
TFTCompanion_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/companions.json" %(URLPatch, language_cdragon[locale])
TFTTrait_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/tfttraits.json" %(URLPatch, language_cdragon[locale])
CherryAugment_url: str = "https://raw.communitydragon.org/%s/plugins/rcp-be-lol-game-data/global/%s/v1/cherry-augments.json" %(URLPatch, language_cdragon[locale])
#下面声明离线数据资源的默认地址(The following code declare the default paths of offline data resources)
patches_local_default: str = "离线数据(Offline Data)\\versions.json"
queue_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\queues.json" %(URLPatch, language_cdragon[locale])
spell_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\summoner-spells.json" %(URLPatch, language_cdragon[locale])
LoLChampion_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\champion-summary.json" %(URLPatch, language_cdragon[locale])
LoLItem_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\items.json" %(URLPatch, language_cdragon[locale])
summonerIcon_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\summoner-icons.json" %(URLPatch, language_cdragon[locale])
perk_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\perks.json" %(URLPatch, language_cdragon[locale])
perkstyle_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\perkstyles.json" %(URLPatch, language_cdragon[locale])
TFTBasic_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\cdragon\\tft\\%s.json" %(URLPatch, locale.lower())
TFTChampion_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\tftchampions.json" %(URLPatch, language_cdragon[locale])
TFTItem_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\tftitems.json" %(URLPatch, language_cdragon[locale])
TFTCompanion_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\companions.json" %(URLPatch, language_cdragon[locale])
TFTTrait_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\tfttraits.json" %(URLPatch, language_cdragon[locale])
CherryAugment_local_default: str = "离线数据(Offline Data)\\cdragon\\%s\\plugins\\rcp-be-lol-game-data\\global\\%s\\v1\\cherry-augments.json" %(URLPatch, locale.lower())
#加载数据(Load data)
logPrint("请选择数据资源获取模式:\nPlease select the data resource capture mode:\n1\t在线模式(Online)\n2\t离线模式(Offline)")
prepareMode: str = logInput()
switch_language: bool = False
while True:
if prepareMode != "" and prepareMode[0] == "1":
switch_prepare_mode: bool = False
#下面获取版本信息(The following code get the patch data)
try:
source, status, session = requestUrl("GET", patches_url, session = session, log = log)
patches_initial = source.json()
except requests.exceptions.RequestException:
logPrint('版本信息获取超时!正在尝试离线加载数据……\nPatch information capture timeout! Trying loading offline data ...\n请输入版本Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the patch Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(patches_local_default, patches_local_default))
while True:
patches_local: str = logInput()
if patches_local == "":
patches_local = patches_local_default
elif patches_local[0] == "0":
logPrint("版本信息获取失败!请检查系统网络状况和代理设置。\nPatch information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(patches_local, "r", encoding = "utf-8") as fp:
patches_initial = json.load(fp)
if isinstance(patches_initial, list) and patches_initial[-1] == "lolpatch_3.7":
break
else:
logPrint("数据格式错误!请选择一个符合DataDragon数据库中记录的版本数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the patch data archived in DataDragon database (%s)!" %(patches_url, patches_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的版本Json数据文件路径!\nFile "%s" NOT found! Please input a correct patch Json data file path!' %(patches_local, patches_local))
except OSError:
logPrint("数据文件名不合法!请输入含有版本信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with patch information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合DataDragon数据库中记录的版本数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the patch data archived in DataDragon database (%s)!" %(patches_url, patches_url))
if switch_prepare_mode:
prepareMode = ""
continue
latest_patch: str = patches_initial[0]
patches_dict: dict[str, list[str]] = {}
smallPatches: list[str] = []
bigPatches = []
for patch in patches_initial:
if not patch.startswith("lolpatch"):
patch_split: str = patch.split(".")
smallPatch: str = ".".join(patch_split[:3])
smallPatches.append(Patch(smallPatch))
bigPatch: str = ".".join(patch_split[:2])
bigPatches.append(Patch(bigPatch))
patches_dict[bigPatch] = []
for i in range(len(bigPatches)):
patches_dict[str(bigPatches[i])].append(str(smallPatches[i]))
#下面获取游戏模式数据(The following code get game mode data)
try:
logPrint("正在加载游戏模式信息……\nLoading game mode information from CommunityDragon...")
source, status, session = requestUrl("GET", queue_url, session = session, log = log)
if source.ok:
queue_initial: list[str] = source.json() #queue存储游戏模式信息(Variable `queue_initial` stores game mode information)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('游戏模式信息获取超时!正在尝试离线加载数据……\nQueue information capture timeout! Trying loading offline data ...\n请输入游戏模式Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the game mode Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(queue_local_default, queue_local_default))
while True:
queue_local: str = logInput()
if queue_local == "":
queue_local = queue_local_default
elif queue_local[0] == "0":
logPrint("游戏模式信息获取失败!请检查系统网络状况和代理设置。\nQueue information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(queue_local, "r", encoding = "utf-8") as fp:
queue_initial = json.load(fp)
if isinstance(queue_initial, list) and all(map(lambda x: all(i in x for i in ["id", "name", "shortName", "description", "detailedDescription", "gameSelectModeGroup", "gameSelectCategory", "gameSelectPriority", "isSkillTreeQueue", "isLimitedTimeQueue", "isBotHonoringAllowed", "hidePlayerPosition", "viableChampionRoster"]), queue_initial)) and all(map(lambda x: all(isinstance(x[i], int) for i in ["id", "gameSelectPriority"]), queue_initial)) and all(map(lambda x: all(isinstance(x[i], str) for i in ["name", "shortName", "description", "detailedDescription", "gameSelectModeGroup", "gameSelectCategory"]), queue_initial)) and all(map(lambda x: all(isinstance(x[i], bool) for i in ["isSkillTreeQueue", "isLimitedTimeQueue", "isBotHonoringAllowed", "hidePlayerPosition"]), queue_initial)) and all(map(lambda x: all(isinstance(x[i], list) or x[i] is None for i in ["viableChampionRoster"]), queue_initial)):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的游戏模式数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the game mode data archived in CommunityDragon database (%s)!" %(queue_url, queue_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的游戏模式Json数据文件路径!\nFile "%s" NOT found! Please input a correct game mode Json data file path!' %(queue_local, queue_local))
except OSError:
logPrint("数据文件名不合法!请输入含有游戏模式信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with game mode information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的游戏模式数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the game mode data archived in CommunityDragon database (%s)!" %(queue_url, queue_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取召唤师技能数据(The following code get summoner spell data)
try:
logPrint("正在加载召唤师技能信息……\nLoading summoner spell information from CommunityDragon...")
source, status, session = requestUrl("GET", spell_url, session = session, log = log)
if source.ok:
spell_initial: list[dict[str, Any]] = source.json() #spell存储召唤师技能信息(Variable `spell_initial` stores summoner spell information)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('召唤师技能信息获取超时!正在尝试离线加载数据……\nSummoner spell information capture timeout! Trying loading offline data ...\n请输入召唤师技能Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the summoner spell Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(spell_local_default, spell_local_default))
while True:
spell_local: str = logInput()
if spell_local == "":
spell_local = spell_local_default
elif spell_local[0] == "0":
logPrint("召唤师技能信息获取失败!请检查系统网络状况和代理设置。\nSummoner spell information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(spell_local, "r", encoding = "utf-8") as fp:
spell_initial = json.load(fp)
if isinstance(spell_initial, list) and all(i in spell_initial[j] for i in ["id", "name", "description", "summonerLevel", "cooldown", "gameModes", "iconPath"] for j in range(len(spell_initial))):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的召唤师技能数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the summoner spell data archived in CommunityDragon database (%s)!" %(spell_url, spell_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的召唤师技能Json数据文件路径!\nFile "%s" NOT found! Please input a correct summoner spell Json data file path!' %(spell_local, spell_local))
except OSError:
logPrint("数据文件名不合法!请输入含有召唤师技能信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with summoner spell information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的召唤师技能数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the summoner spell data archived in CommunityDragon database (%s)!" %(spell_url, spell_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取英雄信息(The following code get LoL champion data)
try:
logPrint("正在加载英雄信息……\nLoading LoL champion information from CommunityDragon...")
source, status, session = requestUrl("GET", LoLChampion_url, session = session, log = log)
if source.ok:
LoLChampion_initial: list[dict[str, Any]] = source.json() #LoLItem存储英雄信息。(Variable `LoLChampion_initial` stores information of LoL champions)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('英雄信息获取超时!正在尝试离线加载数据……\nLoL champion information capture timeout! Trying loading offline data ...\n请输入英雄Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the LoL champion Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(LoLChampion_local_default, LoLChampion_local_default))
while True:
LoLChampion_local: str = logInput()
if LoLChampion_local == "":
LoLChampion_local = LoLChampion_local_default
elif LoLChampion_local[0] == "0":
logPrint("英雄信息获取失败!请检查系统网络状况和代理设置。\nLoL champion information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(LoLChampion_local, "r", encoding = "utf-8") as fp:
LoLChampion_initial = json.load(fp)
if isinstance(LoLChampion_initial, list) and all(isinstance(LoLChampion_initial[i], dict) for i in range(len(LoLChampion_initial))) and all(j in LoLChampion_initial[i] for i in range(len(LoLChampion_initial)) for j in ["id", "name", "alias", "squarePortraitPath", "roles"]) and all(isinstance(LoLChampion_initial[i]["id"], int) for i in range(len(LoLChampion_initial))) and all(isinstance(LoLChampion_initial[i]["name"], str) for i in range(len(LoLChampion_initial))) and all(isinstance(LoLChampion_initial[i]["alias"], str) for i in range(len(LoLChampion_initial))) and all(isinstance(LoLChampion_initial[i]["squarePortraitPath"], str) for i in range(len(LoLChampion_initial))) and all(isinstance(LoLChampion_initial[i]["roles"], list) for i in range(len(LoLChampion_initial))):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的英雄数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the LoL champion data archived in CommunityDragon database (%s)!" %(LoLChampion_url, LoLChampion_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的英雄Json数据文件路径!\nFile "%s" NOT found! Please input a correct LoL champion Json data file path!' %(LoLChampion_local, LoLChampion_local))
except OSError:
logPrint("数据文件名不合法!请输入含有英雄信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with LoL champion information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的英雄数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the LoL champion data archived in CommunityDragon database (%s)!" %(LoLChampion_url, LoLChampion_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取英雄联盟装备信息(The following code get LoL item data)
try:
logPrint("正在加载英雄联盟装备信息……\nLoading LoL item information from CommunityDragon...")
source, status, session = requestUrl("GET", LoLItem_url, session = session, log = log)
if source.ok:
LoLItem_initial: list[dict[str, Any]] = source.json() #LoLItem存储经典模式的装备信息。(Variable `LoLItem_initial` stores information of LoL items)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('英雄联盟装备信息获取超时!正在尝试离线加载数据……\nLoL item information capture timeout! Trying loading offline data ...\n请输入英雄联盟装备Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the LoL item Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(LoLItem_local_default, LoLItem_local_default))
while True:
LoLItem_local: str = logInput()
if LoLItem_local == "":
LoLItem_local = LoLItem_local_default
elif LoLItem_local[0] == "0":
logPrint("英雄联盟装备信息获取失败!请检查系统网络状况和代理设置。\nLoL item information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(LoLItem_local, "r", encoding = "utf-8") as fp:
LoLItem_initial = json.load(fp)
if isinstance(LoLItem_initial, list) and all(i in LoLItem_initial[j] for i in ["id", "name", "description", "active", "inStore", "from", "to", "categories", "maxStacks", "requiredChampion", "requiredAlly", "requiredBuffCurrencyName", "requiredBuffCurrencyCost", "specialRecipe", "isEnchantment", "price", "priceTotal", "iconPath"] for j in range(len(LoLItem_initial))):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的英雄联盟装备数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the LoL item data archived in CommunityDragon database (%s)!" %(LoLItem_url, LoLItem_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的英雄联盟装备Json数据文件路径!\nFile "%s" NOT found! Please input a correct LoL item Json data file path!' %(LoLItem_local, LoLItem_local))
except OSError:
logPrint("数据文件名不合法!请输入含有英雄联盟装备信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with LoL item information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的英雄联盟装备数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the LoL item data archived in CommunityDragon database (%s)!" %(LoLItem_url, LoLItem_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取召唤师图标信息(The following code get summoner icon data)
try:
logPrint("正在加载召唤师图标信息……\nLoading summoner icon information from CommunityDragon...")
source, status, session = requestUrl("GET", summonerIcon_url, session = session, log = log)
if source.ok:
summonerIcon_initial: list[dict[str, Any]] = source.json() #LoLItem存储召唤师图标信息。(Variable `summonerIcon_initial` stores information of summoner icons)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('召唤师图标信息获取超时!正在尝试离线加载数据……\nSummoner icon information capture timeout! Trying loading offline data ...\n请输入召唤师图标Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the summoner icon Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(summonerIcon_local_default, summonerIcon_local_default))
while True:
summonerIcon_local: str = logInput()
if summonerIcon_local == "":
summonerIcon_local = summonerIcon_local_default
elif summonerIcon_local[0] == "0":
logPrint("召唤师图标信息获取失败!请检查系统网络状况和代理设置。\nSummoner icon information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(summonerIcon_local, "r", encoding = "utf-8") as fp:
summonerIcon_initial = json.load(fp)
if isinstance(summonerIcon_initial, list) and all(map(lambda x: isinstance(x, dict), summonerIcon_initial)) and all(i in j for i in ["id", "title", "yearReleased", "isLegacy", "descriptions", "rarities", "disabledRegions"] for j in summonerIcon_initial):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的召唤师图标数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the summoner icon data archived in CommunityDragon database (%s)!" %(summonerIcon_url, summonerIcon_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的召唤师图标Json数据文件路径!\nFile "%s" NOT found! Please input a correct summoner icon Json data file path!' %(summonerIcon_local, summonerIcon_local))
except OSError:
logPrint("数据文件名不合法!请输入含有召唤师图标信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with summoner icon information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的召唤师图标数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the summoner icon data archived in CommunityDragon database (%s)!" %(summonerIcon_url, summonerIcon_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取基石符文信息(The following code get perk data)
try:
logPrint("正在加载基石符文信息……\nLoading perk information from CommunityDragon...")
source, status, session = requestUrl("GET", perk_url, session = session, log = log)
if source.ok:
perk_initial: list[dict[str, Any]] = source.json() #perk存储基石符文信息。(Variable `perk_initial` stores information of perks)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('基石符文信息获取超时!正在尝试离线加载数据……\nPerk information capture timeout! Trying loading offline data ...\n请输入基石符文Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the perk Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(perk_local_default, perk_local_default))
while True:
perk_local: str = logInput()
if perk_local == "":
perk_local = perk_local_default
elif perk_local[0] == "0":
logPrint("基石符文信息获取失败!请检查系统网络状况和代理设置。\nPerk information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(perk_local, "r", encoding = "utf-8") as fp:
perk_initial = json.load(fp)
if isinstance(perk_initial, list) and all(i in perk_initial[j] for i in ["id", "name", "majorChangePatchVersion", "tooltip", "shortDesc", "longDesc", "recommendationDescriptor", "iconPath", "endOfGameStatDescs", "recommendationDescriptorAttributes"] for j in range(len(perk_initial))):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的基石符文数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the perk data archived in CommunityDragon database (%s)!" %(perk_url, perk_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的基石符文Json数据文件路径!\nFile "%s" NOT found! Please input a correct perk Json data file path!' %(perk_local, perk_local))
except OSError:
logPrint("数据文件名不合法!请输入含有基石符文信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with perk information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的基石符文数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the perk data archived in CommunityDragon database (%s)!" %(perk_url, perk_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取符文系信息(The following code get perkstyle data)
try:
logPrint("正在加载符文系信息……\nLoading perkstyle information from CommunityDragon...")
source, status, session = requestUrl("GET", perkstyle_url, session = session, log = log)
if source.ok:
perkstyle_initial: dict[str, Any] = source.json() #perkstyle存储符文系信息。(Variable `perkstyle_initial` stores information of perkstyles)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('符文系信息获取超时!正在尝试离线加载数据……\nPerkstyle information capture timeout! Trying loading offline data ...\n请输入符文系Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the perkstyle Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(perkstyle_local_default, perkstyle_local_default))
while True:
perkstyle_local: str = logInput()
if perkstyle_local == "":
perkstyle_local = perkstyle_local_default
elif perkstyle_local[0] == "0":
logPrint("符文系信息获取失败!请检查系统网络状况和代理设置。\nperkstyle information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(perkstyle_local, "r", encoding = "utf-8") as fp:
perkstyle_initial = json.load(fp)
if isinstance(perkstyle_initial, dict) and all(perkstyle_initial.get(i, 0) for i in ["schemaVersion", "styles"]) and isinstance(perkstyle_initial["styles"], list) and all(j in perkstyle_initial["styles"][i] for i in range(len(perkstyle_initial["styles"])) for j in ["id", "name", "tooltip", "iconPath", "assetMap", "isAdvanced", "allowedSubStyles", "subStyleBonus", "slots", "defaultPageName", "defaultSubStyle", "defaultPerks", "defaultPerksWhenSplashed", "defaultStatModsPerSubStyle"]):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的符文系数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the perkstyle data archived in CommunityDragon database (%s)!" %(perkstyle_url, perkstyle_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的符文系Json数据文件路径!\nFile "%s" NOT found! Please input a correct perkstyle Json data file path!' %(perkstyle_local, perkstyle_local))
except OSError:
logPrint("数据文件名不合法!请输入含有符文系信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with perkstyle information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的符文系数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the perkstyle data archived in CommunityDragon database (%s)!" %(perkstyle_url, perkstyle_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取云顶之弈强化符文数据(The following code get TFT augment data)
try:
logPrint("正在加载云顶之弈基础数据……\nLoading TFT basic data from CommunityDragon ...")
source, status, session = requestUrl("GET", TFTBasic_url, session = session, log = log)
if source.ok:
TFTBasic_initial: dict[str, Any] = source.json() #TFT存储云顶之弈中至今为止所有的强化符文、英雄和羁绊信息和各赛季的英雄和羁绊信息(Variable `TFTBasic_initial` stores information of all augments, champions and traits so far and information of champions and traits with respect to season)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('云顶之弈基础信息获取超时!正在尝试离线加载数据……\nTFT basic information capture timeout! Trying loading offline data ...\n请输入云顶之弈基础数据Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the TFT basics Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(TFTBasic_local_default, TFTBasic_local_default))
while True:
TFTBasic_local: str = logInput()
if TFTBasic_local == "":
TFTBasic_local = TFTBasic_local_default
elif TFTBasic_local[0] == "0":
logPrint("云顶之弈基础信息获取失败!请检查系统网络状况和代理设置。\nTFT basic information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(TFTBasic_local, "r", encoding = "utf-8") as fp:
TFTBasic_initial = json.load(fp)
if isinstance(TFTBasic_initial, dict) and all(i in TFTBasic_initial for i in ["items", "setData", "sets"]) and all(isinstance(TFTBasic_initial[i], list) for i in ["items", "setData"]) and all(isinstance(TFTBasic_initial[i], dict) for i in ["sets"]) and all(j in TFTBasic_initial["items"][i] for i in range(len(TFTBasic_initial["items"])) for j in ["apiName", "associatedTraits", "composition", "desc", "effects", "from", "icon", "id", "incompatibleTraits", "name", "tags", "unique"]) and all(isinstance(TFTBasic_initial["items"][i][j], str) or TFTBasic_initial["items"][i][j] == None for i in range(len(TFTBasic_initial["items"])) for j in ["apiName", "desc", "icon", "name"]) and all(isinstance(TFTBasic_initial["items"][i][j], list) for i in range(len(TFTBasic_initial["items"])) for j in ["associatedTraits", "composition", "tags"]) and all(isinstance(TFTBasic_initial["items"][i][j], dict) for i in range(len(TFTBasic_initial["items"])) for j in ["effects"]) and all(isinstance(TFTBasic_initial["items"][i][j], bool) for i in range(len(TFTBasic_initial["items"])) for j in ["unique"]) and all(j in TFTBasic_initial["setData"][i] for i in range(len(TFTBasic_initial["setData"])) for j in ["augments", "champions", "items", "mutator", "name", "number", "traits"]) and all(isinstance(TFTBasic_initial["setData"][i][j], list) for i in range(len(TFTBasic_initial["setData"])) for j in ["augments", "champions", "items", "traits"]) and all(isinstance(TFTBasic_initial["setData"][i][j], str) for i in range(len(TFTBasic_initial["setData"])) for j in ["mutator", "name"]) and all(isinstance(TFTBasic_initial["setData"][i][j], int) for i in range(len(TFTBasic_initial["setData"])) for j in ["number"]) and all(map(lambda x: isinstance(x, str), TFTBasic_initial["setData"][i][j]) for i in range(len(TFTBasic_initial["setData"])) for j in ["augments", "items"]) and all(map(lambda x: isinstance(x, dict), TFTBasic_initial["setData"][i]["champions"]) for i in range(len(TFTBasic_initial["setData"]))) and all(k in TFTBasic_initial["setData"][i]["champions"][j] for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["champions"])) for k in ["ability", "apiName", "characterName", "cost", "icon", "name", "role", "squareIcon", "stats", "tileIcon", "traits"]) and all(isinstance(TFTBasic_initial["setData"][i]["champions"][j][k], dict) for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["champions"])) for k in ["ability", "stats"]) and all(isinstance(TFTBasic_initial["setData"][i]["champions"][j][k], str) or TFTBasic_initial["setData"][i]["champions"][j][k] == None for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["champions"])) for k in ["apiName", "characterName", "icon", "name", "squareIcon", "tileIcon"]) and all(isinstance(TFTBasic_initial["setData"][i]["champions"][j][k], int) for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["champions"])) for k in ["cost"]) and all(k in TFTBasic_initial["setData"][i]["champions"][j]["ability"] for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["champions"])) for k in ["desc", "icon", "name", "variables"]) and all(isinstance(TFTBasic_initial["setData"][i]["champions"][j]["ability"][k], str) or TFTBasic_initial["setData"][i]["champions"][j]["ability"][k] == None for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["champions"])) for k in ["desc", "icon", "name"]) and all(isinstance(TFTBasic_initial["setData"][i]["champions"][j]["ability"][k], list) for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["champions"])) for k in ["variables"]) and all(map(lambda x: isinstance(x, dict), TFTBasic_initial["setData"][i]["champions"][j]["ability"]["variables"]) for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["champions"]))) and all(l in TFTBasic_initial["setData"][i]["champions"][j]["ability"]["variables"][k] for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["champions"])) for k in range(len(TFTBasic_initial["setData"][i]["champions"][j]["ability"]["variables"])) for l in ["name", "value"]) and all(isinstance(TFTBasic_initial["setData"][i]["champions"][j]["ability"]["variables"][k][l], str) for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["champions"])) for k in range(len(TFTBasic_initial["setData"][i]["champions"][j]["ability"]["variables"])) for l in ["name"]) and all(isinstance(TFTBasic_initial["setData"][i]["champions"][j]["ability"]["variables"][k][l], list) or TFTBasic_initial["setData"][i]["champions"][j]["ability"]["variables"][k][l] == None for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["champions"])) for k in range(len(TFTBasic_initial["setData"][i]["champions"][j]["ability"]["variables"])) for l in ["value"]) and all(k in TFTBasic_initial["setData"][i]["traits"][j] for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["traits"])) for k in ["apiName", "desc", "effects", "icon", "name"]) and all(isinstance(TFTBasic_initial["setData"][i]["traits"][j][k], str) for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["traits"])) for k in ["apiName", "desc", "icon", "name"]) and all(isinstance(TFTBasic_initial["setData"][i]["traits"][j][k], list) for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["traits"])) for k in ["effects"]) and all(map(lambda x: isinstance(x, dict), TFTBasic_initial["setData"][i]["traits"][j]["effects"]) for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["traits"]))) and all(l in TFTBasic_initial["setData"][i]["traits"][j]["effects"][k] for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["traits"])) for k in range(len(TFTBasic_initial["setData"][i]["traits"][j]["effects"])) for l in ["maxUnits", "minUnits", "style", "variables"]) and all(isinstance(TFTBasic_initial["setData"][i]["traits"][j]["effects"][k][l], int) for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["traits"])) for k in range(len(TFTBasic_initial["setData"][i]["traits"][j]["effects"])) for l in ["maxUnits", "minUnits", "style"]) and all(isinstance(TFTBasic_initial["setData"][i]["traits"][j]["effects"][k][l], dict) for i in range(len(TFTBasic_initial["setData"])) for j in range(len(TFTBasic_initial["setData"][i]["traits"])) for k in range(len(TFTBasic_initial["setData"][i]["traits"][j]["effects"])) for l in ["variables"]) and all(j in TFTBasic_initial["sets"][i] for i in TFTBasic_initial["sets"] for j in ["champions", "name", "traits"]) and all(isinstance(TFTBasic_initial["sets"][i][j], list) for i in TFTBasic_initial["sets"] for j in ["champions", "traits"]) and all(isinstance(TFTBasic_initial["sets"][i][j], str) for i in TFTBasic_initial["sets"] for j in ["name"]) and all(k in TFTBasic_initial["sets"][i]["champions"][j] for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["champions"])) for k in ["ability", "apiName", "characterName", "cost", "icon", "name", "role", "squareIcon", "stats", "tileIcon", "traits"]) and all(isinstance(TFTBasic_initial["sets"][i]["champions"][j][k], dict) for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["champions"])) for k in ["ability", "stats"]) and all(isinstance(TFTBasic_initial["sets"][i]["champions"][j][k], str) or TFTBasic_initial["sets"][i]["champions"][j][k] == None for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["champions"])) for k in ["apiName", "characterName", "icon", "name", "squareIcon", "tileIcon"]) and all(isinstance(TFTBasic_initial["sets"][i]["champions"][j][k], int) for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["champions"])) for k in ["cost"]) and all(k in TFTBasic_initial["sets"][i]["champions"][j]["ability"] for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["champions"])) for k in ["desc", "icon", "name", "variables"]) and all(isinstance(TFTBasic_initial["sets"][i]["champions"][j]["ability"][k], str) or TFTBasic_initial["sets"][i]["champions"][j]["ability"][k] == None for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["champions"])) for k in ["desc", "icon", "name"]) and all(isinstance(TFTBasic_initial["sets"][i]["champions"][j]["ability"][k], list) for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["champions"])) for k in ["variables"]) and all(map(lambda x: isinstance(x, dict), TFTBasic_initial["sets"][i]["champions"][j]["ability"]["variables"]) for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["champions"]))) and all(l in TFTBasic_initial["sets"][i]["champions"][j]["ability"]["variables"][k] for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["champions"])) for k in range(len(TFTBasic_initial["sets"][i]["champions"][j]["ability"]["variables"])) for l in ["name", "value"]) and all(isinstance(TFTBasic_initial["sets"][i]["champions"][j]["ability"]["variables"][k][l], str) for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["champions"])) for k in range(len(TFTBasic_initial["sets"][i]["champions"][j]["ability"]["variables"])) for l in ["name"]) and all(isinstance(TFTBasic_initial["sets"][i]["champions"][j]["ability"]["variables"][k][l], list) or TFTBasic_initial["sets"][i]["champions"][j]["ability"]["variables"][k][l] == None for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["champions"])) for k in range(len(TFTBasic_initial["sets"][i]["champions"][j]["ability"]["variables"])) for l in ["value"]) and all(k in TFTBasic_initial["sets"][i]["traits"][j] for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["traits"])) for k in ["apiName", "desc", "effects", "icon", "name"]) and all(isinstance(TFTBasic_initial["sets"][i]["traits"][j][k], str) for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["traits"])) for k in ["apiName", "desc", "icon", "name"]) and all(isinstance(TFTBasic_initial["sets"][i]["traits"][j][k], list) for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["traits"])) for k in ["effects"]) and all(map(lambda x: isinstance(x, dict), TFTBasic_initial["sets"][i]["traits"][j]["effects"]) for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["traits"]))) and all(l in TFTBasic_initial["sets"][i]["traits"][j]["effects"][k] for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["traits"])) for k in range(len(TFTBasic_initial["sets"][i]["traits"][j]["effects"])) for l in ["maxUnits", "minUnits", "style", "variables"]) and all(isinstance(TFTBasic_initial["sets"][i]["traits"][j]["effects"][k][l], int) for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["traits"])) for k in range(len(TFTBasic_initial["sets"][i]["traits"][j]["effects"])) for l in ["maxUnits", "minUnits", "style"]) and all(isinstance(TFTBasic_initial["sets"][i]["traits"][j]["effects"][k][l], dict) for i in TFTBasic_initial["sets"] for j in range(len(TFTBasic_initial["sets"][i]["traits"])) for k in range(len(TFTBasic_initial["sets"][i]["traits"][j]["effects"])) for l in ["variables"]):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的云顶之弈基础数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the TFT basic data archived in CommunityDragon database (%s)!" %(TFTBasic_url, TFTBasic_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的云顶之弈基础信息Json数据文件路径!\nFile "%s" NOT found! Please input a correct TFT basics Json data file path!' %(TFTBasic_local, TFTBasic_local))
except OSError:
logPrint("数据文件名不合法!请输入含有云顶之弈基础信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with TFT basic information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的云顶之弈基础数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the TFT basic data archived in CommunityDragon database (%s)!" %(TFTBasic_url, TFTBasic_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取云顶之弈英雄数据(The following code get TFT champion data)
try:
logPrint("正在加载云顶之弈棋子信息……\nLoading TFT champion information from CommunityDragon ...")
source, status, session = requestUrl("GET", TFTChampion_url, session = session, log = log)
if source.ok:
TFTChampion_initial: list[dict[str, Any]] = source.json() #TFTChampion存储云顶之弈的棋子信息(Variable `TFTChampion_initial` stores information of TFT champions)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('云顶之弈英雄信息获取超时!正在尝试离线加载数据……\nTFT champion information capture timeout! Trying loading offline data ...\n请输入云顶之弈英雄Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the TFT champion Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(TFTChampion_local_default, TFTChampion_local_default))
while True:
TFTChampion_local: str = logInput()
if TFTChampion_local == "":
TFTChampion_local = TFTChampion_local_default
elif TFTChampion_local[0] == "0":
logPrint("云顶之弈英雄信息获取失败!请检查系统网络状况和代理设置。\nTFT champion information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(TFTChampion_local, "r", encoding = "utf-8") as fp:
TFTChampion_initial = json.load(fp)
if isinstance(TFTChampion_initial, list) and all(isinstance(TFTChampion_initial[i], dict) for i in range(len(TFTChampion_initial))) and all(TFTChampion_initial[i].get(j, 0) for i in range(len(TFTChampion_initial)) for j in ["name", "character_record"]):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的云顶之弈棋子数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the TFT champion data archived in CommunityDragon database (%s)!" %(TFTChampion_url, TFTChampion_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的云顶之弈棋子Json数据文件路径!\nFile "%s" NOT found! Please input a correct TFT champion Json data file path!' %(TFTChampion_local, TFTChampion_local))
except OSError:
logPrint("数据文件名不合法!请输入含有云顶之弈英雄信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with TFT champion information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的云顶之弈棋子数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the TFT champion data archived in CommunityDragon database (%s)!" %(TFTChampion_url, TFTChampion_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取云顶之弈装备数据(The following code get TFT item information)
try:
logPrint("正在加载云顶之弈装备信息……\nLoading TFT item information from CommunityDragon ...")
source, status, session = requestUrl("GET", TFTItem_url, session = session, log = log)
if source.ok:
TFTItem_initial: list[dict[str, Any]] = source.json() #TFTItem存储云顶之弈的装备信息(Variable `TFTItem_initial` stores information of TFT items)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('云顶之弈装备信息获取超时!正在尝试离线加载数据……\nTFT item information capture timeout! Trying loading offline data ...\n请输入云顶之弈装备Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the TFT item Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(TFTItem_local_default, TFTItem_local_default))
while True:
TFTItem_local: str = logInput()
if TFTItem_local == "":
TFTItem_local = TFTItem_local_default
elif TFTItem_local[0] == "0":
logPrint("云顶之弈装备信息获取失败!请检查系统网络状况和代理设置。\nTFT item information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(TFTItem_local, "r", encoding = "utf-8") as fp:
TFTItem_initial = json.load(fp)
if isinstance(TFTItem_initial, list) and all(isinstance(TFTItem_initial[i], dict) for i in range(len(TFTItem_initial))) and (all(j in TFTItem_initial[i] for i in range(len(TFTItem_initial)) for j in ["guid", "name", "nameId", "id", "color", "loadoutsIcon"]) or all(j in TFTItem_initial[i] for i in range(len(TFTItem_initial)) for j in ["guid", "name", "nameId", "id", "color", "squareIconPath"])):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的云顶之弈装备数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the TFT item data archived in CommunityDragon database (%s)!" %(TFTItem_url, TFTItem_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的云顶之弈装备Json数据文件路径!\nFile "%s" NOT found! Please input a correct TFT item Json data file path!' %(TFTItem_local, TFTItem_local))
except OSError:
logPrint("数据文件名不合法!请输入含有云顶之弈装备信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with TFT companion information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的云顶之弈装备数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the TFT item data archived in CommunityDragon database (%s)!" %(TFTItem_url, TFTItem_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取云顶之弈小小英雄数据(The following code get TFT companion data)
try:
logPrint("正在加载云顶之弈小小英雄信息……\nLoading companion information from CommunityDragon ...")
source, status, session = requestUrl("GET", TFTCompanion_url, session = session, log = log)
if source.ok:
TFTCompanion_initial: list[dict[str, Any]] = source.json() #TFTChampion存储云顶之弈的小小英雄信息(Variable `TFTChampion_initial` stores information of companions)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('云顶之弈小小英雄信息获取超时!正在尝试离线加载数据……\nTFT companion information capture timeout! Trying loading offline data ...\n请输入云顶之弈小小英雄Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the TFT companion Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(TFTCompanion_local_default, TFTCompanion_local_default))
while True:
TFTCompanion_local: str = logInput()
if TFTCompanion_local == "":
TFTCompanion_local = TFTCompanion_local_default
elif TFTCompanion_local[0] == "0":
logPrint("云顶之弈小小英雄信息获取失败!请检查系统网络状况和代理设置。\nTFT companion information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(TFTCompanion_local, "r", encoding = "utf-8") as fp:
TFTCompanion_initial = json.load(fp)
if isinstance(TFTCompanion_initial, list) and all(isinstance(TFTCompanion_initial[i], dict) for i in range(len(TFTCompanion_initial))) and all(j in TFTCompanion_initial[i] for i in range(len(TFTCompanion_initial)) for j in ["contentId", "itemId", "name", "loadoutsIcon", "description", "level", "speciesName", "speciesId", "rarity", "rarityValue", "isDefault", "upgrades", "TFTOnly"]):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的云顶之弈小小英雄数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the TFT companion data archived in CommunityDragon database (%s)!" %(TFTCompanion_url, TFTCompanion_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的云顶之弈小小英雄Json数据文件路径!\nFile "%s" NOT found! Please input a correct TFT companion Json data file path!' %(TFTCompanion_local, TFTCompanion_local))
except OSError:
logPrint("数据文件名不合法!请输入含有云顶之弈小小英雄信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with TFT companion information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的云顶之弈小小英雄数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the TFT companion data archived in CommunityDragon database (%s)!" %(TFTCompanion_url, TFTCompanion_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取云顶之弈羁绊数据(The following code get TFT trait data)
try:
logPrint("正在加载云顶之弈羁绊信息……\nLoading TFT trait information from CommunityDragon ...")
source, status, session = requestUrl("GET", TFTTrait_url, session = session, log = log)
if source.ok:
TFTTrait_initial: list[dict[str, Any]] = source.json() #TFTTrait存储云顶之弈的羁绊信息(Variable `TFTTrait_initial` stores information of TFT traits)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('云顶之弈羁绊信息获取超时!正在尝试离线加载数据……\nTFT trait information capture timeout! Trying loading offline data ...\n请输入云顶之弈羁绊Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the TFT trait Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(TFTTrait_local_default, TFTTrait_local_default))
while True:
TFTTrait_local: str = logInput()
if TFTTrait_local == "":
TFTTrait_local = TFTTrait_local_default
elif TFTTrait_local[0] == "0":
logPrint("云顶之弈羁绊信息获取失败!请检查系统网络状况和代理设置。\nTFT trait information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(TFTTrait_local, "r", encoding = "utf-8") as fp:
TFTTrait_initial = json.load(fp)
if isinstance(TFTTrait_initial, list) and all(isinstance(TFTTrait_initial[i], dict) for i in range(len(TFTTrait_initial))) and all(j in TFTTrait_initial[i] for i in range(len(TFTTrait_initial)) for j in ["display_name", "trait_id", "set", "icon_path", "tooltip_text", "innate_trait_sets", "conditional_trait_sets"]):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的云顶之弈羁绊数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the TFT trait data archived in CommunityDragon database (%s)!" %(TFTTrait_url, TFTTrait_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的云顶之弈羁绊Json数据文件路径!\nFile "%s" NOT found! Please input a correct TFT trait Json data file path!' %(TFTTrait_local, TFTTrait_local))
except OSError:
logPrint("数据文件名不合法!请输入含有云顶之弈小小英雄信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with TFT companion information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的云顶之弈羁绊数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the TFT trait data archived in CommunityDragon database (%s)!" %(TFTTrait_url, TFTTrait_url))
if switch_prepare_mode:
prepareMode = ""
continue
#下面获取斗魂竞技场强化符文数据(The following code get Arena augment data)
try:
logPrint("正在加载斗魂竞技场强化符文信息……\nLoading Arena augment information from CommunityDragon ...")
source, status, session = requestUrl("GET", CherryAugment_url, session = session, log = log)
if source.ok:
CherryAugment_initial: list[dict[str, Any]] = source.json() #Arena存储斗魂竞技场的强化符文信息(Variable `CherryAugment_initial` stores information of Arena augments)
else:
logPrint(source)
logPrint("当前语言不可用!请切换语言或检查源代码中的链接。\nCurrent language isn't available! Please change another language or check the requests link in the source code.")
switch_language = True
break
except requests.exceptions.RequestException:
logPrint('斗魂竞技场强化符文信息获取超时!正在尝试离线加载数据……\nArena augment information capture timeout! Trying loading offline data ...\n请输入斗魂竞技场强化符文Json数据文件路径。输入空字符以使用默认相对引用路径“%s”。输入“2”以转为离线模式。输入“0”以退出程序。\nPlease enter the Arena augment Json data file path. Enter an empty string to use the default relative path: "%s". Submit "2" to switch to offline mode. Submit "0" to exit.' %(CherryAugment_local_default, CherryAugment_local_default))
while True:
CherryAugment_local: str = logInput()
if CherryAugment_local == "":
CherryAugment_local = CherryAugment_local_default
elif CherryAugment_local[0] == "0":
logPrint("斗魂竞技场强化符文信息获取失败!请检查系统网络状况和代理设置。\nArena augment information capture failure! Please check the system network condition and proxy configuration.")
time.sleep(5)
return (switch_language, True)
else:
switch_prepare_mode = True
break
try:
with open(CherryAugment_local, "r", encoding = "utf-8") as fp:
CherryAugment_initial = json.load(fp)
if isinstance(CherryAugment_initial, list) and all(isinstance(CherryAugment_initial[i], dict) for i in range(len(CherryAugment_initial))) and all(j in CherryAugment_initial[i] for i in range(len(CherryAugment_initial)) for j in ["id", "nameTRA", "augmentSmallIconPath", "rarity"]) and all(isinstance(CherryAugment_initial[i]["id"], int) for i in range(len(CherryAugment_initial))) and all(isinstance(CherryAugment_initial[i]["nameTRA"], str) for i in range(len(CherryAugment_initial))) and all(isinstance(CherryAugment_initial[i]["augmentSmallIconPath"], str) for i in range(len(CherryAugment_initial))) and all(isinstance(CherryAugment_initial[i]["rarity"], str) for i in range(len(CherryAugment_initial))):
break
else:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的斗魂竞技场强化符文数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the Arena augment data archived in CommunityDragon database (%s)!" %(CherryAugment_url, CherryAugment_url))
except FileNotFoundError:
logPrint('未找到文件“%s”!请输入正确的斗魂竞技场强化符文Json数据文件路径!\nFile "%s" NOT found! Please input a correct Arena augment Json data file path!' %(CherryAugment_local, CherryAugment_local))
except OSError:
logPrint("数据文件名不合法!请输入含有斗魂竞技场强化符文信息的本地文件的路径!\nIllegal data filename! Please input the path of a local file with Arena augment information.")
except json.decoder.JSONDecodeError:
logPrint("数据格式错误!请选择一个符合CommunityDragon数据库中记录的斗魂竞技场强化符文数据格式(%s)的数据文件!\nData format mismatched! Please select a data file that corresponds to the format of the Arena augment data archived in CommunityDragon database (%s)!" %(CherryAugment_url, CherryAugment_url))
if switch_prepare_mode:
prepareMode = ""
continue
break
else:
switch_prepare_mode = False
logPrint('请在浏览器中打开以下网页,待加载完成后按Ctrl + S保存网页json文件至同目录的“离线数据(Offline Data)”文件夹下,并根据括号内的提示放置和命名文件。\nPlease open the following URLs in a browser, then press Ctrl + S to save the online json files into the folder "离线数据(Offline Data)" under the same directory after the website finishes loading and organize and rename the downloaded files according to the hints in the circle brackets.\n版本信息(%s): %s\n游戏模式(%s): %s\n召唤师技能(%s): %s\n英雄(%s): %s\n英雄联盟装备(%s): %s\n召唤师图标(%s): %s\n基石符文(%s): %s\n符文系(%s): %s\n云顶之弈基础信息(%s): %s\n云顶之弈棋子(%s): %s\n云顶之弈装备(%s): %s\n云顶之弈小小英雄(%s): %s\n云顶之弈羁绊(%s): %s\n斗魂竞技场强化符文(%s): %s' %(patches_local_default[19:], patches_url, queue_local_default[19:], queue_url, spell_local_default[19:], spell_url, LoLChampion_local_default[19:], LoLChampion_url, LoLItem_local_default[19:], LoLItem_url, summonerIcon_local_default[19:], summonerIcon_url, perk_local_default[19:], perk_url, perkstyle_local_default[19:], perkstyle_url, TFTBasic_local_default[19:], TFTBasic_url, TFTChampion_local_default[19:], TFTChampion_url, TFTItem_local_default[19:], TFTItem_url, TFTCompanion_local_default[19:], TFTCompanion_url, TFTTrait_local_default[19:], TFTTrait_url, CherryAugment_local_default[19:], CherryAugment_url))
offline_files_loaded: dict[str, bool] = {"patch": False, "queue": False, "spell": False, "LoLChampion": False, "LoLItem": False, "summonerIcon": False, "perk": False, "perkstyle": False, "TFT": False, "TFTChampion": False, "TFTItem": False, "TFTCompanion": False, "TFTTrait": False, "CherryAugment": False}
offline_files: dict[str, dict[str, str]] = {"patch": {"file": patches_local_default, "URL": patches_url, "content": "版本信息"}, "queue": {"file": queue_local_default, "URL": queue_url, "content": "游戏模式"}, "spell": {"file": spell_local_default, "URL": spell_url, "content": "召唤师技能"}, "LoLChampion": {"file": LoLChampion_local_default, "URL": LoLChampion_url, "content": "英雄"}, "LoLItem": {"file": LoLItem_local_default, "URL": LoLItem_url, "content": "英雄联盟装备"}, "summonerIcon": {"file": summonerIcon_local_default, "URL": summonerIcon_url, "content": "召唤师图标"}, "perk": {"file": perk_local_default, "URL": perk_url, "content": "基石符文"}, "perkstyle": {"file": perkstyle_local_default, "URL": perkstyle_url, "content": "符文系"}, "TFT": {"file": TFTBasic_local_default, "URL": TFTBasic_url, "content": "云顶之弈基础信息"}, "TFTChampion": {"file": TFTChampion_local_default, "URL": TFTChampion_url, "content": "云顶之弈英雄"}, "TFTItem": {"file": TFTItem_local_default, "URL": TFTItem_url, "content": "云顶之弈装备"}, "TFTCompanion": {"file": TFTCompanion_local_default, "URL": TFTCompanion_url, "content": "云顶之弈小小英雄"}, "TFTTrait": {"file": TFTTrait_local_default, "URL": TFTTrait_url, "content": "云顶之弈羁绊"}, "CherryAugment": {"file": CherryAugment_local_default, "URL": CherryAugment_url, "content": "斗魂竞技场强化符文"}}
logPrint('按回车键以加载离线数据。输入“1”以转为在线模式。输入“0”以退出程序。\nPress Enter to load offline data. Input "1" to switch to online mode. Submit "0" to exit.')
while any(not i for i in offline_files_loaded.values()):
offline_files_notfound: dict[str, bool] = {"patch": False, "queue": False, "spell": False, "LoLChampion": False, "LoLItem": False, "summonerIcon": False, "perk": False, "perkstyle": False, "TFT": False, "TFTChampion": False, "TFTItem": False, "TFTCompanion": False, "TFTTrait": False, "CherryAugment": False}
offline_files_formaterror: dict[str, bool] = {"patch": False, "queue": False, "spell": False, "LoLChampion": False, "LoLItem": False, "summonerIcon": False, "perk": False, "perkstyle": False, "TFT": False, "TFTChampion": False, "TFTItem": False, "TFTCompanion": False, "TFTTrait": False, "CherryAugment": False}
prepareMode = logInput()
if prepareMode != "" and prepareMode[0] == "1":
switch_prepare_mode = True
break
if prepareMode != "" and prepareMode[0] == "0":
return (switch_language, True)
#下面获取版本信息(The following code get the patch data)
if not offline_files_loaded["patch"]:
try:
with open(patches_local_default, "r", encoding = "utf-8") as fp:
patches_initial = json.load(fp)
if not (isinstance(patches_initial, list) and patches_initial[-1] == "lolpatch_3.7"): #之所以将patches的最后一个元素作为判断版本文件数据格式合法的依据,是因为按照这样的逻辑,代码在一般情况下就不需要频繁变动(The reason why I use the last element of the variable `patches_initial` as the judgment whether the patch file data format is legal is, that under this logic, the code won't need further adjustment as the update goes on)
offline_files_formaterror["patch"] = True
except FileNotFoundError:
offline_files_notfound["patch"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["patch"] = True
else:
if not offline_files_formaterror["patch"]:
offline_files_loaded["patch"] = True
latest_patch = patches_initial[0]
patches_dict = {}
smallPatches = []
bigPatches = []
for patch in patches_initial:
if not patch.startswith("lolpatch"):
patch_split = patch.split(".")
smallPatch = ".".join(patch_split[:3])
smallPatches.append(Patch(smallPatch))
bigPatch = ".".join(patch_split[:2])
bigPatches.append(Patch(bigPatch))
patches_dict[bigPatch] = []
for i in range(len(bigPatches)):
patches_dict[str(bigPatches[i])].append(str(smallPatches[i]))
#下面获取游戏模式数据(The following code get game mode data)
if not offline_files_loaded["queue"]:
try:
with open(queue_local_default, "r", encoding = "utf-8") as fp:
queue_initial = json.load(fp)
if not(isinstance(queue_initial, list) and all(map(lambda x: all(i in x for i in ["id", "name", "shortName", "description", "detailedDescription", "gameSelectModeGroup", "gameSelectCategory", "gameSelectPriority", "isSkillTreeQueue", "isLimitedTimeQueue", "isBotHonoringAllowed", "hidePlayerPosition", "viableChampionRoster"]), queue_initial)) and all(map(lambda x: all(isinstance(x[i], int) for i in ["id", "gameSelectPriority"]), queue_initial)) and all(map(lambda x: all(isinstance(x[i], str) for i in ["name", "shortName", "description", "detailedDescription", "gameSelectModeGroup", "gameSelectCategory"]), queue_initial)) and all(map(lambda x: all(isinstance(x[i], bool) for i in ["isSkillTreeQueue", "isLimitedTimeQueue", "isBotHonoringAllowed", "hidePlayerPosition"]), queue_initial)) and all(map(lambda x: all(isinstance(x[i], list) or x[i] is None for i in ["viableChampionRoster"]), queue_initial))):
offline_files_formaterror["queue"] = True
except FileNotFoundError:
offline_files_notfound["queue"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["queue"] = True
else:
if not offline_files_formaterror["queue"]:
offline_files_loaded["queue"] = True
#下面获取召唤师技能数据(The following code get summoner spell data)
if not offline_files_loaded["spell"]:
try:
with open(spell_local_default, "r", encoding = "utf-8") as fp:
spell_initial = json.load(fp)
if not(isinstance(spell_initial, list) and all(i in spell_initial[j] for i in ["id", "name", "description", "summonerLevel", "cooldown", "gameModes", "iconPath"] for j in range(len(spell_initial)))):
offline_files_formaterror["spell"] = True
except FileNotFoundError:
offline_files_notfound["spell"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["spell"] = True
else:
if not offline_files_formaterror["spell"]:
offline_files_loaded["spell"] = True
#下面获取英雄信息(The following code get LoL champion data)
if not offline_files_loaded["LoLChampion"]:
try:
with open(LoLChampion_local_default, "r", encoding = "utf-8") as fp:
LoLChampion_initial = json.load(fp)
if not(isinstance(LoLChampion_initial, list) and all(isinstance(LoLChampion_initial[i], dict) for i in range(len(LoLChampion_initial))) and all(j in LoLChampion_initial[i] for i in range(len(LoLChampion_initial)) for j in ["id", "name", "alias", "squarePortraitPath", "roles"]) and all(isinstance(LoLChampion_initial[i]["id"], int) for i in range(len(LoLChampion_initial))) and all(isinstance(LoLChampion_initial[i]["name"], str) for i in range(len(LoLChampion_initial))) and all(isinstance(LoLChampion_initial[i]["alias"], str) for i in range(len(LoLChampion_initial))) and all(isinstance(LoLChampion_initial[i]["squarePortraitPath"], str) for i in range(len(LoLChampion_initial))) and all(isinstance(LoLChampion_initial[i]["roles"], list) for i in range(len(LoLChampion_initial)))):
offline_files_formaterror["LoLChampion"] = True
except FileNotFoundError:
offline_files_notfound["LoLChampion"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["LoLChampion"] = True
else:
if not offline_files_formaterror["LoLChampion"]:
offline_files_loaded["LoLChampion"] = True
#下面获取英雄联盟装备信息(The following code get LoL item data)
if not offline_files_loaded["LoLItem"]:
try:
with open(LoLItem_local_default, "r", encoding = "utf-8") as fp:
LoLItem_initial = json.load(fp)
if not(isinstance(LoLItem_initial, list) and all(i in LoLItem_initial[j] for i in ["id", "name", "description", "active", "inStore", "from", "to", "categories", "maxStacks", "requiredChampion", "requiredAlly", "requiredBuffCurrencyName", "requiredBuffCurrencyCost", "specialRecipe", "isEnchantment", "price", "priceTotal", "iconPath"] for j in range(len(LoLItem_initial)))):
offline_files_formaterror["LoLItem"] = True
except FileNotFoundError:
offline_files_notfound["LoLItem"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["LoLItem"] = True
else:
if not offline_files_formaterror["LoLItem"]:
offline_files_loaded["LoLItem"] = True
#下面获取召唤师图标信息(The following code get summoner icon data)
if not offline_files_loaded["summonerIcon"]:
try:
with open(summonerIcon_local_default, "r", encoding = "utf-8") as fp:
summonerIcon_initial = json.load(fp)
if not(isinstance(summonerIcon_initial, list) and all(map(lambda x: isinstance(x, dict), summonerIcon_initial)) and all(i in j for i in ["id", "title", "yearReleased", "isLegacy", "descriptions", "rarities", "disabledRegions"] for j in summonerIcon_initial)):
offline_files_formaterror["summonerIcon"] = True
except FileNotFoundError:
offline_files_notfound["summonerIcon"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["summonerIcon"] = True
else:
if not offline_files_formaterror["summonerIcon"]:
offline_files_loaded["summonerIcon"] = True
#下面获取基石符文信息(The following code get perk data)
if not offline_files_loaded["perk"]:
try:
with open(perk_local_default, "r", encoding = "utf-8") as fp:
perk_initial = json.load(fp)
if not(isinstance(perk_initial, list) and all(i in perk_initial[j] for i in ["id", "name", "majorChangePatchVersion", "tooltip", "shortDesc", "longDesc", "recommendationDescriptor", "iconPath", "endOfGameStatDescs", "recommendationDescriptorAttributes"] for j in range(len(perk_initial)))):
offline_files_formaterror["perk"] = True
except FileNotFoundError:
offline_files_notfound["perk"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["perk"] = True
else:
if not offline_files_formaterror["perk"]:
offline_files_loaded["perk"] = True
#下面获取符文系信息(The following code get perkstyle data)
if not offline_files_loaded["perkstyle"]:
try:
with open(perkstyle_local_default, "r", encoding = "utf-8") as fp:
perkstyle_initial = json.load(fp)
if not(isinstance(perkstyle_initial, dict) and all(perkstyle_initial.get(i, 0) for i in ["schemaVersion", "styles"]) and isinstance(perkstyle_initial["styles"], list) and all(j in perkstyle_initial["styles"][i] for i in range(len(perkstyle_initial["styles"])) for j in ["id", "name", "tooltip", "iconPath", "assetMap", "isAdvanced", "allowedSubStyles", "subStyleBonus", "slots", "defaultPageName", "defaultSubStyle", "defaultPerks", "defaultPerksWhenSplashed", "defaultStatModsPerSubStyle"])):
offline_files_formaterror["perkstyle"] = True
except FileNotFoundError:
offline_files_notfound["perkstyle"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["perkstyle"] = True
else:
if not offline_files_formaterror["perkstyle"]:
offline_files_loaded["perkstyle"] = True
#下面获取云顶之弈强化符文数据(The following code get TFT augment data)
if not offline_files_loaded["TFT"]:
try:
with open(TFTBasic_local_default, "r", encoding = "utf-8") as fp:
TFTBasic_initial = json.load(fp)
if not(isinstance(TFTBasic_initial, dict) and all(i in TFTBasic_initial for i in ["items", "setData", "sets"])):
offline_files_formaterror["TFT"] = True
except FileNotFoundError:
offline_files_notfound["TFT"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["TFT"] = True
else:
if not offline_files_formaterror["TFT"]:
offline_files_loaded["TFT"] = True
#下面获取云顶之弈英雄数据(The following code get TFT champion data)
if not offline_files_loaded["TFTChampion"]:
try:
with open(TFTChampion_local_default, "r", encoding = "utf-8") as fp:
TFTChampion_initial = json.load(fp)
if not(isinstance(TFTChampion_initial, list) and all(isinstance(TFTChampion_initial[i], dict) for i in range(len(TFTChampion_initial))) and all(TFTChampion_initial[i].get(j, 0) for i in range(len(TFTChampion_initial)) for j in ["name", "character_record"])):
offline_files_formaterror["TFTChampion"] = True
except FileNotFoundError:
offline_files_notfound["TFTChampion"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["TFTChampion"] = True
else:
if not offline_files_formaterror["TFTChampion"]:
offline_files_loaded["TFTChampion"] = True
#下面获取云顶之弈装备数据(The following code get TFT item information)
if not offline_files_loaded["TFTItem"]:
try:
with open(TFTItem_local_default, "r", encoding = "utf-8") as fp:
TFTItem_initial = json.load(fp)
if not(isinstance(TFTItem_initial, list) and all(isinstance(TFTItem_initial[i], dict) for i in range(len(TFTItem_initial))) and (all(j in TFTItem_initial[i] for i in range(len(TFTItem_initial)) for j in ["guid", "name", "nameId", "id", "color", "loadoutsIcon"]) or all(j in TFTItem_initial[i] for i in range(len(TFTItem_initial)) for j in ["guid", "name", "nameId", "id", "color", "squareIconPath"]))):
offline_files_formaterror["TFTItem"] = True
except FileNotFoundError:
offline_files_notfound["TFTItem"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["TFTItem"] = True
else:
if not offline_files_formaterror["TFTItem"]:
offline_files_loaded["TFTItem"] = True
#下面获取云顶之弈小小英雄数据(The following code get TFT companion data)
if not offline_files_loaded["TFTCompanion"]:
try:
with open(TFTCompanion_local_default, "r", encoding = "utf-8") as fp:
TFTCompanion_initial = json.load(fp)
if not(isinstance(TFTCompanion_initial, list) and all(isinstance(TFTCompanion_initial[i], dict) for i in range(len(TFTCompanion_initial))) and all(j in TFTCompanion_initial[i] for i in range(len(TFTCompanion_initial)) for j in ["contentId", "itemId", "name", "loadoutsIcon", "description", "level", "speciesName", "speciesId", "rarity", "rarityValue", "isDefault", "upgrades", "TFTOnly"])):
offline_files_formaterror["TFTCompanion"] = True
except FileNotFoundError:
offline_files_notfound["TFTCompanion"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["TFTCompanion"] = True
else:
if not offline_files_formaterror["TFTCompanion"]:
offline_files_loaded["TFTCompanion"] = True
#下面获取云顶之弈羁绊数据(The following code get TFT trait data)
if not offline_files_loaded["TFTTrait"]:
try:
with open(TFTTrait_local_default, "r", encoding = "utf-8") as fp:
TFTTrait_initial = json.load(fp)
if not(isinstance(TFTTrait_initial, list) and all(isinstance(TFTTrait_initial[i], dict) for i in range(len(TFTTrait_initial))) and all(j in TFTTrait_initial[i] for i in range(len(TFTTrait_initial)) for j in ["display_name", "trait_id", "set", "icon_path", "tooltip_text", "innate_trait_sets", "conditional_trait_sets"])):
offline_files_formaterror["TFTTrait"] = True
except FileNotFoundError:
offline_files_notfound["TFTTrait"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["TFTTrait"] = True
else:
if not offline_files_formaterror["TFTTrait"]:
offline_files_loaded["TFTTrait"] = True
#下面获取斗魂竞技场强化符文数据(The following code get Arena augment data)
if not offline_files_loaded["CherryAugment"]:
try:
with open(CherryAugment_local_default, "r", encoding = "utf-8") as fp:
CherryAugment_initial = json.load(fp)
if not(isinstance(CherryAugment_initial, list) and all(isinstance(CherryAugment_initial[i], dict) for i in range(len(CherryAugment_initial))) and all(j in CherryAugment_initial[i] for i in range(len(CherryAugment_initial)) for j in ["id", "nameTRA", "augmentSmallIconPath", "rarity"]) and all(isinstance(CherryAugment_initial[i]["id"], int) for i in range(len(CherryAugment_initial))) and all(isinstance(CherryAugment_initial[i]["nameTRA"], str) for i in range(len(CherryAugment_initial))) and all(isinstance(CherryAugment_initial[i]["augmentSmallIconPath"], str) for i in range(len(CherryAugment_initial))) and all(isinstance(CherryAugment_initial[i]["rarity"], str) for i in range(len(CherryAugment_initial)))):
offline_files_formaterror["CherryAugment"] = True
except FileNotFoundError:
offline_files_notfound["CherryAugment"] = True
except json.decoder.JSONDecodeError:
offline_files_formaterror["CherryAugment"] = True
else:
if not offline_files_formaterror["CherryAugment"]:
offline_files_loaded["CherryAugment"] = True
#下面总结离线数据加载情况(The following code conclude the result of loading offline data)
unloaded_offline_files: list[str] = []
notfound_offline_files: list[str] = []
formaterror_offline_files: list[str] = []
if any(offline_files_notfound.values()):
for i in offline_files_notfound:
if offline_files_notfound[i]:
notfound_offline_files.append(i)
unloaded_offline_files.append(i)
logPrint("以下信息文件不存在:\nNot existing file(s):")
for i in notfound_offline_files:
logPrint(offline_files[i]["file"] + "\t" + offline_files[i]["content"] + "\t" + offline_files[i]["URL"])
if any(offline_files_formaterror.values()):
for i in offline_files_formaterror:
if offline_files_formaterror[i]:
formaterror_offline_files.append(i)
unloaded_offline_files.append(i)
logPrint("以下信息文件格式错误:\nFormatError file(s):")
for i in formaterror_offline_files:
logPrint(offline_files[i]["file"] + "\t" + offline_files[i]["content"] + "\t" + offline_files[i]["URL"])
if any(not i for i in offline_files_loaded.values()):
logPrint('按回车键以加载离线数据。输入“1”以转为在线模式。输入“0”以退出程序。\nPress Enter to load offline data. Input "1" to switch to online mode. Submit "0" to exit.')
if not switch_prepare_mode:
break
if not switch_language:
##准备游戏模式数据(Prepare game mode data)
queues_initial = {int(queue_iter["id"]): queue_iter for queue_iter in queue_initial}
##准备召唤师技能数据(Prepare summoner spell data)
spells_initial = {int(spell_iter["id"]): spell_iter for spell_iter in spell_initial}
##准备英雄数据(Prepare champion data)
LoLChampions_initial = {int(LoLChampion_iter["id"]): LoLChampion_iter for LoLChampion_iter in LoLChampion_initial}
##准备英雄联盟装备数据(Prapare LoL item data)
LoLItems_initial = {int(LoLItem_iter["id"]): LoLItem_iter for LoLItem_iter in LoLItem_initial}
##准备召唤师图标数据(Prepare summoner icon data)
summonerIcons_initial = {int(summonerIcon_iter["id"]): summonerIcon_iter for summonerIcon_iter in summonerIcon_initial}
##准备符文数据(Prepare runes data)
perks_initial = {int(perk_iter["id"]): perk_iter for perk_iter in perk_initial}
##准备符文系数据(Prepare perkstyle data)
perkstyles_initial = {int(perkstyle_iter["id"]): perkstyle_iter for perkstyle_iter in perkstyle_initial["styles"]}
##准备云顶之弈强化符文数据(Prepare TFT augment data)
TFTAugments_initial = {item["apiName"]: item for item in TFTBasic_initial["items"]}
##准备云顶之弈英雄数据(Prepare TFT champion data)
TFTChampions_initial = {TFTChampion_iter["name"]: TFTChampion_iter["character_record"] for TFTChampion_iter in TFTChampion_initial}
##准备云顶之弈装备数据(Prepare TFT item data)
TFTItems_initial = {TFTItem_iter["nameId"]: TFTItem_iter for TFTItem_iter in TFTItem_initial}
##准备云顶之弈小小英雄数据(Prepare TFT companion data)
TFTCompanions_initial = {companion_iter["contentId"]: companion_iter for companion_iter in TFTCompanion_initial}
##准备云顶之弈羁绊数据(Prepare TFT trait data)
TFTTraits_initial = {} #TFTTraits为嵌套字典,键为羁绊在LCU API上的表达形式,值为羁绊信息字典。一个键值对的示例如右:(Variable `TFTTraits` is a nested dictionary, whose keys are LCU API representation of traits and values are trait information dictionaries. An example of the key-value pairs is shown as follows: ){"Assassin": {"display_name": "刺客", "set": "TFTSet1", "icon_path": "/lol-game-data/assets/ASSETS/UX/TraitIcons/Trait_Icon_Assassin.png", "tooltip_text": "固有:在战斗环节开始时,刺客们会跃至距离最远的敌人处。<br><br>刺客们会获得额外的暴击伤害和暴击几率。<br><br><expandRow>(@MinUnits@) +@CritAmpPercent@%暴击伤害和+@CritChanceAmpPercent@%暴击几率</expandRow><br>", "innate_trait_sets": [], "conditional_trait_sets": {2: {"effect_amounts": [{"name": "CritAmpPercent", "value": 75.0, "format_string": ""}, {"name": "CritChanceAmpPercent", "value": 5.0, "format_string": ""}], "min_units": 3, "max_units": 5, "style_name": "kBronze"}, 3: {"effect_amounts": [{"name": "CritAmpPercent", "value": 150.0, "format_string": ""}, {"name": "CritChanceAmpPercent", "value": 20.0, "format_string": ""}], "min_units": 6, "max_units": 8, "style_name": "kSilver"}, 4: {"effect_amounts": [{"name": "CritAmpPercent", "value": 225.0, "format_string": ""}, {"name": "CritChanceAmpPercent", "value": 30.0, "format_string": ""}], "min_units": 9, "max_units": 25000, "style_name": "kGold"}}}}
for trait_iter in TFTTrait_initial:
trait_id: str = trait_iter["trait_id"]
conditional_trait_sets = {}
for conditional_trait_set in trait_iter["conditional_trait_sets"]:
style_idx: str = conditional_trait_set["style_idx"]
conditional_trait_sets[style_idx] = conditional_trait_set
trait_iter["conditional_trait_sets"] = conditional_trait_sets
TFTTraits_initial[trait_id] = trait_iter
##准备斗魂竞技场强化符文数据(Prepare Arena augment data)
CherryAugments_initial = {int(CherryAugment_iter["id"]): CherryAugment_iter for CherryAugment_iter in CherryAugment_initial}
return (switch_language, False)
async def prepare_lcu_plugins(connection: Connection) -> None:
'''
从LCU插件中读取实时数据资源。<br>Read real-time data resources from LCU plugin.
:param connection: 通过lcu-driver库创建的用于访问LCU API的连接对象。<br>A Connection object created through lcu-driver library, meant to access LCU API.
:type connection: Connection
'''
global wardSkins, championSkins
##饰品(Ward skin)
wardSkins_source: list[dict[str, Any]] = await (await connection.request("GET", "/lol-game-data/assets/v1/ward-skins.json")).json()
wardSkins = {wardSkin_iter["id"]: wardSkin_iter for wardSkin_iter in wardSkins_source}
##皮肤(Champion skin)
championSkins_source: dict[str, dict[str, Any]] = await (await connection.request("GET", "/lol-game-data/assets/v1/skins.json")).json()
championSkins = {}
for skin in championSkins_source.values():
championSkins[skin["id"]] = skin
if "chromas" in skin:
for chroma in skin["chromas"]:
championSkins[chroma["id"]] = chroma