-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
2009 lines (1705 loc) · 112 KB
/
gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
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 random
from ruamel.yaml import YAML
import os
import requests
from datetime import datetime
import tkinter as tk
from tkinter import messagebox, scrolledtext, StringVar, Toplevel, Label, Button, Entry, Listbox, END, BooleanVar, font, ttk, simpledialog, PhotoImage
from PIL import Image, ImageTk
import re
import sys
import base64
import io
# from ttkthemes import ThemedTk
# Colors and other constants
PURPLE = '#BA55D3'
GOLD = '#FFD700'
GREEN = '#32CD32'
RED = '#FF4500'
RESET = '#FFFFFF'
CYAN = '#00CED1'
YELLOW = '#FFFF00'
BLUE = '#1E90FF'
CHARACTER_DISPLAY_NAME = '角色'
WEAPON_DISPLAY_NAME = '光锥'
BANNER_FILE = 'banners.yml'
GITHUB_PROXY = 'https://mirror.ghproxy.com'
BANNER_DOWNLOAD_URL = "https://raw.githubusercontent.com/qiusyan-projects/SR-Gacha/main/banners.yml"
TIPS = [
"大保底时,下一个5星角色必定是UP角色。",
"每10次抽卡必定至少有一个4星或以上角色/光锥。",
"这个Tip我还没想好怎么写...",
"你说得对,但是...",
"来点Star叭!",
"这是一个小Tip,只有聪明人才能看到它的内容",
"可以修改卡池文件来实现其他游戏的抽卡效果",
"本来我是想整个主题的,但是好像加上之后会变得很卡我就删了",
"你看什么看!",
"双击抽卡记录可以查看物品的详细信息",
"双击卡池可以查看卡池的信息",
"角色池的保底和概率跟光锥池的都不一样",
"可以通过修改抽卡概率来达成任意抽卡效果"
]
yaml = YAML()
class GachaSimulatorGUI:
def __init__(self, root):
self.root = root
self.root.withdraw() # 隐藏主窗口
self.root.title("崩坏:星穹铁道抽卡模拟器")
self.root.geometry("1200x800")
self.root.minsize(900, 600) # 设置最小窗口大小
# 设置默认字体为微软雅黑
self.default_font_name = 'Microsoft YaHei'
self.default_font = (self.default_font_name, 10)
self.large_font = (self.default_font_name, 14)
# 检查更新
self.check_for_updates()
self.character_five_star_small_pity_var_random = BooleanVar()
self.character_five_star_small_pity_var_must_waste = BooleanVar()
self.character_five_star_small_pity_var_must_not_waste = BooleanVar()
self.weapon_five_star_small_pity_var_random = BooleanVar()
self.weapon_five_star_small_pity_var_must_waste = BooleanVar()
self.weapon_five_star_small_pity_var_must_not_waste = BooleanVar()
self.character_four_star_small_pity_var_random = BooleanVar()
self.character_four_star_small_pity_var_must_waste = BooleanVar()
self.character_four_star_small_pity_var_must_not_waste = BooleanVar()
self.weapon_four_star_small_pity_var_random = BooleanVar()
self.weapon_four_star_small_pity_var_must_waste = BooleanVar()
self.weapon_four_star_small_pity_var_must_not_waste = BooleanVar()
# 初始化主题选择
# self.setup_theme_selection()
# 确保 GachaSystem 已正确初始化
if not hasattr(self.gacha_system, 'pools'):
messagebox.showerror("错误", "无法加载卡池数据。请重新启动程序。")
sys.exit(1)
# 初始化其他GUI组件
self.initialize_gui_components()
# 显示主窗口
self.root.deiconify()
def check_for_updates(self):
if os.path.exists(BANNER_FILE):
check_update = messagebox.askyesno("更新确认", "是否检查卡池文件更新?(修改卡池了的不要选更新)")
no_update = not check_update
else:
no_update = False # 如果文件不存在,强制更新
self.gacha_system = GachaSystem(BANNER_FILE, no_update=no_update)
def initialize_gui_components(self):
self.banner_id_map = {}
self.banner_name_map = {}
self.initialize_banner_maps()
self.setup_gui()
def initialize_banner_maps(self):
character_banners, weapon_banners = self.gacha_system.categorize_banners()
all_banners = character_banners + weapon_banners
# print("初始化 banner_id_map:") # 调试信息
for banner_id, banner_name in all_banners:
self.banner_id_map[banner_name] = banner_id
self.banner_name_map[banner_id] = banner_name
# print(f" {banner_name} -> {banner_id}") # 调试信息
# print("banner_id_map 内容:") # 调试信息
# for name, id in self.banner_id_map.items():
# print(f" {name}: {id}") # 调试信息
def setup_gui(self):
# Create main frame
self.main_frame = ttk.Frame(self.root)
self.main_frame.pack(fill=tk.BOTH, expand=1)
# Create left and right frames
self.left_frame = ttk.Frame(self.main_frame, width=250)
self.right_frame = ttk.Frame(self.main_frame)
# Pack frames
self.left_frame.pack(side=tk.LEFT, fill=tk.Y, padx=5, pady=5)
self.right_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5)
# Ensure the left frame maintains its width
self.left_frame.pack_propagate(False)
# Left frame content
self.setup_left_frame()
# Right frame content
self.setup_right_frame()
def setup_left_frame(self):
# Banner controls
banner_frame = ttk.LabelFrame(self.left_frame, text="卡池切换")
banner_frame.pack(pady=2, padx=5, fill=tk.X)
self.toggle_button = ttk.Button(banner_frame, text=f"切换到{WEAPON_DISPLAY_NAME}池列表", command=self.toggle_banner_type)
self.toggle_button.grid(row=0, column=0, pady=2, padx=2, sticky="ew")
self.standard_banner_button = ttk.Button(banner_frame, text="切换到常驻池", command=self.select_standard_banner)
self.standard_banner_button.grid(row=0, column=1, pady=2, padx=2, sticky="ew")
self.banner_listbox = tk.Listbox(banner_frame, height=8, font=self.default_font)
self.banner_listbox.grid(row=1, column=0, columnspan=2, pady=2, padx=2, sticky="nsew")
self.switch_banner_button = ttk.Button(banner_frame, text="切换到选择的卡池", command=self.on_switch_banner)
self.switch_banner_button.grid(row=2, column=0, columnspan=2, pady=2, padx=2, sticky="ew")
banner_frame.columnconfigure(0, weight=1)
banner_frame.columnconfigure(1, weight=1)
# Gacha controls
gacha_frame = ttk.LabelFrame(self.left_frame, text="抽卡")
gacha_frame.pack(pady=2, padx=5, fill=tk.X)
self.pull_1_button = ttk.Button(gacha_frame, text="抽一次", command=lambda: self.on_pull(1))
self.pull_1_button.grid(row=0, column=0, pady=2, padx=2, sticky="ew")
self.pull_10_button = ttk.Button(gacha_frame, text="十连抽!", command=lambda: self.on_pull(10))
self.pull_10_button.grid(row=0, column=1, pady=2, padx=2, sticky="ew")
self.pull_pity_button = ttk.Button(gacha_frame, text="抽一个小保底", command=lambda: self.on_pull(self.get_current_pity()))
self.pull_pity_button.grid(row=1, column=0, columnspan=2, pady=2, padx=2, sticky="ew")
gacha_frame.columnconfigure(0, weight=1)
gacha_frame.columnconfigure(1, weight=1)
# Utility controls
util_frame = ttk.LabelFrame(self.left_frame, text="工具箱")
util_frame.pack(pady=2, padx=5, fill=tk.X)
self.random_tip_button = ttk.Button(util_frame, text="随机Tips", command=self.show_random_tip)
self.random_tip_button.grid(row=0, column=0, pady=2, padx=2, sticky="ew")
self.clear_data_button = ttk.Button(util_frame, text="修改当前卡池概率", command=self.open_probability_settings)
self.clear_data_button.grid(row=0, column=1, pady=2, padx=2, sticky="ew")
self.prob_settings_button = ttk.Button(util_frame, text="重置抽卡统计数据", command=self.clear_gacha_data)
self.prob_settings_button.grid(row=2, column=0, columnspan=2, pady=2, padx=2, sticky="ew")
self.version_button = ttk.Button(util_frame, text="查看当前版本", command=self.show_version)
self.version_button.grid(row=1, column=0, pady=2, padx=2, sticky="ew")
self.update_button = ttk.Button(util_frame, text="检查卡池更新", command=self.check_pool_update)
self.update_button.grid(row=1, column=1, pady=2, padx=2, sticky="ew")
util_frame.columnconfigure(0, weight=1)
util_frame.columnconfigure(1, weight=1)
# Statistics display
self.stats_frame = ttk.LabelFrame(self.left_frame, text="统计信息")
self.stats_frame.pack(pady=2, padx=5, fill=tk.X)
self.current_stats_label = ttk.Label(self.stats_frame, text="当前显示的是角色池的数据", font=self.default_font)
self.current_stats_label.pack(pady=2)
self.current_banner_type = StringVar(value="character")
self.stats_text = tk.Text(self.stats_frame, width=25, font=self.default_font, wrap=tk.WORD)
self.stats_text.pack(fill=tk.X, expand=True)
self.stats_text.config(state=tk.DISABLED)
# 将双击指令绑定到Listbox
self.banner_listbox.bind("<Double-1>", self.show_banner_details)
self.update_banner_list()
self.update_stats_display()
def setup_right_frame(self):
# Banner info frame
banner_info_frame = ttk.Frame(self.right_frame)
banner_info_frame.pack(fill=tk.X, pady=10, padx=10)
self.banner_label_var = StringVar()
self.banner_label = ttk.Label(banner_info_frame, textvariable=self.banner_label_var, font=self.large_font)
self.banner_label.pack(side=tk.LEFT)
self.clear_history_button = ttk.Button(banner_info_frame, text="清空抽卡记录", command=self.clear_pull_history)
self.clear_history_button.pack(side=tk.RIGHT)
# Pull history frame
history_frame = ttk.LabelFrame(self.right_frame, text="抽卡历史")
history_frame.pack(pady=10, padx=10, fill=tk.BOTH, expand=True)
# Pull history table
columns = ('时间', '星级', '类型', '名称', '卡池', '是否UP')
self.pull_history_tree = ttk.Treeview(history_frame, columns=columns, show='headings')
# Define column headings and widths
column_widths = {'时间': 150, '星级': 50, '类型': 50, '名称': 150, '卡池': 150, '是否UP': 50}
for col in columns:
self.pull_history_tree.heading(col, text=col, anchor='center')
self.pull_history_tree.column(col, width=column_widths[col], anchor='center')
# Add vertical scrollbar
vsb = ttk.Scrollbar(history_frame, orient="vertical", command=self.pull_history_tree.yview)
self.pull_history_tree.configure(yscrollcommand=vsb.set)
# Add horizontal scrollbar
hsb = ttk.Scrollbar(history_frame, orient="horizontal", command=self.pull_history_tree.xview)
self.pull_history_tree.configure(xscrollcommand=hsb.set)
# Grid layout for Treeview and scrollbars
self.pull_history_tree.grid(row=0, column=0, sticky='nsew')
vsb.grid(row=0, column=1, sticky='ns')
hsb.grid(row=1, column=0, sticky='ew')
history_frame.grid_rowconfigure(0, weight=1)
history_frame.grid_columnconfigure(0, weight=1)
# Tips frame
tips_frame = ttk.LabelFrame(self.right_frame, text="Tips")
tips_frame.pack(pady=10, padx=10, fill=tk.X)
self.tip_label = ttk.Label(tips_frame, text="", font=self.default_font, foreground="blue", wraplength=500)
self.tip_label.pack(pady=5, padx=5)
self.update_gui_banner_name()
self.show_random_tip()
# Bind double click event to Treeview for item details
self.pull_history_tree.bind("<Double-1>", self.show_item_details)
def toggle_banner_type(self):
if self.current_banner_type.get() == "character":
self.current_banner_type.set("weapon")
self.toggle_button.config(text=f"切换到{CHARACTER_DISPLAY_NAME}池列表")
else:
self.current_banner_type.set("character")
self.toggle_button.config(text=f"切换到{WEAPON_DISPLAY_NAME}池列表")
self.update_banner_list()
def select_standard_banner(self):
standard_banner = self.gacha_system.get_standard_banner()
if standard_banner:
if self.gacha_system.switch_banner(standard_banner):
banner_info = self.gacha_system.pools['banners'].get(standard_banner, {})
banner_name = banner_info.get('name', standard_banner)
self.update_gui_banner_name()
self.update_banner_list()
self.update_stats_display('standard')
messagebox.showinfo("提示", f"已切换到常驻池:{banner_name}")
else:
messagebox.showerror("错误", f"切换到常驻池失败")
else:
messagebox.showinfo("提示", "未找到常驻池")
def update_banner_list(self):
self.banner_listbox.delete(0, tk.END)
character_banners, weapon_banners = self.gacha_system.categorize_banners()
banners_to_show = character_banners if self.current_banner_type.get() == "character" else weapon_banners
for banner_id, banner_name in banners_to_show:
banner_info = self.gacha_system.pools['banners'][banner_id]
if 'character_up_5_star' in banner_info:
up_character = banner_info['character_up_5_star'][0]
display_name = f"{banner_name} - UP: {up_character}"
elif 'weapon_up_5_star' in banner_info:
up_weapon = banner_info['weapon_up_5_star'][0]
display_name = f"{banner_name} - UP: {up_weapon}"
else:
display_name = banner_name
self.banner_listbox.insert(tk.END, display_name)
if self.gacha_system.current_banner is not None and banner_id == self.gacha_system.current_banner:
self.banner_listbox.selection_set(tk.END)
def on_switch_banner(self):
# print("开始切换卡池...") # 调试信息
selected_indices = self.banner_listbox.curselection()
# print(f"选中的索引: {selected_indices}") # 调试信息
if not selected_indices:
messagebox.showinfo("提示", "你还没有选择一个卡池")
return
selected_banner_display_name = self.banner_listbox.get(selected_indices[0])
selected_banner_name = selected_banner_display_name.split(" - UP:")[0]
selected_banner_id = self.banner_id_map.get(selected_banner_name)
# print(f"选中的卡池ID: {selected_banner_id}") # 调试信息
if selected_banner_id:
if self.gacha_system.switch_banner(selected_banner_id):
self.update_banner_list()
self.update_gui_banner_name()
# 获取新卡池的类型并更新统计显示
new_pool_type = self.gacha_system.pools['banners'][selected_banner_id].get('pool_type', 'standard')
self.update_stats_display(new_pool_type)
banner_info = self.gacha_system.pools['banners'].get(selected_banner_id, {})
banner_name = banner_info.get('name', selected_banner_name)
messagebox.showinfo("提示", f"已切换到卡池:{banner_name}")
else:
messagebox.showerror("错误", f"切换到卡池 {selected_banner_name} 失败")
else:
messagebox.showerror("错误", f"未找到卡池 {selected_banner_name} 的ID")
self.update_stats_display()
def show_banner_details(self, event):
# 获取双击事件中的选中项
selected_index = event.widget.nearest(event.y)
selected_banner_display_name = self.banner_listbox.get(selected_index)
# 从显示名称中提取卡池名称(去除UP信息)
selected_banner_name = selected_banner_display_name.split(" - UP:")[0]
# 通过卡池名称获取卡池ID
selected_banner_id = self.banner_id_map.get(selected_banner_name)
# 使用卡池ID获取卡池详细信息
if selected_banner_id:
banner_info = self.gacha_system.pools['banners'].get(selected_banner_id, {})
else:
banner_info = {}
# 根据卡池类型确定显示的文本
pool_type = banner_info.get('pool_type', 'standard') # 默认为'standard',如果未指定类型
pool_type_display = WEAPON_DISPLAY_NAME if pool_type == 'weapon' else CHARACTER_DISPLAY_NAME
# 获取UP的五星和四星项目信息
up_5_star_key = f'{pool_type}_up_5_star'
up_4_star_key = f'{pool_type}_up_4_star'
up_5_star_info = banner_info.get(up_5_star_key, [])
up_4_star_info = banner_info.get(up_4_star_key, [])
# 构造详细信息字符串
details = f"卡池名称: {banner_info.get('name', '未知')}\n" \
f"卡池类型: {pool_type_display}\n" \
f"UP的五星{pool_type_display}: {' | '.join(up_5_star_info) if up_5_star_info else '无'}\n" \
f"UP的四星{pool_type_display}: {' | '.join(up_4_star_info) if up_4_star_info else '无'}"
# 显示详细信息
messagebox.showinfo("卡池详情", details)
def on_pull(self, num_pulls):
pulls = self.gacha_system.perform_pull(num_pulls)
if pulls:
self.update_gui_pull_history(pulls)
self.gacha_system.save_state()
# 获取当前卡池类型并更新统计显示
current_pool_type = self.gacha_system.pools['banners'][self.gacha_system.current_banner].get('pool_type', 'standard')
self.update_stats_display(current_pool_type)
def show_random_tip(self):
self.tip_label.config(text=random.choice(self.gacha_system.TIPS))
def update_gui_banner_name(self):
if self.gacha_system.current_banner:
banner_info = self.gacha_system.pools['banners'].get(self.gacha_system.current_banner, {})
banner_name = banner_info.get('name', self.gacha_system.current_banner)
self.banner_label_var.set(f"当前卡池: {banner_name}")
else:
self.banner_label_var.set("当前卡池: 未选择")
def update_gui_pull_history(self, pulls):
current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
current_banner_info = self.gacha_system.pools['banners'].get(self.gacha_system.current_banner, {})
current_banner_name = current_banner_info.get('name', self.gacha_system.current_banner)
is_standard_banner = current_banner_info.get('pool_type') == 'standard'
for rarity, item_type, item in pulls:
# Convert rarity to display format
display_rarity = rarity.replace('_star', '星')
tag = display_rarity.split('星')[0] # '5星' becomes '5'
# Determine if it's an UP item
is_up = "否"
if not is_standard_banner and rarity in ['4_star', '5_star']:
up_items = current_banner_info.get(f"{item_type}_up_{rarity}", [])
if not up_items and item_type == CHARACTER_DISPLAY_NAME:
up_items = current_banner_info.get(f"character_up_{rarity}", [])
elif not up_items and item_type == WEAPON_DISPLAY_NAME:
up_items = current_banner_info.get(f"weapon_up_{rarity}", [])
is_up = "是" if item in up_items else "否"
# For 3-star items and standard banner pulls, leave the UP column empty
if rarity == '3_star' or is_standard_banner:
is_up = ""
self.pull_history_tree.insert('', 0, values=(current_time, display_rarity, item_type, item, current_banner_name, is_up), tags=(tag,))
# Set tag colors
self.pull_history_tree.tag_configure('5', foreground='gold')
self.pull_history_tree.tag_configure('4', foreground='purple')
def clear_gacha_data(self):
confirm = messagebox.askyesno("确认", "您确定要清除所有抽卡统计数据吗?此操作不可逆。")
if confirm:
second_confirm = messagebox.askyesno("二次确认", "真的要清除所有数据吗?这将重置所有统计信息。")
if second_confirm:
self.gacha_system.reset_statistics()
self.update_stats_display() # Update stats after clearing data
messagebox.showinfo("成功", "所有抽卡统计数据已被清除。")
def clear_pull_history(self):
confirm = messagebox.askyesno("确认", "您确定要清空抽卡记录吗?此操作不可逆。")
if confirm:
self.pull_history_tree.delete(*self.pull_history_tree.get_children())
self.gacha_system.pull_history = []
self.gacha_system.save_state()
messagebox.showinfo("成功", "抽卡记录已清空。")
def update_stats_display(self, pool_type=None):
if pool_type is None:
if self.gacha_system.current_banner:
banner_info = self.gacha_system.pools['banners'].get(self.gacha_system.current_banner, {})
pool_type = banner_info.get('pool_type', 'standard')
else:
pool_type = 'standard'
if pool_type == 'character':
pity_5 = self.gacha_system.character_pity_5
pity_4 = self.gacha_system.character_pity_4
gold_records = self.gacha_system.character_gold_records
purple_records = self.gacha_system.character_purple_records
failed_featured_5star = self.gacha_system.character_failed_featured_5star
successful_featured_5star = self.gacha_system.character_successful_featured_5star
pulls_since_last_5star = self.gacha_system.character_pulls_since_last_5star
is_guaranteed = self.gacha_system.character_is_guaranteed
stats_type = f"{CHARACTER_DISPLAY_NAME}池"
pool_pulls = self.gacha_system.character_pulls
five_star_pity = self.gacha_system.current_prob['character_five_star_pity']
four_star_pity = self.gacha_system.current_prob['character_four_star_pity']
five_star_small_pity_mechanism = self.gacha_system.current_prob['character_five_star_small_pity_mechanism']
four_star_small_pity_mechanism = self.gacha_system.current_prob['character_four_star_small_pity_mechanism']
five_star_big_pity_enabled = self.gacha_system.current_prob['character_five_star_big_pity_enabled']
four_star_big_pity_enabled = self.gacha_system.current_prob['character_four_star_big_pity_enabled']
four_star_guaranteed = self.gacha_system.character_four_star_guaranteed
elif pool_type == 'weapon':
pity_5 = self.gacha_system.weapon_pity_5
pity_4 = self.gacha_system.weapon_pity_4
gold_records = self.gacha_system.weapon_gold_records
purple_records = self.gacha_system.weapon_purple_records
failed_featured_5star = self.gacha_system.weapon_failed_featured_5star
successful_featured_5star = self.gacha_system.weapon_successful_featured_5star
pulls_since_last_5star = self.gacha_system.weapon_pulls_since_last_5star
is_guaranteed = self.gacha_system.weapon_is_guaranteed
stats_type = f"{WEAPON_DISPLAY_NAME}池"
pool_pulls = self.gacha_system.weapon_pulls
five_star_pity = self.gacha_system.current_prob['weapon_five_star_pity']
four_star_pity = self.gacha_system.current_prob['weapon_four_star_pity']
five_star_small_pity_mechanism = self.gacha_system.current_prob['weapon_five_star_small_pity_mechanism']
four_star_small_pity_mechanism = self.gacha_system.current_prob['weapon_four_star_small_pity_mechanism']
five_star_big_pity_enabled = self.gacha_system.current_prob['weapon_five_star_big_pity_enabled']
four_star_big_pity_enabled = self.gacha_system.current_prob['weapon_four_star_big_pity_enabled']
four_star_guaranteed = self.gacha_system.weapon_four_star_guaranteed
else:
pity_5 = self.gacha_system.pity_5
pity_4 = self.gacha_system.pity_4
gold_records = self.gacha_system.gold_records
purple_records = self.gacha_system.purple_records
failed_featured_5star = self.gacha_system.failed_featured_5star
successful_featured_5star = self.gacha_system.successful_featured_5star
pulls_since_last_5star = self.gacha_system.pulls_since_last_5star
is_guaranteed = self.gacha_system.is_guaranteed
stats_type = "常驻池"
pool_pulls = self.gacha_system.standard_pulls
five_star_pity = self.gacha_system.current_prob['standard_five_star_pity']
four_star_pity = self.gacha_system.current_prob['standard_four_star_pity']
five_star_big_pity_enabled = True
four_star_big_pity_enabled = True
four_star_guaranteed = self.gacha_system.four_star_guaranteed
luck_rating = self.gacha_system.calculate_luck(pool_type)
self.current_stats_label.config(text=f"当前显示的是{stats_type}的数据")
if len(gold_records) > 0: # 如果出金次数大于1,执行计算
avg_gold_pulls = sum(gold_records) / len(gold_records) # 平均抽数出金
else:
avg_gold_pulls = "暂无数据"
if gold_records: # 如果列表不为空
min_gold_records = min(gold_records)
max_gold_records = max(gold_records)
else:
min_gold_records = "暂无数据"
max_gold_records = "暂无数据"
total_featured_5star = successful_featured_5star + failed_featured_5star
if total_featured_5star > 0: # 如果总数大于0
success_rate = successful_featured_5star / total_featured_5star * 100
else:
success_rate = "暂无数据"
pool_pulls_str = f"{stats_type}的抽取次数: {pool_pulls}"
next_pity_5_str = f"距离下一个5星保底的抽数: {five_star_pity - pity_5}"
next_pity_4_str = f"距离下一个4星保底: {four_star_pity - pity_4}"
get_gold_records_str = f"获得5星次数: {len(gold_records)}"
get_purple_records_str = f"获得4星次数: {len(purple_records)}"
min_gold_records_str = f"最少抽数出金: {min_gold_records}"
max_gold_records_str = f"最多抽数出金: {max_gold_records}"
if isinstance(avg_gold_pulls, (int, float)): # 检查 avg_gold_pulls 是否是数字类型
avg_gold_pulls_str = f"平均出金抽数: {avg_gold_pulls:.2f}"
else:
avg_gold_pulls_str = f"平均出金抽数: {avg_gold_pulls}"
if pool_type != 'standard':
failed_featured_5star_str = f"歪掉5星次数: {failed_featured_5star}"
else:
failed_featured_5star_str = f"歪掉5星次数: 无"
if pool_type != 'standard':
if isinstance(success_rate, (int, float)): # 检查 success_rate 是否是数字类型
success_rate_str = f"小保底不歪概率: {success_rate:.2f}%"
else:
success_rate_str = f"小保底不歪概率: {success_rate}"
else:
success_rate_str = f"小保底不歪概率: 无"
pulls_since_last_5star_str = f"距离上次5星: {pulls_since_last_5star}"
if five_star_big_pity_enabled:
if pool_type != 'standard':
five_star_is_guaranteed_str = f"5星大保底状态: {'是' if is_guaranteed else '否'}"
else:
five_star_is_guaranteed_str = f"5星大保底状态: 无"
else:
five_star_is_guaranteed_str = f"5星大保底状态: 你没有启用大保底机制"
if four_star_big_pity_enabled:
if pool_type != 'standard':
four_star_guaranteed_str = f"4星大保底状态: {'是' if four_star_guaranteed else '否'}"
else:
four_star_guaranteed_str = f"4星大保底状态: 无"
else:
four_star_guaranteed_str = f"4星大保底状态: 你没有启用大保底机制"
if pool_type != 'standard':
if five_star_small_pity_mechanism == 'random':
five_star_small_pity_mechanism_str = f"5星小保底机制: 默认"
elif five_star_small_pity_mechanism == 'must_not_waste':
five_star_small_pity_mechanism_str = f"5星小保底机制: 必不歪"
else:
five_star_small_pity_mechanism_str = f"5星小保底机制: 必歪"
else:
five_star_small_pity_mechanism_str = f"5星小保底机制: 无"
if pool_type != 'standard':
if four_star_small_pity_mechanism == 'random':
four_star_small_pity_mechanism_str = f"4星小保底机制: 默认"
elif four_star_small_pity_mechanism == 'must_not_waste':
four_star_small_pity_mechanism_str = f"4星小保底机制: 必不歪"
else:
four_star_small_pity_mechanism_str = f"4星小保底机制: 必歪"
else:
four_star_small_pity_mechanism_str = f"4星小保底机制: 无"
luck_rating_str = f"抽卡运势: {luck_rating}"
# 使用变量控制输出
stats = (
f"{pool_pulls_str}\n"
f"{next_pity_5_str}\n"
f"{next_pity_4_str}\n"
f"{get_gold_records_str}\n"
f"{get_purple_records_str}\n"
f"{min_gold_records_str}\n"
f"{max_gold_records_str}\n"
f"{avg_gold_pulls_str}\n"
f"{success_rate_str}\n"
f"{pulls_since_last_5star_str}\n"
f"{five_star_small_pity_mechanism_str}\n"
f"{four_star_small_pity_mechanism_str}\n"
f"{five_star_is_guaranteed_str}\n"
f"{four_star_guaranteed_str}\n"
f"{luck_rating_str}"
)
self.stats_text.config(state=tk.NORMAL)
self.stats_text.delete(1.0, tk.END)
self.stats_text.insert(tk.END, stats)
self.stats_text.config(state=tk.DISABLED)
# 动态调整高度
self.stats_text.update_idletasks()
height = self.stats_text.count('1.0', 'end', 'displaylines')
self.stats_text.config(height=height)
def show_version(self):
version = "2.2.11"
author = "QiuSYan & Claude"
github = "qiusyan-projects/SR-Gacha"
other = "来点Star叭~💖"
messagebox.showinfo("版本信息", f"当前版本: {version}\n作者:{author}\nGithub:{github}\n{other}")
try:
response = requests.get(f"https://api.github.com/repos/{github}/releases/latest")
response.raise_for_status()
except requests.exceptions.SSLError:
print("发生SSL错误,尝试不验证证书进行请求...")
response = requests.get(f"https://api.github.com/repos/{github}/releases/latest", verify=False)
response.raise_for_status()
except requests.RequestException as e:
messagebox.showerror("错误", f"检查更新时发生错误: {e}")
latest_release = response.json()
latest_version = latest_release['tag_name']
# 版本号比较
if self.compare_versions(latest_version, version):
messagebox.showinfo("更新提示", f"检测到新版本 {latest_version},请及时更新!")
else:
messagebox.showinfo("已是最新版本", "你的程序已是最新版本。")
def compare_versions(self, version1, version2):
# 使用正则表达式去除版本号前的非数字字符(如 'v')
version1 = re.sub(r'^[^0-9]+', '', version1)
version2 = re.sub(r'^[^0-9]+', '', version2)
# 将版本号字符串分割并转换为整数元组
v1 = tuple(map(int, version1.split('.')))
v2 = tuple(map(int, version2.split('.')))
# 比较两个版本号
return v1 > v2
def check_pool_update(self):
# status, message = self.gacha_system.check_and_update_pool_file()
status = self.gacha_system.check_and_update_pool_file()
try:
if status == "updated":
self.gacha_system.load_pools(self.gacha_system.pool_file)
self.update_banner_list()
message = "卡池文件已更新到最新版本。"
elif status == "current":
self.gacha_system.load_pools(self.gacha_system.pool_file)
self.update_banner_list()
message = "卡池文件已是最新版本。"
except requests.RequestException as e:
message = f"检查更新时发生错误: {e}"
messagebox.showinfo("检查更新", message)
def show_item_details(self, event):
selected_items = self.pull_history_tree.selection()
if not selected_items: # 如果没有选中任何项目
return # 直接返回,不执行任何操作
item = selected_items[0] # 获取选中的第一个项目
item_details = self.pull_history_tree.item(item, "values")
messagebox.showinfo("物品详情", f"名称: {item_details[3]}\n类型: {item_details[2]}\n星级: {item_details[1]}\n是否UP: {item_details[5]}")
def open_probability_settings(self, pool_type=None):
# 创建一个新的顶级窗口
settings_window = tk.Toplevel(self.root)
settings_window.title("概率设置")
settings_window.geometry("450x500") # 窗口大小,宽x长
# 创建 Notebook 并添加到窗口
notebook = ttk.Notebook(settings_window)
notebook.pack(fill="both", expand=True)
# 创建角色池、光锥池和常驻池的标签页
tab_character = ttk.Frame(notebook, padding="30")
tab_weapon = ttk.Frame(notebook, padding="30")
tab_standard = ttk.Frame(notebook, padding="30")
# 添加标签页到 Notebook
notebook.add(tab_character, text=f"{CHARACTER_DISPLAY_NAME}池")
notebook.add(tab_weapon, text=f"{WEAPON_DISPLAY_NAME}池")
notebook.add(tab_standard, text="常驻池")
if pool_type is None:
if self.gacha_system.current_banner:
banner_info = self.gacha_system.pools['banners'].get(self.gacha_system.current_banner, {})
pool_type = banner_info.get('pool_type', 'standard')
else:
pool_type = 'standard'
# 根据pool_type设置Notebook的当前标签页
if pool_type == 'character':
notebook.select(tab_character)
elif pool_type == 'weapon':
notebook.select(tab_weapon)
else:
notebook.select(tab_standard)
# print(f"当前卡池类型:{pool_type}") # Debug
# 角色池概率设置
def setup_character_prob_tab(self, tab):
self.character_five_star_prob = tk.StringVar(value=str(self.gacha_system.current_prob['character_five_star_base']))
ttk.Label(tab, text="5星基础概率:").grid(row=0, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.character_five_star_prob, width=10).grid(row=0, column=1, padx=5, pady=5)
ttk.Label(tab, text="(0.006 = 0.6%)").grid(row=0, column=2, sticky="w", padx=5, pady=5)
self.character_five_star_success_prob = tk.StringVar(value=str(self.gacha_system.current_prob['character_five_star_success_prob']))
ttk.Label(tab, text="5星不歪概率:").grid(row=1, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.character_five_star_success_prob, width=10).grid(row=1, column=1, padx=5, pady=5)
ttk.Label(tab, text="(0.5 = 50%)").grid(row=1, column=2, sticky="w", padx=5, pady=5)
self.character_five_star_pity = tk.StringVar(value=str(self.gacha_system.current_prob['character_five_star_pity']))
ttk.Label(tab, text="5星保底抽数:").grid(row=2, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.character_five_star_pity, width=10).grid(row=2, column=1, padx=5, pady=5)
ttk.Label(tab, text="(默认: 90)").grid(row=2, column=2, sticky="w", padx=5, pady=5)
self.character_four_star_prob = tk.StringVar(value=str(self.gacha_system.current_prob['character_four_star_base']))
ttk.Label(tab, text="4星基础概率:").grid(row=3, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.character_four_star_prob, width=10).grid(row=3, column=1, padx=5, pady=5)
ttk.Label(tab, text="(0.051 = 5.1%)").grid(row=3, column=2, sticky="w", padx=5, pady=5)
self.character_four_star_success_prob = tk.StringVar(value=str(self.gacha_system.current_prob['character_four_star_success_prob']))
ttk.Label(tab, text="4星不歪概率:").grid(row=4, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.character_four_star_success_prob, width=10).grid(row=4, column=1, padx=5, pady=5)
ttk.Label(tab, text="(0.5 = 50%)").grid(row=4, column=2, sticky="w", padx=5, pady=5)
self.character_four_star_pity = tk.StringVar(value=str(self.gacha_system.current_prob['character_four_star_pity']))
ttk.Label(tab, text="4星保底抽数:").grid(row=5, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.character_four_star_pity, width=10).grid(row=5, column=1, padx=5, pady=5)
ttk.Label(tab, text="(默认: 10)").grid(row=5, column=2, sticky="w", padx=5, pady=5)
# 角色池五星小保底
self.setup_character_5_star_small_pity(tab_character)
# 角色池四星小保底
self.setup_character_4_star_small_pity(tab_character)
# 角色池五星大保底机制设置
self.character_five_star_big_pity_enabled = tk.BooleanVar(value=self.gacha_system.current_prob['character_five_star_big_pity_enabled'])
character_five_star_big_pity_checkbox = ttk.Checkbutton(tab, text="启用5星大保底机制", variable=self.character_five_star_big_pity_enabled)
character_five_star_big_pity_checkbox.grid(row=8, column=0, columnspan=3, sticky="w", padx=5, pady=5)
# 角色池四星大保底机制设置
self.character_four_star_big_pity_enabled = tk.BooleanVar(value=self.gacha_system.current_prob['character_four_star_big_pity_enabled'])
character_four_star_big_pity_checkbox = ttk.Checkbutton(tab, text="启用4星大保底机制", variable=self.character_four_star_big_pity_enabled)
# character_four_star_big_pity_checkbox.grid(row=13, column=2, columnspan=3, sticky="w", padx=(20, 0), pady=5)
character_four_star_big_pity_checkbox.grid(row=8, column=2, columnspan=3,sticky="w" ,padx=5, pady=5)
setup_character_prob_tab(self, tab_character)
# 光锥池概率设置
def setup_weapon_prob_tab(self, tab):
self.weapon_five_star_prob = tk.StringVar(value=str(self.gacha_system.current_prob['weapon_five_star_base']))
ttk.Label(tab, text="5星基础概率:").grid(row=0, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.weapon_five_star_prob, width=10).grid(row=0, column=1, padx=5, pady=5)
ttk.Label(tab, text="(0.008 = 0.8%)").grid(row=0, column=2, sticky="w", padx=5, pady=5)
self.weapon_five_star_success_prob = tk.StringVar(value=str(self.gacha_system.current_prob['weapon_five_star_success_prob']))
ttk.Label(tab, text="5星不歪概率:").grid(row=1, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.weapon_five_star_success_prob, width=10).grid(row=1, column=1, padx=5, pady=5)
ttk.Label(tab, text="(0.75 = 75%)").grid(row=1, column=2, sticky="w", padx=5, pady=5)
self.weapon_five_star_pity = tk.StringVar(value=str(self.gacha_system.current_prob['weapon_five_star_pity']))
ttk.Label(tab, text="5星保底抽数:").grid(row=2, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.weapon_five_star_pity, width=10).grid(row=2, column=1, padx=5, pady=5)
ttk.Label(tab, text="(默认: 80)").grid(row=2, column=2, sticky="w", padx=5, pady=5)
self.weapon_four_star_prob = tk.StringVar(value=str(self.gacha_system.current_prob['weapon_four_star_base']))
ttk.Label(tab, text="4星基础概率:").grid(row=3, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.weapon_four_star_prob, width=10).grid(row=3, column=1, padx=5, pady=5)
ttk.Label(tab, text="(0.066 = 6.6%)").grid(row=3, column=2, sticky="w", padx=5, pady=5)
self.weapon_four_star_success_prob = tk.StringVar(value=str(self.gacha_system.current_prob['weapon_four_star_success_prob']))
ttk.Label(tab, text="4星不歪概率:").grid(row=4, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.weapon_four_star_success_prob, width=10).grid(row=4, column=1, padx=5, pady=5)
ttk.Label(tab, text="(0.75 = 75%)").grid(row=4, column=2, sticky="w", padx=5, pady=5)
self.weapon_four_star_pity = tk.StringVar(value=str(self.gacha_system.current_prob['weapon_four_star_pity']))
ttk.Label(tab, text="4星保底抽数:").grid(row=5, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.weapon_four_star_pity, width=10).grid(row=5, column=1, padx=5, pady=5)
ttk.Label(tab, text="(默认: 10)").grid(row=5, column=2, sticky="w", padx=5, pady=5)
# 光锥池五星小保底
self.setup_weapon_5_star_small_pity(tab_weapon)
# 光锥池四星小保底
self.setup_weapon_4_star_small_pity(tab_weapon)
# 光锥池五星大保底机制设置
self.weapon_five_star_big_pity_enabled = tk.BooleanVar(value=self.gacha_system.current_prob['weapon_five_star_big_pity_enabled'])
weapon_five_star_big_pity_checkbox = ttk.Checkbutton(tab, text="启用5星大保底机制", variable=self.weapon_five_star_big_pity_enabled)
weapon_five_star_big_pity_checkbox.grid(row=8, column=0, columnspan=3, sticky="w", padx=5,pady=5)
# 光锥池四星大保底机制设置
self.weapon_four_star_big_pity_enabled = tk.BooleanVar(value=self.gacha_system.current_prob['weapon_four_star_big_pity_enabled'])
weapon_four_star_big_pity_checkbox = ttk.Checkbutton(tab, text="启用4星大保底机制", variable=self.weapon_four_star_big_pity_enabled)
# character_four_star_big_pity_checkbox.grid(row=13, column=2, columnspan=3, sticky="w", padx=(20, 0), pady=5)
weapon_four_star_big_pity_checkbox.grid(row=8, column=2, columnspan=3,sticky="w", padx=5,pady=5)
# 其他设置项按照类似方式添加...
setup_weapon_prob_tab(self, tab_weapon)
# 常驻池概率设置
def setup_standard_prob_tab(self, tab):
self.standard_five_star_prob = tk.StringVar(value=str(self.gacha_system.current_prob['standard_five_star_base']))
ttk.Label(tab, text="5星基础概率:").grid(row=0, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.standard_five_star_prob, width=10).grid(row=0, column=1, padx=5, pady=5)
ttk.Label(tab, text="(0.006 = 0.6%)").grid(row=0, column=2, sticky="w", padx=5, pady=5)
self.standard_five_star_pity = tk.StringVar(value=str(self.gacha_system.current_prob['standard_five_star_pity']))
ttk.Label(tab, text="5星保底抽数:").grid(row=1, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.standard_five_star_pity, width=10).grid(row=1, column=1, padx=5, pady=5)
ttk.Label(tab, text="(默认: 90)").grid(row=1, column=2, sticky="w", padx=5, pady=5)
self.standard_four_star_prob = tk.StringVar(value=str(self.gacha_system.current_prob['standard_four_star_base']))
ttk.Label(tab, text="常驻池4星基础概率:").grid(row=2, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.standard_four_star_prob, width=10).grid(row=2, column=1, padx=5, pady=5)
ttk.Label(tab, text="(0.051 = 5.1%)").grid(row=2, column=2, sticky="w", padx=5, pady=5)
self.standard_four_star_pity = tk.StringVar(value=str(self.gacha_system.current_prob['standard_four_star_pity']))
ttk.Label(tab, text="常驻池4星保底抽数:").grid(row=3, column=0, sticky="w", padx=5, pady=5)
ttk.Entry(tab, textvariable=self.standard_four_star_pity, width=10).grid(row=3, column=1, padx=5, pady=5)
ttk.Label(tab, text="(默认: 10)").grid(row=3, column=2, sticky="w", padx=5, pady=5)
setup_standard_prob_tab(self, tab_standard)
# 保存设置和恢复默认设置按钮
button_frame = ttk.Frame(settings_window) # 创建一个水平的按钮容器
button_frame.pack(side="bottom", fill="x", expand=True, padx=5, pady=5)
save_button = ttk.Button(button_frame, text="保存设置", command=lambda: self.save_probability_settings(settings_window))
default_button = ttk.Button(button_frame, text="恢复默认设置", command=lambda: self.restore_default_settings(settings_window))
# 将按钮加入到button_frame中,并设置它们填充整个button_frame
save_button.pack(side="left", expand=True)
default_button.pack(side="left",expand=True)
def save_probability_settings(self, window):
try:
# 更新角色池5星小保底机制
if self.character_five_star_small_pity_var_random.get():
self.gacha_system.update_probability('character_five_star_small_pity_mechanism', 'random')
elif self.character_five_star_small_pity_var_must_waste.get():
self.gacha_system.update_probability('character_five_star_small_pity_mechanism', 'must_waste')
elif self.character_five_star_small_pity_var_must_not_waste.get():
self.gacha_system.update_probability('character_five_star_small_pity_mechanism', 'must_not_waste')
# 更新角色池4星小保底机制
if self.character_four_star_small_pity_var_random.get():
self.gacha_system.update_probability('character_four_star_small_pity_mechanism', 'random')
elif self.character_four_star_small_pity_var_must_waste.get():
self.gacha_system.update_probability('character_four_star_small_pity_mechanism', 'must_waste')
elif self.character_four_star_small_pity_var_must_not_waste.get():
self.gacha_system.update_probability('character_four_star_small_pity_mechanism', 'must_not_waste')
# 更新光锥池5星小保底机制
if self.weapon_five_star_small_pity_var_random.get():
self.gacha_system.update_probability('weapon_five_star_small_pity_mechanism', 'random')
elif self.weapon_five_star_small_pity_var_must_waste.get():
self.gacha_system.update_probability('weapon_five_star_small_pity_mechanism', 'must_waste')
elif self.weapon_five_star_small_pity_var_must_not_waste.get():
self.gacha_system.update_probability('weapon_five_star_small_pity_mechanism', 'must_not_waste')
# 更新光锥池4星小保底机制
if self.weapon_four_star_small_pity_var_random.get():
self.gacha_system.update_probability('weapon_four_star_small_pity_mechanism', 'random')
elif self.weapon_four_star_small_pity_var_must_waste.get():
self.gacha_system.update_probability('weapon_four_star_small_pity_mechanism', 'must_waste')
elif self.weapon_four_star_small_pity_var_must_not_waste.get():
self.gacha_system.update_probability('weapon_four_star_small_pity_mechanism', 'must_not_waste')
self.gacha_system.update_probability('character_five_star_base', float(self.character_five_star_prob.get()))
self.gacha_system.update_probability('weapon_five_star_base', float(self.weapon_five_star_prob.get()))
self.gacha_system.update_probability('character_four_star_base', float(self.character_four_star_prob.get()))
self.gacha_system.update_probability('weapon_four_star_base', float(self.weapon_four_star_prob.get()))
self.gacha_system.update_probability('character_five_star_pity', int(self.character_five_star_pity.get()))
self.gacha_system.update_probability('weapon_five_star_pity', int(self.weapon_five_star_pity.get()))
self.gacha_system.update_probability('character_five_star_success_prob', float(self.character_five_star_success_prob.get()))
self.gacha_system.update_probability('weapon_five_star_success_prob', float(self.weapon_five_star_success_prob.get()))
self.gacha_system.update_probability('character_four_star_success_prob', float(self.character_four_star_success_prob.get()))
self.gacha_system.update_probability('weapon_four_star_success_prob', float(self.weapon_four_star_success_prob.get()))
self.gacha_system.update_probability('character_four_star_pity', int(self.character_four_star_pity.get()))
self.gacha_system.update_probability('weapon_four_star_pity', int(self.weapon_four_star_pity.get()))
self.gacha_system.update_probability('character_five_star_big_pity_enabled', self.character_five_star_big_pity_enabled.get())
self.gacha_system.update_probability('character_four_star_big_pity_enabled', self.character_four_star_big_pity_enabled.get())
self.gacha_system.update_probability('weapon_five_star_big_pity_enabled', self.weapon_five_star_big_pity_enabled.get())
self.gacha_system.update_probability('weapon_four_star_big_pity_enabled', self.weapon_four_star_big_pity_enabled.get())
self.gacha_system.update_probability('standard_five_star_base', float(self.standard_five_star_prob.get()))
self.gacha_system.update_probability('standard_five_star_pity', int(self.standard_five_star_pity.get()))
self.gacha_system.update_probability('standard_four_star_base', float(self.standard_four_star_prob.get()))
self.gacha_system.update_probability('standard_four_star_pity', int(self.standard_four_star_pity.get()))
# 更新抽卡统计信息展示
self.update_stats_display()
messagebox.showinfo("成功", "概率设置已保存")
window.destroy()
except ValueError:
messagebox.showerror("错误", "请输入有效的数值")
def restore_default_settings(self, window):
# 恢复默认设置
default_settings = {
'character_five_star_base': 0.006,
'weapon_five_star_base': 0.008,
'character_four_star_base': 0.051,
'weapon_four_star_base': 0.066,
'character_five_star_pity': 90,
'weapon_five_star_pity': 80,
'character_five_star_success_prob': 0.5,
'weapon_five_star_success_prob': 0.75,
'character_four_star_success_prob': 0.5,
'weapon_four_star_success_prob': 0.75,
'character_four_star_pity': 10,
'weapon_four_star_pity': 10,
'character_five_star_big_pity_enabled': True,
'character_four_star_big_pity_enabled': True,
'weapon_five_star_big_pity_enabled': True,
'weapon_four_star_big_pity_enabled': True,
'standard_five_star_base': 0.006,
'standard_five_star_pity': 90,
'standard_four_star_base': 0.051,
'standard_four_star_pity': 10,
'character_five_star_small_pity_mechanism': 'random',
'character_four_star_small_pity_mechanism': 'random',
'weapon_five_star_small_pity_mechanism': 'random',
'weapon_four_star_small_pity_mechanism': 'random'
}
# 更新界面上的值
self.character_five_star_prob.set(str(default_settings['character_five_star_base']))
self.weapon_five_star_prob.set(str(default_settings['weapon_five_star_base']))
self.character_four_star_prob.set(str(default_settings['character_four_star_base']))
self.weapon_four_star_prob.set(str(default_settings['weapon_four_star_base']))
self.character_five_star_pity.set(str(default_settings['character_five_star_pity']))
self.weapon_five_star_pity.set(str(default_settings['weapon_five_star_pity']))
self.character_five_star_success_prob.set(str(default_settings['character_five_star_success_prob']))
self.weapon_five_star_success_prob.set(str(default_settings['weapon_five_star_success_prob']))
self.character_four_star_success_prob.set(str(default_settings['character_four_star_success_prob']))
self.weapon_four_star_success_prob.set(str(default_settings['weapon_four_star_success_prob']))
self.character_four_star_pity.set(str(default_settings['character_four_star_pity']))
self.weapon_four_star_pity.set(str(default_settings['weapon_four_star_pity']))
self.character_five_star_big_pity_enabled.set(default_settings['character_five_star_big_pity_enabled'])
self.character_four_star_big_pity_enabled.set(default_settings['character_four_star_big_pity_enabled'])
self.weapon_five_star_big_pity_enabled.set(default_settings['weapon_five_star_big_pity_enabled'])
self.weapon_four_star_big_pity_enabled.set(default_settings['weapon_four_star_big_pity_enabled'])
self.standard_five_star_prob.set(str(default_settings['standard_five_star_base']))
self.standard_five_star_pity.set(str(default_settings['standard_five_star_pity']))
self.standard_four_star_prob.set(str(default_settings['standard_four_star_base']))
self.standard_four_star_pity.set(str(default_settings['standard_four_star_pity']))
# 更新角色池5星小保底机制单选框的状态
self.character_five_star_small_pity_var_random.set(default_settings['character_five_star_small_pity_mechanism'] == 'random')
self.character_five_star_small_pity_var_must_waste.set(default_settings['character_five_star_small_pity_mechanism'] == 'must_waste')
self.character_five_star_small_pity_var_must_not_waste.set(default_settings['character_five_star_small_pity_mechanism'] == 'must_not_waste')
# 更新角色池4星小保底机制单选框的状态
self.character_four_star_small_pity_var_random.set(default_settings['character_four_star_small_pity_mechanism'] == 'random')
self.character_four_star_small_pity_var_must_waste.set(default_settings['character_four_star_small_pity_mechanism'] == 'must_waste')