Przeglądaj źródła

fix(MetaDemon): Use recognition loop to close victory screen reliably

Problem:
After I_MD_WIN was detected ('Win battle' logged), ui_click_until_disappear
sometimes returned immediately without clicking, because the screenshot in
its loop caught a transition frame where the template no longer matched.
The game stayed on the victory/reward screen for 2+ minutes until the
boss_timer expired and MetaDemon force-exited.

Fix:
Replace ui_click_until_disappear with an explicit recognition loop that
screenshots and clicks I_MD_WIN every 0.5s until the victory screen is
actually gone, guaranteeing the click happens before returning True.

Also remove leftover commented-out code (appear_then_click variant).

Tested locally: 4 consecutive battles closed the victory screen reliably.
微凉徒眸 6 dni temu
rodzic
commit
484337f579
1 zmienionych plików z 9 dodań i 6 usunięć
  1. 9 6
      tasks/MetaDemon/script_task.py

+ 9 - 6
tasks/MetaDemon/script_task.py

@@ -269,21 +269,24 @@ class ScriptTask(RightActivity, GeneralBattle, SwitchSoul, Star56):
 
     def battle_wait(self, random_click_swipt_enable: bool) -> bool:
         # 重写
-        self.device.stuck_record_add('BATTLE_STATUS_S')
+        self.device.stuck_record_add("BATTLE_STATUS_S")
         self.device.click_record_clear()
         logger.info("Start battle process")
         self.boss_mark_reset()
         while 1:
             self.screenshot()
-            # if self.appear_then_click(self.I_MD_WIN, interval=1):
-            #     continue
             if self.appear(self.I_MD_WIN):
-                logger.info('Win battle')
-                self.ui_click_until_disappear(self.I_MD_WIN)
+                logger.info("Win battle")
+                while 1:
+                    self.screenshot()
+                    if not self.appear(self.I_MD_WIN):
+                        break
+                    self.click(self.I_MD_WIN)
+                    sleep(0.5)
                 return True
 
             if self.appear(self.I_MD_BATTLE_FAILURE):
-                logger.warning('False battle')
+                logger.warning("False battle")
                 self.ui_click_until_disappear(self.I_MD_BATTLE_FAILURE)
                 return False
             if self.boss_mark():