Ver Fonte

fix(GameUi): Can not close additional button when arrive destination page

runhey há 3 anos atrás
pai
commit
1b5f60f8ba

+ 1 - 1
tasks/Component/GeneralBattle/general_battle.py

@@ -345,7 +345,6 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
         logger.info("Click preset ensure")
 
     def random_click_swipt(self):
-        time.sleep(0.4)  # 这样的好像不对
         if 0 <= random.randint(0, 500) <= 3:  # 百分之4的概率
             rand_type = random.randint(0, 2)
             match rand_type:
@@ -357,6 +356,7 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
                     self.swipe(self.S_BATTLE_RANDOM_RIGHT, interval=20)
             # 重新设置为长战斗
             self.device.stuck_record_add('BATTLE_STATUS_S')
+        time.sleep(0.4)  # 这样的好像不对
 
     # 判断是否在战斗中
     def is_in_battle(self, is_screenshot: bool = True) -> bool:

BIN
tasks/GameUi/additional/additional_ad_disappear.png


BIN
tasks/GameUi/additional/additional_records_close.png


+ 2 - 2
tasks/GameUi/additional/records.json

@@ -5,7 +5,7 @@
     "roiFront": "412,405,37,40",
     "roiBack": "412,405,37,40",
     "method": "Template matching",
-    "threshold": 0.9,
+    "threshold": 0.75,
     "description": "description"
   },
   {
@@ -14,7 +14,7 @@
     "roiFront": "914,143,30,30",
     "roiBack": "914,143,30,30",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "description"
   }
 ]

+ 2 - 2
tasks/GameUi/assets.py

@@ -24,9 +24,9 @@ class GameUiAssets:
 
 	# Image Rule Assets
 	# description 
-	I_AD_DISAPPEAR = RuleImage(roi_front=(412,405,37,40), roi_back=(412,405,37,40), threshold=0.9, method="Template matching", file="./tasks/GameUi/additional/additional_ad_disappear.png")
+	I_AD_DISAPPEAR = RuleImage(roi_front=(412,405,37,40), roi_back=(412,405,37,40), threshold=0.75, method="Template matching", file="./tasks/GameUi/additional/additional_ad_disappear.png")
 	# description 
-	I_RECORDS_CLOSE = RuleImage(roi_front=(914,143,30,30), roi_back=(914,143,30,30), threshold=0.8, method="Template matching", file="./tasks/GameUi/additional/additional_records_close.png")
+	I_RECORDS_CLOSE = RuleImage(roi_front=(914,143,30,30), roi_back=(914,143,30,30), threshold=0.7, method="Template matching", file="./tasks/GameUi/additional/additional_records_close.png")
 
 
 	# Image Rule Assets

+ 21 - 14
tasks/GameUi/game_ui.py

@@ -188,6 +188,8 @@ class GameUi(BaseTask, GameUiAssets):
             visited = new
 
         logger.hr(f"UI goto {destination}")
+        for vis in visited:
+            logger.attr("visited", vis)
         confirm_timer = Timer(confirm_wait, count=int(confirm_wait // 0.5)).start()
         while 1:
             if skip_first_screenshot:
@@ -195,6 +197,16 @@ class GameUi(BaseTask, GameUiAssets):
             else:
                 self.screenshot()
 
+            # Destination additional button
+            if destination.additional and isinstance(destination.additional, list):
+                appear = False
+                for button in destination.additional:
+                    if self.appear_then_click(button, interval=0.6):
+                        appear = True
+                        logger.info(f'Page {destination} AB {button} clicked')
+                if appear:
+                    continue
+
             # Destination page
             if self.appear(destination.check_button):
                 if confirm_timer.reached():
@@ -209,16 +221,15 @@ class GameUi(BaseTask, GameUiAssets):
                 if page.parent is None or page.check_button is None:
                     continue
                 # 如果当前页面不出现可以检测当前按键的按钮,那可能是有一些弹窗,广告,这个时候额外处理
-                if page.additional:
-                    if not isinstance(page.additional, list):
-                        page.additional = [page.additional]
-                    for button in page.additional:
-                        if isinstance(button, RuleImage) and self.appear_then_click(button, interval=1):
-                            sleep(0.4)
-                            logger.info(f'Page {page} AB {button} clicked')
-                        if isinstance(button, RuleOcr) and self.ocr_appear_click(button, interval=1):
-                            sleep(0.4)
-                            logger.info(f'Page {page} AB {button} clicked')
+                # if page.additional:
+                #     if not isinstance(page.additional, list):
+                #         page.additional = [page.additional]
+                #     for button in page.additional:
+                #         logger.info(f'Page {page} AB {button} checking')
+                #         if self.appear_then_click(button, interval=1):
+                #             sleep(0.2)
+                #             logger.info(f'Page {page} AB {button} clicked')
+
 
                 # 获取当前页面的要点击的按钮
                 if self.appear(page.check_button, interval=4):
@@ -233,10 +244,6 @@ class GameUi(BaseTask, GameUiAssets):
             if clicked:
                 continue
 
-            # # Additional
-            # if self.ui_additional():
-            #     continue
-
         # Reset connection
         for page in self.ui_pages:
             page.parent = None