Procházet zdrojové kódy

add(DailyTrifles): open filter on every open

Azure před 1 rokem
rodič
revize
32b7a57ac2
1 změnil soubory, kde provedl 13 přidání a 7 odebrání
  1. 13 7
      tasks/AreaBoss/script_task.py

+ 13 - 7
tasks/AreaBoss/script_task.py

@@ -7,6 +7,7 @@ import cv2
 import numpy as np
 import numpy as np
 import random
 import random
 import re
 import re
+from module.atom.click import RuleClick
 from tasks.base_task import BaseTask
 from tasks.base_task import BaseTask
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.game_ui import GameUi
@@ -265,12 +266,13 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
         # 不需要打开筛选界面说明直接找到了目标boss, 直接挑战
         # 不需要打开筛选界面说明直接找到了目标boss, 直接挑战
         if not need_open_filter:
         if not need_open_filter:
             return self.boss_fight(photo, True, fileter_open=False)
             return self.boss_fight(photo, True, fileter_open=False)
-        self.open_filter()
         # 滑动到最顶层
         # 滑动到最顶层
         logger.info("Swipe to top")
         logger.info("Swipe to top")
         for i in range(random.randint(1, 3)):
         for i in range(random.randint(1, 3)):
             self.swipe(self.S_AB_FILTER_DOWN)
             self.swipe(self.S_AB_FILTER_DOWN)
+        # 遍历所有boss找到名称一致的即目前挑战人数最多的
         for PHOTO in BOSS_REWARD_PHOTO1:
         for PHOTO in BOSS_REWARD_PHOTO1:
+            self.open_filter()
             name = self.get_bossName(PHOTO)
             name = self.get_bossName(PHOTO)
             if self.check_common_chars(str(name), boss_name):
             if self.check_common_chars(str(name), boss_name):
                 return self.boss_fight(PHOTO, True, fileter_open=False)
                 return self.boss_fight(PHOTO, True, fileter_open=False)
@@ -279,6 +281,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
         for i in range(random.randint(1, 3)):
         for i in range(random.randint(1, 3)):
             self.swipe(self.S_AB_FILTER_UP)
             self.swipe(self.S_AB_FILTER_UP)
         for PHOTO in BOSS_REWARD_PHOTO2:
         for PHOTO in BOSS_REWARD_PHOTO2:
+            self.open_filter()
             name = self.get_bossName(PHOTO)
             name = self.get_bossName(PHOTO)
             if self.check_common_chars(str(name), boss_name):
             if self.check_common_chars(str(name), boss_name):
                 return self.boss_fight(PHOTO, True, fileter_open=False)
                 return self.boss_fight(PHOTO, True, fileter_open=False)
@@ -288,7 +291,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
     def get_hot_in_reward(self):
     def get_hot_in_reward(self):
         """
         """
             返回挑战人数最多的悬赏鬼王
             返回挑战人数最多的悬赏鬼王
-        @return: 是否打开筛选界面, boss名称
+        @return: 是否打开筛选界面, boss名称, boss图片的click
         @rtype:
         @rtype:
         """
         """
         self.switch_to_reward()
         self.switch_to_reward()
@@ -300,8 +303,12 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
             {"photo": self.C_AB_BOSS_REWARD_PHOTO_MINUS_1, "need_swipe": True},
             {"photo": self.C_AB_BOSS_REWARD_PHOTO_MINUS_1, "need_swipe": True},
         ]
         ]
 
 
-        def check_boss(photo):
-            """检查boss是否满足条件"""
+        def check_boss(photo: RuleClick):
+            """
+            检查boss是否满足条件
+            :param photo:
+            :return: 是否满足条件, 挑战数量, boss名称
+            """
             self.open_filter()
             self.open_filter()
             num = self.get_num_challenge(photo) or 0
             num = self.get_num_challenge(photo) or 0
             if not num:
             if not num:
@@ -318,7 +325,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
         mx_challenge_boss_name = None
         mx_challenge_boss_name = None
         mx_challenge_num = 0
         mx_challenge_num = 0
         photo = None
         photo = None
-        # 遍历所有boss配置
+        # 遍历所有boss配置, 找挑战人数最多的boss
         for cfg in boss_configs:
         for cfg in boss_configs:
             if cfg["need_swipe"]:
             if cfg["need_swipe"]:
                 self.open_filter()
                 self.open_filter()
@@ -326,14 +333,13 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
                     self.swipe(self.S_AB_FILTER_UP)
                     self.swipe(self.S_AB_FILTER_UP)
                 self.wait_until_appear(cfg["photo"], wait_time=1)
                 self.wait_until_appear(cfg["photo"], wait_time=1)
             ret, challenge_num, boss_name = check_boss(cfg["photo"])
             ret, challenge_num, boss_name = check_boss(cfg["photo"])
-            if ret:
+            if ret:  # 直接找到满足条件的, 则不需要打开筛选界面直接挑战即可
                 return False, boss_name, cfg["photo"]
                 return False, boss_name, cfg["photo"]
             if challenge_num > mx_challenge_num:
             if challenge_num > mx_challenge_num:
                 mx_challenge_num = challenge_num
                 mx_challenge_num = challenge_num
                 mx_challenge_boss_name = boss_name
                 mx_challenge_boss_name = boss_name
                 photo = cfg['photo']
                 photo = cfg['photo']
                 logger.attr(mx_challenge_num, f'Select:{boss_name},{photo.name}')
                 logger.attr(mx_challenge_num, f'Select:{boss_name},{photo.name}')
-        # 没有最优boss则找挑战人数最多的boss
         return True, mx_challenge_boss_name if mx_challenge_boss_name else '声望不够', photo if mx_challenge_boss_name else None
         return True, mx_challenge_boss_name if mx_challenge_boss_name else '声望不够', photo if mx_challenge_boss_name else None
 
 
     def get_num_challenge(self, click_area):
     def get_num_challenge(self, click_area):