Răsfoiți Sursa

Merge pull request #140 from 976913054/dev-normal

fix(Exploration):修改探索任务中判断战斗开始的逻辑
huangrunheng 2 ani în urmă
părinte
comite
27b8f538e1

+ 4 - 0
tasks/Exploration/assets.py

@@ -60,6 +60,10 @@ class ExplorationAssets:
 	I_BATTLE_REWARD = RuleImage(roi_front=(647,395,31,21), roi_back=(1,1,1278,718), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_battle_reward.png")
 	# 妖 
 	I_EXPLORATION_TITLE = RuleImage(roi_front=(1133,124,47,43), roi_back=(1133,124,47,43), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_exploration_title.png")
+	# description 
+	I_BATTLE_START = RuleImage(roi_front=(555,688,39,27.5), roi_back=(221,677,561,41), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_battle_start.png")
+	# description 
+	I_GET_REWARD = RuleImage(roi_front=(464,231,339,44), roi_back=(464,231,339,44), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_get_reward.png")
 
 
 	# Ocr Rule Assets

+ 18 - 0
tasks/Exploration/res/image.json

@@ -133,5 +133,23 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "妖"
+  },
+  {
+    "itemName": "battle_start",
+    "imageName": "res_battle_start.png",
+    "roiFront": "555,688,39,27.5",
+    "roiBack": "221,677,561,41",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "get_reward",
+    "imageName": "res_get_reward.png",
+    "roiFront": "464,231,339,44",
+    "roiBack": "464,231,339,44",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
   }
 ]

BIN
tasks/Exploration/res/res_battle_start.png


BIN
tasks/Exploration/res/res_e_exploration_click.png


BIN
tasks/Exploration/res/res_exploration_title.png


BIN
tasks/Exploration/res/res_get_reward.png


+ 14 - 16
tasks/Exploration/script_task.py

@@ -66,9 +66,8 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
         if explorationConfig.exploration_config.attack_number == AttackNumber.SEVEN:
             count = 0
             while count < 7:
-                self.screenshot()
-                time.sleep(0.5)
-                if self.appear_then_click(self.I_E_EXPLORATION_CLICK):
+                if self.wait_until_appear(self.I_E_EXPLORATION_CLICK, wait_time=1):
+                    self.click(self.I_E_EXPLORATION_CLICK)
                     count += 1
                     # 进入战斗环节
                     self.battle_process()
@@ -90,7 +89,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
             # 判断当前章节有无目标章节
             result = set(text1).intersection({explorationConfig.exploration_config.exploration_level})
             # 有则跳出检测
-            if result and len(result) > 0:
+            if self.appear(self.I_E_EXPLORATION_CLICK) or result and len(result) > 0:
                 break
             self.device.click_record_clear()
             self.swipe(self.S_SWIPE_LEVEL_UP)
@@ -103,7 +102,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
             self.screenshot()
             self.O_E_EXPLORATION_LEVEL_NUMBER.keyword = explorationConfig.exploration_config.exploration_level
             if self.ocr_appear_click(self.O_E_EXPLORATION_LEVEL_NUMBER):
-                self.wait_until_appear(self.I_E_EXPLORATION_CLICK)
+                self.wait_until_appear(self.I_E_EXPLORATION_CLICK, wait_time=3)
             if self.appear(self.I_E_EXPLORATION_CLICK):
                 break
 
@@ -183,23 +182,22 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
         while 1:
             self.screenshot()
             # 战后奖励
-            self.appear_then_click(self.I_BATTLE_REWARD)
+            if self.appear(self.I_BATTLE_REWARD) and not self.appear(self.I_GET_REWARD):
+                self.click(self.I_BATTLE_REWARD)
             # boss 战
             if self.appear_then_click(self.I_BOSS_BATTLE_BUTTON):
-                time.sleep(0.5)
-                self.screenshot()
-                if self.appear(self.I_BOSS_BATTLE_BUTTON):
+                if self.wait_until_appear(self.I_BATTLE_START, wait_time=5):
+                    self.run_general_battle(self.config.exploration.general_battle_config)
+                else:
                     continue
-                self.run_general_battle(self.config.exploration.general_battle_config)
             # 小怪 战
             if self.appear_then_click(self.I_NORMAL_BATTLE_BUTTON):
-                time.sleep(0.5)
-                self.screenshot()
-                if self.appear(self.I_NORMAL_BATTLE_BUTTON):
+                if self.wait_until_appear(self.I_BATTLE_START, wait_time=5):
+                    self.run_general_battle(self.config.exploration.general_battle_config)
+                else:
                     continue
-                self.run_general_battle(self.config.exploration.general_battle_config)
-                self.screenshot()
-            elif self.appear(self.I_E_AUTO_ROTATE_ON) and not self.appear(self.I_BATTLE_REWARD):
+            # 滑动
+            elif self.appear(self.I_E_AUTO_ROTATE_ON) or self.appear(self.I_GET_REWARD):
                 self.swipe(self.S_SWIPE_BACKGROUND_RIGHT)
             # 结束流程
             if self.appear(self.I_E_EXPLORATION_CLICK) or self.appear(self.I_EXPLORATION_TITLE):