Explorar o código

fix(task): Can not Obtain small boss in DemonEncounter boss

runhey %!s(int64=3) %!d(string=hai) anos
pai
achega
84387b8047

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

@@ -153,7 +153,8 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
 
 
     def battle_wait(self, random_click_swipt_enable: bool) -> bool:
     def battle_wait(self, random_click_swipt_enable: bool) -> bool:
         """
         """
-        等待战斗结束
+        等待战斗结束 !!!
+        很重要 这个函数是原先写的, 优化版本在tasks/Secret/script_task下。本着不改动原先的代码的原则,所以就不改了
         :param random_click_swipt_enable:
         :param random_click_swipt_enable:
         :return:
         :return:
         """
         """
@@ -193,7 +194,6 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
             if random_click_swipt_enable:
             if random_click_swipt_enable:
                 self.random_click_swipt()
                 self.random_click_swipt()
 
 
-
         # 再次确认战斗结果
         # 再次确认战斗结果
         logger.info("Reconfirm the results of the battle")
         logger.info("Reconfirm the results of the battle")
         while 1:
         while 1:

+ 36 - 1
tasks/DemonEncounter/script_task.py

@@ -362,6 +362,40 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets):
         else:
         else:
             return True
             return True
 
 
+    def battle_wait(self, random_click_swipt_enable: bool) -> bool:
+        # 重写
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        self.device.click_record_clear()
+        # 战斗过程 随机点击和滑动 防封
+        logger.info("Start battle process")
+        check_timer = None
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_DE_WIN):
+                logger.info('Appear [demon encounter] win button')
+                self.ui_click_until_disappear(self.I_DE_WIN)
+                check_timer = Timer(3)
+                check_timer.start()
+                continue
+            if self.appear_then_click(self.I_WIN, interval=1):
+                logger.info('Appear win button')
+                check_timer = Timer(3)
+                check_timer.start()
+                continue
+            if self.appear(self.I_REWARD):
+                logger.info('Win battle')
+                self.ui_click_until_disappear(self.I_REWARD)
+                return True
+
+            # 失败的
+            if self.appear(self.I_FALSE):
+                logger.warning('False battle')
+                self.ui_click_until_disappear(self.I_FALSE)
+                return False
+            # 时间到
+            if check_timer and check_timer.reached():
+                logger.warning('Obtain battle timeout')
+                return True
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
     from module.config.config import Config
     from module.config.config import Config
@@ -372,4 +406,5 @@ if __name__ == '__main__':
     d = Device(c)
     d = Device(c)
     t = ScriptTask(c, d)
     t = ScriptTask(c, d)
 
 
-    t.run()
+    # t.run()
+    t.battle_wait(True)

+ 0 - 1
tasks/Secret/script_task.py

@@ -248,7 +248,6 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
         self.device.click_record_clear()
         self.device.click_record_clear()
         # 战斗过程 随机点击和滑动 防封
         # 战斗过程 随机点击和滑动 防封
         logger.info("Start battle process")
         logger.info("Start battle process")
-        # win: bool = False
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             if self.appear(self.I_SE_BATTLE_WIN):
             if self.appear(self.I_SE_BATTLE_WIN):