Просмотр исходного кода

fix(GameUi): Improve repeated button handling and login screen refresh
- slow down button retries after repeated recognition attempts
- refresh screenshots and process the latest frame before login and reward handling

neptine 2 месяцев назад
Родитель
Сommit
fffc3940f0
2 измененных файлов с 6 добавлено и 5 удалено
  1. 2 3
      tasks/GameUi/game_ui.py
  2. 4 2
      tasks/Restart/login.py

+ 2 - 3
tasks/GameUi/game_ui.py

@@ -289,9 +289,8 @@ class GameUi(BaseTask, GameUiAssets):
                     return False
                 if isinstance(button, list):
                     for idx, btn in enumerate(button):
-                        if attempts_list[idx] >= max_attempts_per_button:
-                            continue
-                        attempt =  self.appear_then_operate(btn, interval=0.8, skip_first_screenshot=False)
+                        click_interval = 2.5 if attempts_list[idx] >= max_attempts_per_button else 0.8
+                        attempt =  self.appear_then_operate(btn, interval=click_interval, skip_first_screenshot=False)
                         if attempt:
                             attempts_list[idx] += 1
                         # 只要第一个成功就跳出

+ 4 - 2
tasks/Restart/login.py

@@ -39,10 +39,11 @@ class LoginHandler(BaseTask, RestartAssets, GameUiAssets, GeneralBuffAssets):
                 self.device.get_orientation()
                 orientation_timer.reset()
 
-            self.screenshot()
+            self.device.screenshot()
             # https://github.com/runhey/OnmyojiAutoScript/pull/1761
             if not self.device.check_screen_size_sample():
                 continue
+            self._burst()
 
             # 取消继续战斗
             if self.appear_then_click(self.I_CANCEL_BATTLE, interval=0.8):
@@ -174,10 +175,11 @@ class LoginHandler(BaseTask, RestartAssets, GameUiAssets, GeneralBuffAssets):
         skip_default = False
         courtyard_affairs_done = False  # 庭院事务只执行一次
         while 1:
-            self.screenshot()
+            self.device.screenshot()
             # https://github.com/runhey/OnmyojiAutoScript/pull/1761
             if not self.device.check_screen_size_sample():
                 continue
+            self._burst()
 
             # 点击'获得奖励'
             if self.ui_reward_appear_click():