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

fix(GameUI): Ensure the click intervals during the GOTO PAGE

ryland 1 год назад
Родитель
Сommit
679c8cda42
3 измененных файлов с 13 добавлено и 4 удалено
  1. 6 0
      module/ocr/base_ocr.py
  2. 1 1
      tasks/ActivityShikigami/script_task.py
  3. 6 3
      tasks/GameUi/game_ui.py

+ 6 - 0
module/ocr/base_ocr.py

@@ -87,6 +87,12 @@ class BaseCor:
         self.area: list = list(area)
         self.area: list = list(area)
         self.keyword = keyword
         self.keyword = keyword
 
 
+    def __str__(self):
+        return f"{self.name}"
+
+    def __repr__(self):
+        return f"{self.name}"
+
     @cached_property
     @cached_property
     def model(self) -> TextSystem:
     def model(self) -> TextSystem:
         return OCR_MODEL.__getattribute__(self.lang)
         return OCR_MODEL.__getattribute__(self.lang)

+ 1 - 1
tasks/ActivityShikigami/script_task.py

@@ -464,7 +464,7 @@ if __name__ == '__main__':
     from module.config.config import Config
     from module.config.config import Config
     from module.device.device import Device
     from module.device.device import Device
 
 
-    c = Config('oas3')
+    c = Config('oas1')
     d = Device(c)
     d = Device(c)
     t = ScriptTask(c, d)
     t = ScriptTask(c, d)
 
 

+ 6 - 3
tasks/GameUi/game_ui.py

@@ -245,15 +245,17 @@ class GameUi(BaseTask, GameUiAssets):
             for page, path in paths:
             for page, path in paths:
                 if not self.ui_page_appear(page):
                 if not self.ui_page_appear(page):
                     continue
                     continue
-                logger.info(f"Current page: {page}, following shortest path: {[p.name for p in path]}")
+                logger.info(f"Current page: {page}. Following shortest path:")
+                show_paths: str = ''.join([f"{p.name} -> " for p in path])
+                logger.info(f" {show_paths}")
                 if self._execute_path(path, confirm_timer, timeout_timer):
                 if self._execute_path(path, confirm_timer, timeout_timer):
                     return True
                     return True
-            sleep(0.5)
+            sleep(0.3)
         else:
         else:
             logger.error(f'Cannot goto page[{destination}], timeout[{timeout}s] reached')
             logger.error(f'Cannot goto page[{destination}], timeout[{timeout}s] reached')
         return False
         return False
 
 
-    def _execute_path(self, path, confirm_timer, timeout_timer):
+    def _execute_path(self, path: list, confirm_timer, timeout_timer):
         """
         """
         执行路径
         执行路径
         :param path: currentPage,page1,page2,...,destinationPage
         :param path: currentPage,page1,page2,...,destinationPage
@@ -276,6 +278,7 @@ class GameUi(BaseTask, GameUiAssets):
                             self.appear_then_click(button, interval=0.6) or
                             self.appear_then_click(button, interval=0.6) or
                             (isinstance(button, RuleOcr) and self.ocr_appear_click(button, interval=2))):
                             (isinstance(button, RuleOcr) and self.ocr_appear_click(button, interval=2))):
                         logger.info(f'Page {current_page} additional {button} clicked')
                         logger.info(f'Page {current_page} additional {button} clicked')
+                sleep(0.3)
             # 执行页面跳转
             # 执行页面跳转
             button = current_page.links.get(next_page)
             button = current_page.links.get(next_page)
             if not button:
             if not button: