Просмотр исходного кода

feat(task): rewrite realm raid

runhey 3 лет назад
Родитель
Сommit
ac31f2045d

BIN
module/config/i18n/zh_CN.qm


+ 17 - 0
module/config/i18n/zh_CN.ts

@@ -520,4 +520,21 @@ mode_3策略是刷到五个契灵后开始结契,选择高级、中级盘来
 	<message><source>Notify Config</source><translation>推送配置</translation></message>	
 	<message><source>notify_config_help</source><translation>输入为yaml格式,":"冒号后有一个空格,具体请翻阅文档[消息推送]</translation></message>	
 </context>		
+<context>
+    <name>Args</name>
+	<message><source>Number Attack</source><translation>挑战次数</translation></message>	
+	<message><source>Exit Four</source><translation>当进攻到左上角第一个的时候先退四次再进攻</translation></message>	
+	<message><source>Order Attack</source><translation>挑战顺序</translation></message>
+	<message><source>WhenAttackFail</source><translation>挑战失败时</translation></message>
+	<message><source>Three Refresh</source><translation>每三次就刷新</translation></message>
+	<message><source>Number Base</source><translation>突破卷数量大于等于 X 时才会挑战</translation></message>
+	<message><source>number_attack_help</source><translation>默认30,可选范围[1~30],没有挑战卷自动退出任务(标记为成功)</translation></message>
+	<message><source>exit_four_help</source><translation>为了支持打九退四,保证稳定57级</translation></message>	
+	<message><source>order_attack_help</source><translation>使用过滤器,保持默认即可</translation></message>
+	<message><source>when_attack_fail_help</source><translation>Exit:直接退出任务,标记为失败
+Continue:挑战其他的直至没有可挑战的才刷新
+Refresh:直接刷新,如果刷新操作进入CD,将标记为失败并退出</translation></message>
+	<message><source>three_refresh_help</source><translation>挑战进度到三,领取奖励后就刷新,如果刷新操作进入CD,将标记为失败并退出</translation></message>
+	<message><source>number_base_help</source><translation>旨在检查突破卷数量,如果当前的数量没有大于等于这个值,将标记为成功并退出</translation></message>
+</context>	
 </TS>

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

@@ -26,7 +26,7 @@ class GeneralBattle(BaseTask, GeneralBattleAssets):
         self.current_count += 1
         logger.info(f"Current count: {self.current_count}")
         if config is None:
-            config = GeneralBattleConfig().dict()
+            config = GeneralBattleConfig()
 
 
         # 如果没有锁定队伍。那么可以根据配置设定队伍
@@ -61,7 +61,7 @@ class GeneralBattle(BaseTask, GeneralBattleAssets):
             return False
 
 
-    def run_general_battle_back(self, config: dict=None) -> bool:
+    def run_general_battle_back(self, config: GeneralBattleConfig=None) -> bool:
         """
         进入挑战然后直接返回
         :param config:

+ 8 - 5
tasks/KekkaiUtilize/script_task.py

@@ -203,11 +203,14 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
                             continue
                     break
 
-                # 如果达到今日领取的最大,就不领取了
-                cur, res, totol = self.O_BOX_EXP.ocr(self.device.image)
-                if cur == totol and cur + res == totol:
-                    logger.info('Exp box reach max do not collect')
-                    break
+                if self.appear(self.I_EXP_EXTRACT):
+                    # 如果达到今日领取的最大,就不领取了
+                    cur, res, totol = self.O_BOX_EXP.ocr(self.device.image)
+                    if cur == res == totol == 0:
+                        continue
+                    if cur == totol and cur + res == totol:
+                        logger.info('Exp box reach max do not collect')
+                        break
 
                 if time_exp.reached():
                     logger.warning('Extract exp box timeout')

+ 50 - 0
tasks/RealmRaid/assets.py

@@ -53,10 +53,60 @@ class RealmRaidAssets:
 	I_MEDAL_3_3 = RuleImage(roi_front=(902,479,201,50), roi_back=(902,479,201,50), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_medal_3_3.png")
 
 
+	# Image Rule Assets
+	# 出现呱太勋章 
+	I_FROG_MEDAL = RuleImage(roi_front=(912,12,32,35), roi_back=(912,12,32,35), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_frog_medal.png")
+	# 已经进攻三次了 
+	I_RR_THREE = RuleImage(roi_front=(346,584,42,44), roi_back=(346,584,42,44), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_rr_three.png")
+	# 呱太入侵, 第一次进入结界时候出现 
+	I_FROG_RAID = RuleImage(roi_front=(511,301,282,100), roi_back=(511,301,282,100), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_frog_raid.png")
+	# 个人 
+	I_RR_PERSON = RuleImage(roi_front=(1203,236,56,100), roi_back=(1203,236,56,100), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_rr_person.png")
+
+
 	# Ocr Rule Assets
 	# 刷新的时间 
 	O_FRESH_TIME = RuleOcr(roi=(1042,582,85,36), area=(0,0,100,100), mode="Duration", method="Default", keyword="", name="fresh_time")
 	# 右上角 突破卷的数量 
 	O_NUMBER = RuleOcr(roi=(1143,13,80,39), area=(0,0,100,100), mode="DigitCounter", method="Default", keyword="", name="number")
+	# Ocr-description 
+	O_FROG_1 = RuleOcr(roi=(158,168,42,33), area=(158,168,42,33), mode="Digit", method="Default", keyword="", name="frog_1")
+	# Ocr-description 
+	O_FROG_2 = RuleOcr(roi=(491,170,34,32), area=(491,170,34,32), mode="Digit", method="Default", keyword="", name="frog_2")
+	# Ocr-description 
+	O_FROG_3 = RuleOcr(roi=(824,170,34,32), area=(824,170,34,32), mode="Digit", method="Default", keyword="", name="frog_3")
+	# Ocr-description 
+	O_FROG_4 = RuleOcr(roi=(158,303,38,35), area=(158,303,38,35), mode="Digit", method="Default", keyword="", name="frog_4")
+	# Ocr-description 
+	O_FROG_5 = RuleOcr(roi=(489,304,35,35), area=(489,304,35,35), mode="Digit", method="Default", keyword="", name="frog_5")
+	# Ocr-description 
+	O_FROG_6 = RuleOcr(roi=(824,305,35,33), area=(824,305,35,33), mode="Digit", method="Default", keyword="", name="frog_6")
+	# Ocr-description 
+	O_FROG_7 = RuleOcr(roi=(160,439,31,33), area=(160,439,31,33), mode="Digit", method="Default", keyword="", name="frog_7")
+	# Ocr-description 
+	O_FROG_8 = RuleOcr(roi=(494,441,31,31), area=(494,441,31,31), mode="Digit", method="Default", keyword="", name="frog_8")
+	# Ocr-description 
+	O_FROG_9 = RuleOcr(roi=(825,440,33,33), area=(825,440,33,33), mode="Digit", method="Default", keyword="", name="frog_9")
+
+
+	# Click Rule Assets
+	# 用来分割不同的挑战位置 
+	C_PARTITION_1 = RuleClick(roi_front=(220,147,242,120), roi_back=(220,147,242,120), name="partition_1")
+	# 用来分割不同的挑战位置 
+	C_PARTITION_2 = RuleClick(roi_front=(554,148,249,115), roi_back=(554,148,249,115), name="partition_2")
+	# 用来分割不同的挑战位置 
+	C_PARTITION_3 = RuleClick(roi_front=(885,147,242,116), roi_back=(885,147,242,116), name="partition_3")
+	# 用来分割不同的挑战位置 
+	C_PARTITION_4 = RuleClick(roi_front=(220,283,245,124), roi_back=(220,283,245,124), name="partition_4")
+	# 用来分割不同的挑战位置 
+	C_PARTITION_5 = RuleClick(roi_front=(564,280,237,120), roi_back=(564,280,237,120), name="partition_5")
+	# 用来分割不同的挑战位置 
+	C_PARTITION_6 = RuleClick(roi_front=(894,282,237,120), roi_back=(894,282,237,120), name="partition_6")
+	# 用来分割不同的挑战位置 
+	C_PARTITION_7 = RuleClick(roi_front=(225,416,244,121), roi_back=(225,416,244,121), name="partition_7")
+	# 用来分割不同的挑战位置 
+	C_PARTITION_8 = RuleClick(roi_front=(560,413,237,124), roi_back=(560,413,237,124), name="partition_8")
+	# 用来分割不同的挑战位置 
+	C_PARTITION_9 = RuleClick(roi_front=(893,418,234,116), roi_back=(893,418,234,116), name="partition_9")
 
 

+ 16 - 4
tasks/RealmRaid/config.py

@@ -17,11 +17,23 @@ class AttackNumber(str, Enum):
     NINE = 'nine'
     ALL = 'all'
 
+class WhenAttackFail(str, Enum):
+    EXIT: str = 'Exit'
+    CONTINUE: str = 'Continue'
+    REFRESH: str = 'Refresh'
+
 class RaidConfig(BaseModel):
-    raid_mode: RaidMode = Field(title='Raid Mode', default=RaidMode.NORMAL,
-                                description='raid_mode_help')
-    attack_number: AttackNumber = Field(title='Attack Number', default=AttackNumber.ALL,
-                                        description='')
+    # raid_mode: RaidMode = Field(title='Raid Mode', default=RaidMode.NORMAL,
+    #                             description='raid_mode_help')
+    # attack_number: AttackNumber = Field(title='Attack Number', default=AttackNumber.ALL,
+    #                                     description='')
+
+    number_attack: int = Field(title='Number Attack', default=30, le=30, ge=1, description='number_attack_help')
+    number_base: int = Field(title='Number Base', default=0, le=20, ge=0, description='number_base_help')
+    exit_four: bool = Field(title='Exit Four', default=True, description='exit_four_help')
+    order_attack: str = Field(title='Order Attack', default='5 > 4 > 3 > 2 > 1 > 0', description='order_attack_help')
+    three_refresh: bool = Field(title='Three Refresh', default=False, description='three_refresh_help')
+    when_attack_fail: WhenAttackFail = Field(title='WhenAttackFail', default=WhenAttackFail.REFRESH, description='when_attack_fail_help')
 
 class RealmRaid(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)

+ 38 - 0
tasks/RealmRaid/res/image2.json

@@ -0,0 +1,38 @@
+[
+  {
+    "itemName": "frog_medal",
+    "imageName": "res_frog_medal.png",
+    "roiFront": "912,12,32,35",
+    "roiBack": "912,12,32,35",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "出现呱太勋章"
+  },
+  {
+    "itemName": "rr_three",
+    "imageName": "res_rr_three.png",
+    "roiFront": "346,584,42,44",
+    "roiBack": "346,584,42,44",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "已经进攻三次了"
+  },
+  {
+    "itemName": "frog_raid",
+    "imageName": "res_frog_raid.png",
+    "roiFront": "511,301,282,100",
+    "roiBack": "511,301,282,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "呱太入侵, 第一次进入结界时候出现"
+  },
+  {
+    "itemName": "rr_person",
+    "imageName": "res_rr_person.png",
+    "roiFront": "1203,236,56,100",
+    "roiBack": "1203,236,56,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "个人"
+  }
+]

+ 81 - 0
tasks/RealmRaid/res/ocr.json

@@ -16,5 +16,86 @@
     "method": "Default",
     "keyword": "",
     "description": "右上角 突破卷的数量"
+  },
+  {
+    "itemName": "frog_1",
+    "roiFront": "158,168,42,33",
+    "roiBack": "158,168,42,33",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "frog_2",
+    "roiFront": "491,170,34,32",
+    "roiBack": "491,170,34,32",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "frog_3",
+    "roiFront": "824,170,34,32",
+    "roiBack": "824,170,34,32",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "frog_4",
+    "roiFront": "158,303,38,35",
+    "roiBack": "158,303,38,35",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "frog_5",
+    "roiFront": "489,304,35,35",
+    "roiBack": "489,304,35,35",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "frog_6",
+    "roiFront": "824,305,35,33",
+    "roiBack": "824,305,35,33",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "frog_7",
+    "roiFront": "160,439,31,33",
+    "roiBack": "160,439,31,33",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "frog_8",
+    "roiFront": "494,441,31,31",
+    "roiBack": "494,441,31,31",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "frog_9",
+    "roiFront": "825,440,33,33",
+    "roiBack": "825,440,33,33",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
   }
 ]

+ 56 - 0
tasks/RealmRaid/res/partition.json

@@ -0,0 +1,56 @@
+[
+  {
+    "itemName": "partition_1",
+    "roiFront": "220,147,242,120",
+    "roiBack": "220,147,242,120",
+    "description": "用来分割不同的挑战位置"
+  },
+  {
+    "itemName": "partition_2",
+    "roiFront": "554,148,249,115",
+    "roiBack": "554,148,249,115",
+    "description": "用来分割不同的挑战位置"
+  },
+  {
+    "itemName": "partition_3",
+    "roiFront": "885,147,242,116",
+    "roiBack": "885,147,242,116",
+    "description": "用来分割不同的挑战位置"
+  },
+  {
+    "itemName": "partition_4",
+    "roiFront": "220,283,245,124",
+    "roiBack": "220,283,245,124",
+    "description": "用来分割不同的挑战位置"
+  },
+  {
+    "itemName": "partition_5",
+    "roiFront": "564,280,237,120",
+    "roiBack": "564,280,237,120",
+    "description": "用来分割不同的挑战位置"
+  },
+  {
+    "itemName": "partition_6",
+    "roiFront": "894,282,237,120",
+    "roiBack": "894,282,237,120",
+    "description": "用来分割不同的挑战位置"
+  },
+  {
+    "itemName": "partition_7",
+    "roiFront": "225,416,244,121",
+    "roiBack": "225,416,244,121",
+    "description": "用来分割不同的挑战位置"
+  },
+  {
+    "itemName": "partition_8",
+    "roiFront": "560,413,237,124",
+    "roiBack": "560,413,237,124",
+    "description": "用来分割不同的挑战位置"
+  },
+  {
+    "itemName": "partition_9",
+    "roiFront": "893,418,234,116",
+    "roiBack": "893,418,234,116",
+    "description": "用来分割不同的挑战位置"
+  }
+]

BIN
tasks/RealmRaid/res/res_frog_medal.png


BIN
tasks/RealmRaid/res/res_frog_raid.png


BIN
tasks/RealmRaid/res/res_rr_person.png


BIN
tasks/RealmRaid/res/res_rr_three.png


+ 342 - 75
tasks/RealmRaid/script_task.py

@@ -2,94 +2,29 @@
 # @author runhey
 # github https://github.com/runhey
 import time
+import re
+from cached_property import cached_property
 
 from tasks.base_task import BaseTask
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.page import page_realm_raid, page_main
 from tasks.RealmRaid.assets import RealmRaidAssets
-from tasks.RealmRaid.config import RealmRaid, RaidMode, AttackNumber
+from tasks.RealmRaid.config import RealmRaid, RaidMode, AttackNumber, WhenAttackFail
+
+
 from module.logger import logger
 from module.exception import TaskEnd
 from module.atom.image_grid import ImageGrid
+from module.atom.image import RuleImage
+from module.atom.click import RuleClick
 
-class ScriptTask(GeneralBattle, GameUi, RealmRaidAssets):
 
+class ScriptTask(GeneralBattle, GameUi, RealmRaidAssets):
     medal_grid: ImageGrid = None
 
     def run(self):
-        """
-        执行
-        :return:
-        """
-        config = self.config.realm_raid
-        self.medal_grid = ImageGrid([self.I_MEDAL_5, self.I_MEDAL_4, self.I_MEDAL_3, self.I_MEDAL_3_2, self.I_MEDAL_3_3,
-                                     self.I_MEDAL_2, self.I_MEDAL_1, self.I_MEDAL_0])
-        self.ui_get_current_page()
-        self.ui_goto(page_realm_raid)
-
-        # 点击突破
-        while 1:
-            self.screenshot()
-            if self.appear_then_click(self.I_REALM_RAID, interval=1):
-                continue
-            if self.appear(self.I_BACK_RED, threshold=0.6):
-                break
-        logger.info(f'Click {self.I_REALM_RAID.name}')
-
-        # 判断是不是锁定阵容
-        if config.general_battle_config.lock_team_enable:
-            while 1:
-                self.screenshot()
-                if self.appear_then_click(self.I_UNLOCK, interval=1):
-                    continue
-                if self.appear_then_click(self.I_UNLOCK_2, interval=1):
-                    continue
-                if self.appear(self.I_LOCK_2, threshold=0.9):
-                    break
-                if self.appear(self.I_LOCK, threshold=0.9):
-                    break
-            logger.info(f'Click {self.I_UNLOCK.name}')
-        else:
-            while 1:
-                self.screenshot()
-                if self.appear_then_click(self.I_LOCK, interval=1):
-                    continue
-                if self.appear_then_click(self.I_LOCK_2, interval=1):
-                    continue
-                if self.appear(self.I_UNLOCK_2, threshold=0.9):
-                    break
-                if self.appear(self.I_UNLOCK, threshold=0.9):
-                    break
-            logger.info(f'Click {self.I_LOCK.name}')
-
-        # 判断是只打九次还是打完去
-        if config.raid_config.attack_number == AttackNumber.NINE:
-            self.execute_round(config)
-        else:
-            while 1:
-                if self.execute_round(config):
-                    continue
-                else:
-                    break
-
-        # 点击 右上角的关闭
-        # while 1:
-        #     self.screenshot()
-        #     if self.appear_then_click(self.I_BACK_RED, interval=1):
-        #         continue
-        #     if self.appear(self.I_REALM_RAID, threshold=0.6):
-        #         break
-        # logger.info(f'Click {self.I_BACK_RED.name}')
-        #
-        # # 点击左上角的关闭
-        # self.explore_home()
-        self.ui_current = page_realm_raid
-        self.ui_goto(page_main)
-
-        self.set_next_run(task='RealmRaid', success=True)
-        raise TaskEnd
-
+        self.run_2()
 
     def is_ticket(self) -> bool:
         """
@@ -99,7 +34,7 @@ class ScriptTask(GeneralBattle, GameUi, RealmRaidAssets):
         self.wait_until_appear(self.I_BACK_RED)
         self.screenshot()
         cu, res, total = self.O_NUMBER.ocr(self.device.image)
-        if cu == 0 and cu+res == total:
+        if cu == 0 and cu + res == total:
             logger.warning(f'Execute round failed, no ticket')
             return False
         return True
@@ -179,3 +114,335 @@ class ScriptTask(GeneralBattle, GameUi, RealmRaidAssets):
             self.wait_until_appear(self.I_BACK_RED)
 
         return True
+
+    # ------------------------------------------------------------------------------------------------------------------
+    def run_2(self):
+        con = self.config.realm_raid
+        self.ui_get_current_page()
+        self.ui_goto(page_realm_raid)
+
+        # 有呱太活动的时候第一次进入还会 出现一个弹窗
+        self.screenshot()
+        if self.appear(self.I_FROG_RAID):
+            logger.info(f'Click {self.I_FROG_RAID.name}')
+            while 1:
+                self.screenshot()
+                if not self.appear(self.I_FROG_RAID):
+                    break
+                if self.appear_then_click(self.I_FROG_RAID, interval=1):
+                    continue
+        # 判断是不是锁定阵容
+        self.ensure_lock(con.general_battle_config.lock_team_enable)
+        # 判断是否是呱太活动
+        frog = self.is_frog(True)
+        if frog:
+            logger.info(f'Frog raid')
+
+
+        # 开始循环
+        success = True
+        last_battle = True  # 记录上一次战斗的结果
+        while 1:
+            self.screenshot()
+
+            # 检查票数
+            if not self.check_ticket(con.raid_config.number_base):
+                break
+            # 挑战次数
+            if self.current_count >= con.raid_config.number_attack:
+                logger.info(f'Current count {self.current_count}, max count {con.raid_config.number_attack}')
+                break
+            # 检查是否每三次领一个奖励
+            if self.reward_detect_click(False):
+                continue
+            # 刷新 >> 如果勾选了三次刷新并且到达了三次,就刷新
+            if con.raid_config.three_refresh and self.appear(self.I_RR_THREE, threshold=0.8):
+                logger.info('Three refresh')
+                if self.check_refresh():
+                    continue
+                else:
+                    success = False
+                    break
+            # 刷新 >> 如果上一轮的失败并且勾选了失败刷新,就刷新
+            if not last_battle and con.raid_config.when_attack_fail == WhenAttackFail.REFRESH:
+                logger.info('Battle lost and then refresh')
+                if self.check_refresh():
+                    continue
+                else:
+                    success = False
+                    break
+            # ----------------------------------------开始进攻
+            medal, index = self.find_one(False)
+            if not medal and not index:
+                # 已经没有可以挑战的了,只能刷新
+                if con.raid_config.when_attack_fail == WhenAttackFail.CONTINUE:
+                    logger.info('No one can attack and then refresh')
+                    if self.check_refresh():
+                        continue
+                    else:
+                        success = False
+                        break
+                else:
+                    logger.info('No one can attack, break')
+                    success = False
+                    break
+            # 判断是不是左上角第一个
+            lock_before = con.general_battle_config.lock_team_enable
+            if index == 1:
+                logger.info('Now is the first one')
+                if con.raid_config.exit_four:
+                    logger.info('Exit four enable')
+                    self.fire(index)
+                    self.run_general_battle_back(con.general_battle_config)
+                    self.fire(index)
+                    self.run_general_battle_back(con.general_battle_config)
+                    self.fire(index)
+                    self.run_general_battle_back(con.general_battle_config)
+                    self.fire(index)
+                    self.run_general_battle_back(con.general_battle_config)
+            elif self.check_medal_is_frog(frog, medal, index):
+                # 如果挑战的这只是呱太的话,就要把锁定改为不锁定
+                con.general_battle_config.lock_team_enable = False
+            self.fire(index)
+            last_battle = self.run_general_battle(con.general_battle_config)
+            if lock_before:
+                con.general_battle_config.lock_team_enable = lock_before
+
+        self.ui_current = page_realm_raid
+        self.ui_goto(page_main)
+        self.set_next_run(task='RealmRaid', success=success, finish=True)
+        raise TaskEnd
+
+
+
+
+
+
+
+
+    # ----------------------------------------------------------------------------------------------------------------------
+    # 2023.7.21 改版个人突破
+
+    def ensure_lock(self, lock_team_enable: bool):
+        """
+        确保锁定阵容
+        :param lock_team_enable:
+        :return:
+        """
+        if lock_team_enable:
+            while 1:
+                self.screenshot()
+                if self.appear_then_click(self.I_UNLOCK, interval=1):
+                    continue
+                if self.appear_then_click(self.I_UNLOCK_2, interval=1):
+                    continue
+                if self.appear(self.I_LOCK_2, threshold=0.9):
+                    break
+                if self.appear(self.I_LOCK, threshold=0.9):
+                    break
+            logger.info(f'Click {self.I_UNLOCK.name}')
+        else:
+            while 1:
+                self.screenshot()
+                if self.appear_then_click(self.I_LOCK, interval=1):
+                    continue
+                if self.appear_then_click(self.I_LOCK_2, interval=1):
+                    continue
+                if self.appear(self.I_UNLOCK_2, threshold=0.9):
+                    break
+                if self.appear(self.I_UNLOCK, threshold=0.9):
+                    break
+            logger.info(f'Click {self.I_LOCK.name}')
+
+    def is_frog(self, screenshot: bool=True) -> bool:
+        """
+        判断是不是呱太活动
+        :return:
+        """
+        if screenshot:
+            self.screenshot()
+        if self.appear(self.I_FROG_MEDAL):
+            return True
+        return False
+
+    def check_ticket(self, base: int=0) -> bool:
+        """
+        检查是不是有票, 检查这个票是否大于等于基准
+        :param base:
+        :return:
+        """
+        if base < 0 or base > 30:
+            logger.warning(f'It is not a valid base {base}')
+            base = 0
+        self.wait_until_appear(self.I_BACK_RED)
+        self.screenshot()
+        cu, res, total = self.O_NUMBER.ocr(self.device.image)
+        if cu == 0 and cu + res == total:
+            logger.warning(f'Execute raid failed, no ticket')
+            return False
+        elif cu + res == total and cu < base:
+            logger.warning(f'Execute raid failed, ticket is not enough')
+            return False
+        return True
+
+    @cached_property
+    def order_medal(self) -> ImageGrid:
+        order_attack = self.config.realm_raid.raid_config.order_attack
+        support_number = [0, 1, 2, 3, 4, 5]
+        match = {
+            0: self.I_MEDAL_0,
+            1: self.I_MEDAL_1,
+            2: self.I_MEDAL_2,
+            3: self.I_MEDAL_3,
+            4: self.I_MEDAL_4,
+            5: self.I_MEDAL_5,
+        }
+        order = order_attack.replace(' ', '').replace('\n', '')
+        order = re.split(r'>', order)
+        order = [int(i) for i in order]
+        order = [i for i in order if i in support_number]
+
+        images = []
+        for i in order:
+            images.append(match[i])
+        return ImageGrid(images)
+
+    @cached_property
+    def partition(self) -> list[RuleClick]:
+        return [self.C_PARTITION_1, self.C_PARTITION_2, self.C_PARTITION_3, self.C_PARTITION_4, self.C_PARTITION_5,
+                self.C_PARTITION_6, self.C_PARTITION_7, self.C_PARTITION_8, self.C_PARTITION_9]
+
+    def find_one(self, screenshot: bool=True) -> tuple:
+        """
+        找到一个可以打的,并且检查一下是不是这一个的是第几个的
+        我们约定次序是:从左到右 上到下
+        1 2 3
+        4 5 9
+        7 8 9
+        :return: 返回的第一个参数是一个RuleImage, 第二个参数是位置信息
+        如果没有找到,返回None, None
+        """
+        if screenshot:
+            self.screenshot()
+        target = self.order_medal.find_anyone(self.device.image)
+        if target:
+            center = target.front_center()
+            for i, click in enumerate(self.partition):
+                x1, x2, y1, y2 = click.roi_front[0], click.roi_front[0] + click.roi_front[2], \
+                                 click.roi_front[1], click.roi_front[1] + click.roi_front[3]
+                if x1 < center[0] < x2 and y1 < center[1] < y2:
+                    logger.info(f'Find one medal [{target}], order is {i + 1}')
+                    return target, i + 1
+
+        return None, None
+
+    def check_medal_is_frog(self, is_activity: False, target: RuleImage, order: int) -> bool:
+        """
+        检查这个是不是呱太,为此之前你还需要判断是不是 处于呱太活动的
+        :param target:
+        :param is_activity: 如果不是呱太活动,那么就不需要检查了
+        :param order:
+        :return:
+        """
+        if not is_activity:
+            return False
+        # 好像呱太的位置是只有 789这三个
+        if order < 7:
+            return False
+        # 有时候四星可能和五星的混一起
+        if target != self.I_MEDAL_5 and target != self.I_MEDAL_4:
+            return False
+        match_ocr = {
+            1: self.O_FROG_1,
+            2: self.O_FROG_2,
+            3: self.O_FROG_3,
+            4: self.O_FROG_4,
+            5: self.O_FROG_5,
+            6: self.O_FROG_6,
+            7: self.O_FROG_7,
+            8: self.O_FROG_8,
+            9: self.O_FROG_9,
+        }
+        target_ocr = match_ocr[order]
+        self.screenshot()
+        if target_ocr.ocr(self.device.image) == 20:
+            logger.info(f'Find frog medal [{target}]')
+            return True
+        return False
+
+    def reward_detect_click(self, screenshot: bool=True) -> bool:
+        """
+        检测是否出现 每三次就有奖励的界面, 有就领取
+        :return:
+        """
+        if screenshot:
+            self.screenshot()
+        if self.appear(self.I_SOUL_RAID):
+            self.screenshot()
+            # 稳定一次的截图时间
+            # 再次判断是否出现的
+            if not self.appear(self.I_SOUL_RAID):
+                return False
+            while 1:
+                self.screenshot()
+                if not self.appear(self.I_SOUL_RAID, threshold=0.7):
+                    return True
+                if self.appear_then_click(self.I_SOUL_RAID, interval=1.5):
+                    continue
+
+    def check_refresh(self, screenshot: bool=True) -> bool:
+        """
+        检查是否出现了刷新的按钮
+        如果可以刷新就刷新,返回True
+        如果在CD中,就返回False
+        :return:
+        """
+        if screenshot:
+            self.screenshot()
+        if not self.appear(self.I_FRESH):
+            logger.info(f'No find refresh button and it is in CD')
+            return False
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_FRESH_ENSURE):
+                break
+            if self.appear_then_click(self.I_FRESH, interval=1):
+                continue
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_FRESH_ENSURE):
+                return True
+            if self.appear_then_click(self.I_FRESH_ENSURE, interval=1):
+                continue
+
+    def fire(self, order: int):
+        """
+        挑战
+        :param order:  第几个
+        :return:
+        """
+        click = self.partition[order - 1]
+        self.wait_until_appear(self.I_RR_PERSON)
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_RR_PERSON, threshold=0.8):
+                break
+            if self.appear_then_click(self.I_FIRE, interval=1):
+                continue
+            if self.click(click, interval=1.8):
+                continue
+        logger.info(f'Click fire {order} success')
+
+
+if __name__ == "__main__":
+    from module.config.config import Config
+    from module.device.device import Device
+    config = Config('oas1')
+    device = Device(config)
+    t = ScriptTask(config, device)
+
+    t.run_2()
+
+    # print(t.find_one())
+    # target, order = t.find_one()
+    # print(t.check_medal_is_frog(True, target, order))