Przeglądaj źródła

add is_in_battle function. modified run_general_battle with adding is_in_battle confirmation

TripleEarth 3 lat temu
rodzic
commit
78a1bbfade

BIN
tasks/Component/GeneralBattle/gb/gb_friends.png


+ 9 - 0
tasks/Component/GeneralBattle/gb/image.json

@@ -160,5 +160,14 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "退出确认"
     "description": "退出确认"
+  },
+  {
+    "itemName": "friends",
+    "imageName": "gb_friends.png",
+    "roiFront": "89,14,36,36",
+    "roiBack": "89,14,36,36",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角好友图标"
   }
   }
 ]
 ]

+ 25 - 0
tasks/Component/GeneralBattle/general_battle.py

@@ -36,6 +36,14 @@ class GeneralBattle(BaseTask, GeneralBattleAssets):
             if self.current_count == 1:
             if self.current_count == 1:
                 self.switch_preset_team(config.preset_enable, config.preset_group, config.preset_team)
                 self.switch_preset_team(config.preset_enable, config.preset_group, config.preset_team)
 
 
+            # 检测是否已经在战斗中
+            if self.is_in_battle():
+                win = self.battle_wait(config.random_click_swipt_enable)
+                if win:
+                    return True
+                else:
+                    return False
+
             # 点击准备按钮
             # 点击准备按钮
             self.wait_until_appear(self.I_PREPARE_HIGHLIGHT)
             self.wait_until_appear(self.I_PREPARE_HIGHLIGHT)
             while 1:
             while 1:
@@ -334,6 +342,23 @@ class GeneralBattle(BaseTask, GeneralBattleAssets):
             # 重新设置为长战斗
             # 重新设置为长战斗
             self.device.stuck_record_add('BATTLE_STATUS_S')
             self.device.stuck_record_add('BATTLE_STATUS_S')
 
 
+    # 判断是否在战斗中
+    def is_in_battle(self, is_screenshot: bool = True) -> bool:
+        """
+        判断是否在战斗中
+        :return:
+        """
+        if is_screenshot:
+            self.screenshot()
+        if self.appear(self.I_FRIENDS) or \
+                        self.appear(self.I_WIN) or \
+                        self.appear(self.I_FALSE) or \
+                        self.appear(self.I_REWARD):
+            return True
+        else:
+            return False
+
+
 
 
 
 
 
 

+ 1 - 6
tasks/Orochi/script_task.py

@@ -233,12 +233,7 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
                 else:
                 else:
                     break
                     break
             # 队长秒开的时候,检测是否进入到战斗中
             # 队长秒开的时候,检测是否进入到战斗中
-            elif self.appear(self.I_PREPARE_HIGHLIGHT) or \
-                    self.appear(self.I_PRESET) or \
-                    self.appear(self.I_LOCAL) or \
-                    self.appear(self.I_WIN) or \
-                    self.appear(self.I_FALSE) or \
-                    self.appear(self.I_REWARD):
+            elif self.is_in_battle():
                 self.run_general_battle(config=self.config.orochi.general_battle_config)
                 self.run_general_battle(config=self.config.orochi.general_battle_config)
 
 
         while 1:
         while 1: