@@ -25,13 +25,13 @@ def ensure_main(self, recheck_time=1, time_out=30, esc=True):
25
25
if not self .wait_until (lambda : self .is_main (recheck_time = recheck_time , esc = esc ), time_out = time_out ):
26
26
raise Exception ("请从游戏主页进入" )
27
27
28
- def skip_dialogs (self , end_match , end_box = None , time_out = 120 ):
28
+ def skip_dialogs (self , end_match , end_box = None , time_out = 120 , has_dialog = True ):
29
29
self .info_set ('current_task' , 'skip_dialogs' )
30
30
self .sleep (5 )
31
31
start = time .time ()
32
32
while time .time () - start < time_out :
33
33
boxes = self .ocr ()
34
- if skip := self .find_boxes (boxes , match = ['跳过' ] + pop_ups ):
34
+ if skip := self .find_boxes (boxes , match = ['跳过' ]):
35
35
self .click (skip )
36
36
self .sleep (2 )
37
37
elif no_alert := self .find_boxes (boxes , match = '今日不再提示' ):
@@ -43,15 +43,20 @@ def skip_dialogs(self, end_match, end_box=None, time_out=120):
43
43
return result
44
44
elif self .find_boxes (boxes , match = re .compile (r'回合$' ), boundary = 'top_left' ):
45
45
self .sleep (3 )
46
+ elif pop_up := self .find_boxes (boxes , match = pop_ups ):
47
+ self .click (pop_up )
48
+ self .sleep (2 )
46
49
else :
47
- self .click_relative (0.95 , 0.04 )
50
+ if has_dialog :
51
+ self .click_relative (0.95 , 0.04 )
48
52
self .sleep (2 )
49
53
self .next_frame ()
50
54
raise Exception ('跳过剧情超时!' )
51
55
52
- def auto_battle (self , end_match = None , end_box = None ):
56
+ def auto_battle (self , end_match = None , end_box = None , has_dialog = False ):
53
57
self .info_set ('current_task' , 'auto battle' )
54
- result = self .skip_dialogs (end_match = ['作战开始' , '行动结束' ], end_box = 'bottom' , time_out = 120 )
58
+ result = self .skip_dialogs (end_match = ['作战开始' , '行动结束' ], end_box = 'bottom' , time_out = 120 ,
59
+ has_dialog = has_dialog )
55
60
if result [0 ].name == '作战开始' :
56
61
self .sleep (2 )
57
62
self .click_box (result , after_sleep = 1 )
@@ -76,7 +81,8 @@ def auto_battle(self, end_match=None, end_box=None):
76
81
77
82
results = []
78
83
while results := self .skip_dialogs (
79
- end_match = ['任务完成' , '任务失败' , '战斗失败' , '对战胜利' , '对战失败' , '确认' ], time_out = 900 ):
84
+ end_match = ['任务完成' , '任务失败' , '战斗失败' , '对战胜利' , '对战失败' , '确认' ], time_out = 900 ,
85
+ has_dialog = has_dialog ):
80
86
for result in results :
81
87
if result .name == '确认' :
82
88
self .click_box (result , after_sleep = 2 )
@@ -118,14 +124,17 @@ def is_main(self, recheck_time=0, esc=True):
118
124
119
125
def click (self , x = 0 , y = 0 , move_back = False , name = None , interval = - 1 , move = True ,
120
126
down_time = 0.01 , after_sleep = 0 ):
121
- super ().click (x , y , move_back = move_back , name = name , move = move , down_time = 0.02 , after_sleep = after_sleep ,
127
+ frame = self .frame
128
+ super ().click (x , y , move_back = move_back , name = name , move = move , down_time = 0.04 , after_sleep = after_sleep ,
122
129
interval = interval )
123
-
124
- # def back(self, after_sleep=0):
125
- # if not self.is_adb() and not self.hwnd.visible:
126
- # self.click_relative(0.03, 0.04, after_sleep=after_sleep)
127
- # else:
128
- # super().back(after_sleep=after_sleep)
130
+ if self .debug :
131
+ self .screenshot ('click' , frame = frame )
132
+
133
+ def back (self , after_sleep = 0 ):
134
+ frame = self .frame
135
+ super ().back (after_sleep = after_sleep )
136
+ if self .debug :
137
+ self .screenshot ('back' , frame = frame )
129
138
130
139
def find_top_right_count (self ):
131
140
result = self .ocr (0.89 , 0.01 , 0.99 , 0.1 , match = re .compile (r"^\d+/\d+$" ), box = 'top_right' )
0 commit comments