Sfoglia il codice sorgente

Merge pull request #139 from kaneki-029/dev

新增了一个开发版本的阴阳寮结界突破。
huangrunheng 2 anni fa
parent
commit
6db417573b
46 ha cambiato i file con 1403 aggiunte e 25 eliminazioni
  1. 6 9
      dev_tools/assets_extract.py
  2. 2 2
      module/config/config_manual.py
  3. 5 3
      module/config/config_menu.py
  4. 6 0
      module/config/config_model.py
  5. 57 0
      tasks/DevExploration/assets.py
  6. 22 0
      tasks/DevExploration/config.py
  7. 14 0
      tasks/DevExploration/res/click.json
  8. 83 0
      tasks/DevExploration/res/image.json
  9. 65 0
      tasks/DevExploration/res/ocr.json
  10. BIN
      tasks/DevExploration/res/res_accept.png
  11. BIN
      tasks/DevExploration/res/res_add_image.png
  12. BIN
      tasks/DevExploration/res/res_chapter.png
  13. BIN
      tasks/DevExploration/res/res_exit_sign.png
  14. BIN
      tasks/DevExploration/res/res_exit_sign_2.png
  15. BIN
      tasks/DevExploration/res/res_exit_tansuo.png
  16. BIN
      tasks/DevExploration/res/res_smile.png
  17. BIN
      tasks/DevExploration/res/res_start.png
  18. BIN
      tasks/DevExploration/res/res_sure.png
  19. 154 0
      tasks/DevExploration/script_task.py
  20. 101 1
      tasks/DevRyouToppa/assets.py
  21. 14 0
      tasks/DevRyouToppa/config.py
  22. 56 0
      tasks/DevRyouToppa/res/click.json
  23. 146 0
      tasks/DevRyouToppa/res/failure.json
  24. 146 0
      tasks/DevRyouToppa/res/finished.json
  25. BIN
      tasks/DevRyouToppa/res/finished_1.png
  26. BIN
      tasks/DevRyouToppa/res/finished_2.png
  27. 11 0
      tasks/DevRyouToppa/res/image.json
  28. BIN
      tasks/DevRyouToppa/res/loser_sign_1.png
  29. BIN
      tasks/DevRyouToppa/res/loser_sign_2.png
  30. 11 0
      tasks/DevRyouToppa/res/ocr.json
  31. BIN
      tasks/DevRyouToppa/res/res_toppa_record.png
  32. 236 0
      tasks/DevRyouToppa/script_task.py
  33. 36 0
      tasks/MyOrochi/assets.py
  34. 20 0
      tasks/MyOrochi/config.py
  35. 14 0
      tasks/MyOrochi/res/click.json
  36. 65 0
      tasks/MyOrochi/res/image.json
  37. BIN
      tasks/MyOrochi/res/res_fire_sign.png
  38. BIN
      tasks/MyOrochi/res/res_gu.png
  39. BIN
      tasks/MyOrochi/res/res_in_fight.png
  40. BIN
      tasks/MyOrochi/res/res_in_room.png
  41. BIN
      tasks/MyOrochi/res/res_orichi_end.png
  42. BIN
      tasks/MyOrochi/res/res_orichi_glod.png
  43. BIN
      tasks/MyOrochi/res/res_second_pit_position.png
  44. 107 0
      tasks/MyOrochi/script_task.py
  45. 1 1
      tasks/Orochi/assets.py
  46. 25 9
      tasks/base_task.py

+ 6 - 9
dev_tools/assets_extract.py

@@ -26,7 +26,6 @@ from module.atom.list import RuleList
 IMPORT_EXP = IMPORT_EXP.strip().split('MODULE_FOLDER') + ['']
 
 
-
 def name_transform(name: str) -> str:
     """
     转换名称, 把小写的转化为大写的, 带有数字的不变,有下划线继续有下划线,
@@ -40,6 +39,7 @@ def name_transform(name: str) -> str:
         return name.upper()
     return name.upper()
 
+
 class ImageExtractor:
 
     def __init__(self, file: str, data: list) -> None:
@@ -59,7 +59,6 @@ class ImageExtractor:
     def result(self) -> str:
         return self._result
 
-
     def extract_item(self, item) -> str:
         """
         解析每一项,返回字符串
@@ -75,6 +74,7 @@ class ImageExtractor:
                     f'file="./{self.image_path}/{item["imageName"]}")\n'
         return description + name
 
+
 class ClickExtractor:
 
     def __init__(self, file: str, data: list) -> None:
@@ -103,6 +103,7 @@ class ClickExtractor:
                     f'name="{item["itemName"]}")\n'
         return description + name
 
+
 class LongClickExtractor:
 
     def __init__(self, file: str, data: list) -> None:
@@ -132,6 +133,7 @@ class LongClickExtractor:
                     f'name="{item["itemName"]}")\n'
         return description + name
 
+
 class SwipeExtractor:
 
     def __init__(self, file: str, data: list) -> None:
@@ -161,6 +163,7 @@ class SwipeExtractor:
                     f'name="{item["itemName"]}")\n'
         return description + name
 
+
 class OcrExtractor:
     def __init__(self, file: str, data: list) -> None:
         """
@@ -240,9 +243,6 @@ class ListExtractor:
         return description + name
 
 
-
-
-
 class AssetsExtractor:
 
     def __init__(self, task_path: str) -> None:
@@ -262,7 +262,6 @@ class AssetsExtractor:
             self._result += import_exp
         self._result += self.class_name
 
-
     def all_json_file(self) -> list:
         """
         获取所有json文件
@@ -353,7 +352,6 @@ class AssetsExtractor:
             return True
         return False
 
-
     def write_file(self) -> None:
         """
         将自身的_resule写入文件
@@ -418,6 +416,5 @@ class AllAssetsExtractor:
         me.extract()
 
 
-
 if __name__ == "__main__":
-    AllAssetsExtractor()
+    AllAssetsExtractor.work(r"D:\Tools\OnmyojiAutoScript\tasks\MyOrochi")

+ 2 - 2
module/config/config_manual.py

@@ -11,8 +11,8 @@ class ConfigManual:
         Restart
         > KekkaiUtilize > KekkaiActivation > DemonEncounter
         > AreaBoss > GoldYoukai > ExperienceYoukai > Nian > Tako > RealmRaid > RyouToppa > DailyTrifles > Exploration
-        > Hunt 
-        > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea
+        > Hunt > DevRyouToppa > DevExploration
+        > MyOrochi > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea
         > ActivityShikigami > WantedQuests
         > BondlingFairyland > EvoZone > GoryouRealm
         > TrueOrochi > RichMan

+ 5 - 3
module/config/config_menu.py

@@ -8,6 +8,7 @@ from pydantic import BaseModel, ValidationError, validator, Field
 
 from module.config.utils import *
 
+
 class ConfigMenu:
     # 手动的代码配置菜单
     def __init__(self) -> None:
@@ -18,16 +19,17 @@ class ConfigMenu:
         # 脚本设置
         self.menu['Script'] = ['Script', 'Restart', 'GlobalGame']
         # 刷御魂
-        self.menu["Soul Zones"] = ['Orochi', 'Sougenbi', 'FallenSun', 'EternitySea']
+        self.menu["Soul Zones"] = ['Orochi', 'Sougenbi', 'FallenSun', 'EternitySea', 'MyOrochi']
         # 日常的任务
         self.menu["Daily Task"] = ['DailyTrifles', 'AreaBoss', 'GoldYoukai', 'ExperienceYoukai', 'Nian',
                                    'TalismanPass', 'DemonEncounter', 'Pets', 'SoulsTidy', 'Delegation', 'WantedQuests',
                                    'Tako']
         # 很肝的任务
-        self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone', 'GoryouRealm', 'Exploration']
+        self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone', 'GoryouRealm', 'Exploration',
+                                                'DevExploration']
         # 阴阳寮
         self.menu["Guild"] = ['KekkaiUtilize', 'KekkaiActivation', 'RealmRaid', 'RyouToppa', 'CollectiveMissions',
-                              'Hunt']
+                              'Hunt', 'DevRyouToppa']
         # 每周任务
         self.menu["Weekly Task"] = ['TrueOrochi', 'RichMan', 'Secret', 'WeeklyTrifles', 'MysteryShop', 'Duel']
         # 活动的任务

+ 6 - 0
module/config/config_model.py

@@ -16,6 +16,9 @@ from module.logger import logger
 from tasks.Component.config_base import ConfigBase, TimeDelta
 from tasks.Exploration.config import Exploration
 from tasks.RyouToppa.config import RyouToppa
+from tasks.DevRyouToppa.config import DevRyouToppa
+from tasks.DevExploration.config import DevExploration
+from tasks.MyOrochi.config import MyOrochi
 from tasks.Script.config import Script
 from tasks.Restart.config import Restart
 from tasks.GlobalGame.config import GlobalGame
@@ -77,6 +80,8 @@ class ConfigModel(ConfigBase):
     nian: Nian = Field(default_factory=Nian)
     realm_raid: RealmRaid = Field(default_factory=RealmRaid)
     ryou_toppa: RyouToppa = Field(default_factory=RyouToppa)
+    dev_ryou_toppa: DevRyouToppa = Field(default_factory=DevRyouToppa)
+    my_orochi: MyOrochi = Field(default_factory=MyOrochi)
     kekkai_utilize: KekkaiUtilize = Field(default_factory=KekkaiUtilize)
     kekkai_activation: KekkaiActivation = Field(default_factory=KekkaiActivation)
     demon_encounter: DemonEncounter = Field(default_factory=DemonEncounter)
@@ -86,6 +91,7 @@ class ConfigModel(ConfigBase):
     souls_tidy: SoulsTidy = Field(default_factory=SoulsTidy)
     delegation: Delegation = Field(default_factory=Delegation)
     exploration: Exploration = Field(default_factory=Exploration)
+    dev_exploration: DevExploration = Field(default_factory=DevExploration)
     wanted_quests: WantedQuests = Field(default_factory=WantedQuests)
     tako: Tako = Field(default_factory=Tako)
 

+ 57 - 0
tasks/DevExploration/assets.py

@@ -0,0 +1,57 @@
+from module.atom.image import RuleImage
+from module.atom.click import RuleClick
+from module.atom.long_click import RuleLongClick
+from module.atom.swipe import RuleSwipe
+from module.atom.ocr import RuleOcr
+from module.atom.list import RuleList
+
+# This file was automatically generated by ./dev_tools/assets_extract.py.
+# Don't modify it manually.
+class DevExplorationAssets: 
+
+
+	# Click Rule Assets
+	# 添加点击区域 
+	C_ADD_AREA = RuleClick(roi_front=(1039,204,100,100), roi_back=(1039,204,100,100), name="add_area")
+	# 重新邀请 
+	C_RE_INVITE = RuleClick(roi_front=(711,410,86,46), roi_back=(711,410,86,46), name="re_invite")
+
+
+	# Image Rule Assets
+	# 第二十八章节 
+	I_CHAPTER = RuleImage(roi_front=(1086,559,131,76), roi_back=(1086,559,131,76), threshold=0.8, method="Template matching", file="./tasks/DevExploration/res/res_chapter.png")
+	# 微笑标识 
+	I_SMILE = RuleImage(roi_front=(25,539,55,53), roi_back=(25,539,55,53), threshold=0.8, method="Template matching", file="./tasks/DevExploration/res/res_smile.png")
+	# 添加图案 
+	I_ADD_IMAGE = RuleImage(roi_front=(1040,203,100,100), roi_back=(1040,203,100,100), threshold=0.8, method="Template matching", file="./tasks/DevExploration/res/res_add_image.png")
+	# 挑战按钮 
+	I_START = RuleImage(roi_front=(1180,610,74,68), roi_back=(1180,610,74,68), threshold=0.8, method="Template matching", file="./tasks/DevExploration/res/res_start.png")
+	# 确认 
+	I_SURE = RuleImage(roi_front=(725,413,69,41), roi_back=(725,413,69,41), threshold=0.8, method="Template matching", file="./tasks/DevExploration/res/res_sure.png")
+	# 接受邀请 
+	I_ACCEPT = RuleImage(roi_front=(111,229,63,55), roi_back=(111,229,63,55), threshold=0.8, method="Template matching", file="./tasks/DevExploration/res/res_accept.png")
+	# 退出探索 
+	I_EXIT_TANSUO = RuleImage(roi_front=(17,35,70,56), roi_back=(17,35,70,56), threshold=0.8, method="Template matching", file="./tasks/DevExploration/res/res_exit_tansuo.png")
+	# 退出标识 
+	I_EXIT_SIGN = RuleImage(roi_front=(10,123,87,162), roi_back=(10,123,87,162), threshold=0.8, method="Template matching", file="./tasks/DevExploration/res/res_exit_sign.png")
+	# exit_sign_2 
+	I_EXIT_SIGN_2 = RuleImage(roi_front=(11,148,94,321), roi_back=(11,148,94,321), threshold=0.8, method="Template matching", file="./tasks/DevExploration/res/res_exit_sign_2.png")
+
+
+	# Ocr Rule Assets
+	# 组队按钮 
+	O_TEAM_BUTTON = RuleOcr(roi=(608,516,86,46), area=(608,516,86,46), mode="Full", method="Default", keyword="组队", name="team_button")
+	# 创建房间按钮 
+	O_CREATE_BUTTON = RuleOcr(roi=(593,491,93,49), area=(593,491,93,49), mode="Full", method="Default", keyword="创建", name="create_button")
+	# 需要邀请的好友名称 
+	O_FRIEND = RuleOcr(roi=(352,180,579,320), area=(352,180,579,320), mode="Full", method="Default", keyword="", name="friend")
+	# 邀请 
+	O_INVITE = RuleOcr(roi=(732,553,84,45), area=(732,553,84,45), mode="Full", method="Default", keyword="邀请", name="invite")
+	# 确认 
+	O_QUEREN = RuleOcr(roi=(729,384,90,40), area=(729,384,90,40), mode="Full", method="Default", keyword="确认", name="queren")
+	# 确定 
+	O_QUEDING = RuleOcr(roi=(709,399,87,69), area=(709,399,87,69), mode="Full", method="Default", keyword="确定", name="queding")
+	# Ocr-description 
+	O_QUEREN_2 = RuleOcr(roi=(732,385,82,40), area=(732,385,82,40), mode="Full", method="Default", keyword="确认", name="queren_2")
+
+

+ 22 - 0
tasks/DevExploration/config.py

@@ -0,0 +1,22 @@
+from pydantic import BaseModel, Field
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.config_base import ConfigBase
+from tasks.Component.config_scheduler import Scheduler
+from enum import Enum
+
+
+class ExplorationMode(str, Enum):
+    CAPTAIN = '队长'
+    MEMBER = '队员'
+
+
+class ExplorationConfig(BaseModel):
+    mode: ExplorationMode = Field(title='探索模式', default=ExplorationMode.CAPTAIN,
+                                  description='默认是队长模式')
+    friend: str = Field(default='', description='friend_name_help')
+
+
+class DevExploration(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    exploration_config: ExplorationConfig = Field(default_factory=ExplorationConfig)
+    general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)

+ 14 - 0
tasks/DevExploration/res/click.json

@@ -0,0 +1,14 @@
+[
+  {
+    "itemName": "add_area",
+    "roiFront": "1039,204,100,100",
+    "roiBack": "1039,204,100,100",
+    "description": "添加点击区域"
+  },
+  {
+    "itemName": "re_invite",
+    "roiFront": "711,410,86,46",
+    "roiBack": "711,410,86,46",
+    "description": "重新邀请"
+  }
+]

+ 83 - 0
tasks/DevExploration/res/image.json

@@ -0,0 +1,83 @@
+[
+  {
+    "itemName": "chapter",
+    "imageName": "res_chapter.png",
+    "roiFront": "1086,559,131,76",
+    "roiBack": "1086,559,131,76",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "第二十八章节"
+  },
+  {
+    "itemName": "smile",
+    "imageName": "res_smile.png",
+    "roiFront": "25,539,55,53",
+    "roiBack": "25,539,55,53",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "微笑标识"
+  },
+  {
+    "itemName": "add_image",
+    "imageName": "res_add_image.png",
+    "roiFront": "1040,203,100,100",
+    "roiBack": "1040,203,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "添加图案"
+  },
+  {
+    "itemName": "start",
+    "imageName": "res_start.png",
+    "roiFront": "1180,610,74,68",
+    "roiBack": "1180,610,74,68",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "挑战按钮"
+  },
+  {
+    "itemName": "sure",
+    "imageName": "res_sure.png",
+    "roiFront": "725,413,69,41",
+    "roiBack": "725,413,69,41",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "确认"
+  },
+  {
+    "itemName": "accept",
+    "imageName": "res_accept.png",
+    "roiFront": "111,229,63,55",
+    "roiBack": "111,229,63,55",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "接受邀请"
+  },
+  {
+    "itemName": "exit_tansuo",
+    "imageName": "res_exit_tansuo.png",
+    "roiFront": "17,35,70,56",
+    "roiBack": "17,35,70,56",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "退出探索"
+  },
+  {
+    "itemName": "exit_sign",
+    "imageName": "res_exit_sign.png",
+    "roiFront": "10,123,87,162",
+    "roiBack": "10,123,87,162",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "退出标识"
+  },
+  {
+    "itemName": "exit_sign_2",
+    "imageName": "res_exit_sign_2.png",
+    "roiFront": "11,148,94,321",
+    "roiBack": "11,148,94,321",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "exit_sign_2"
+  }
+]

+ 65 - 0
tasks/DevExploration/res/ocr.json

@@ -0,0 +1,65 @@
+[
+  {
+    "itemName": "team_button",
+    "roiFront": "608,516,86,46",
+    "roiBack": "608,516,86,46",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "组队",
+    "description": "组队按钮"
+  },
+  {
+    "itemName": "create_button",
+    "roiFront": "593,491,93,49",
+    "roiBack": "593,491,93,49",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "创建",
+    "description": "创建房间按钮"
+  },
+  {
+    "itemName": "friend",
+    "roiFront": "352,180,579,320",
+    "roiBack": "352,180,579,320",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "",
+    "description": "需要邀请的好友名称"
+  },
+  {
+    "itemName": "invite",
+    "roiFront": "732,553,84,45",
+    "roiBack": "732,553,84,45",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "邀请",
+    "description": "邀请"
+  },
+  {
+    "itemName": "queren",
+    "roiFront": "729,384,90,40",
+    "roiBack": "729,384,90,40",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "确认",
+    "description": "确认"
+  },
+  {
+    "itemName": "queding",
+    "roiFront": "709,399,87,69",
+    "roiBack": "709,399,87,69",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "确定",
+    "description": "确定"
+  },
+  {
+    "itemName": "queren_2",
+    "roiFront": "732,385,82,40",
+    "roiBack": "732,385,82,40",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "确认",
+    "description": "Ocr-description"
+  }
+]

BIN
tasks/DevExploration/res/res_accept.png


BIN
tasks/DevExploration/res/res_add_image.png


BIN
tasks/DevExploration/res/res_chapter.png


BIN
tasks/DevExploration/res/res_exit_sign.png


BIN
tasks/DevExploration/res/res_exit_sign_2.png


BIN
tasks/DevExploration/res/res_exit_tansuo.png


BIN
tasks/DevExploration/res/res_smile.png


BIN
tasks/DevExploration/res/res_start.png


BIN
tasks/DevExploration/res/res_sure.png


+ 154 - 0
tasks/DevExploration/script_task.py

@@ -0,0 +1,154 @@
+# This Python file uses the following encoding: utf-8
+
+import time
+from module.exception import TaskEnd
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_exploration
+from tasks.DevExploration.assets import DevExplorationAssets
+from module.logger import logger
+from tasks.Secret.assets import SecretAssets
+from tasks.DevExploration.config import ExplorationMode
+
+
+class ScriptTask(GeneralBattle, GameUi, DevExplorationAssets):
+
+    def run(self):
+        options = self.config.dev_exploration
+        if options.exploration_config.mode == ExplorationMode.CAPTAIN:
+            return self._run_captain()
+        elif options.exploration_config.mode == ExplorationMode.MEMBER:
+            return self._run_member()
+        else:
+            logger.exception("Invalid mode, please choice [captain] or [member]")
+        self._run_member()
+
+    def _run_captain(self):
+        options = self.config.dev_exploration
+        self.ui_get_current_page()
+        self.ui_goto(page_exploration)
+
+        while True:
+            self.screenshot()
+            if self.ocr_appear(self.O_TEAM_BUTTON):
+                break
+            if self.appear_then_click(self.I_CHAPTER, interval=2):
+                continue
+
+        while True:
+            self.screenshot()
+            if self.ocr_appear(self.O_CREATE_BUTTON):
+                break
+            if self.ocr_appear_click(self.O_TEAM_BUTTON, interval=2):
+                continue
+
+        while True:
+            self.screenshot()
+            if self.appear(self.I_SMILE):
+                break
+            if self.ocr_appear_click(self.O_CREATE_BUTTON, interval=2):
+                continue
+
+        while True:
+            self.screenshot()
+            if self.ocr_appear(self.O_INVITE):
+                break
+            if self.click(self.C_ADD_AREA, interval=2):
+                continue
+
+        friend_name = options.exploration_config.friend
+        logger.info("准备邀请队员:%s" % friend_name)
+        self.O_FRIEND.keyword = friend_name
+
+        time.sleep(2)
+        self.screenshot()
+        if not self.ocr_appear_click(self.O_FRIEND):
+            logger.error("无法找到队员:%s" % friend_name)
+            raise TaskEnd
+
+        time.sleep(2)
+        self.screenshot()
+        self.ocr_appear_click(self.O_INVITE)
+        self.wait_until_disappear(self.I_ADD_IMAGE)
+
+        # 进入探索
+        self.appear_then_click(self.I_START)
+        time.sleep(3)
+
+        while True:
+            self.screenshot()
+            if self.in_fight():
+                logger.info("检测到进入战斗")
+                self.battle_wait(random_click_swipt_enable=False)
+            if self.in_room():
+                self.wait_until_disappear(self.I_ADD_IMAGE)
+                self.appear_then_click(self.I_START)
+            if self.ocr_appear_click(self.O_QUEREN):
+                pass
+            if self.ocr_appear_click(self.O_QUEDING):
+                pass
+            time.sleep(0.2)
+
+    def _run_member(self):
+        count = 0
+        while True:
+            self.screenshot()
+            if self.appear_then_click(self.I_ACCEPT):
+                time.sleep(2)
+            if self.in_fight():
+                count += 1
+                logger.info("检测到进入战斗 %s" % str(count))
+                self.battle_wait(random_click_swipt_enable=False)
+            if self.appear(self.I_EXIT_SIGN) or self.appear(self.I_EXIT_SIGN_2):
+                self.appear_then_click(self.I_EXIT_TANSUO)
+            if self.ocr_appear_click(self.O_QUEREN_2):
+                pass
+            time.sleep(0.2)
+
+    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")
+        while 1:
+            self.screenshot()
+            if self.appear(SecretAssets.I_SE_BATTLE_WIN):
+                logger.info('Win battle')
+                self.ui_click_until_disappear(SecretAssets.I_SE_BATTLE_WIN)
+                return True
+            if self.appear_then_click(self.I_WIN, interval=1):
+                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
+
+    def in_fight(self):
+        self.screenshot()
+        if self.appear(self.I_EXIT):
+            return True
+        else:
+            return False
+
+    def in_room(self):
+        self.screenshot()
+        if self.appear(self.I_SMILE):
+            return True
+        else:
+            return False
+
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+
+    config = Config('oas2')
+    device = Device(config)
+    t = ScriptTask(config, device)
+    t.run()

+ 101 - 1
tasks/DevRyouToppa/assets.py

@@ -8,5 +8,105 @@ from module.atom.list import RuleList
 # This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 class DevRyouToppaAssets: 
-	pass
+  
+	# Click Rule Assets
+	# area1 
+	C_AREA_1 = RuleClick(roi_front=(533,162,177,74), roi_back=(533,162,177,74), name="area_1")
+	# area2 
+	C_AREA_2 = RuleClick(roi_front=(863,164,181,71), roi_back=(863,164,181,71), name="area_2")
+	# area3 
+	C_AREA_3 = RuleClick(roi_front=(532,292,181,87), roi_back=(532,292,181,87), name="area_3")
+	# area4 
+	C_AREA_4 = RuleClick(roi_front=(863,301,171,62), roi_back=(863,301,171,62), name="area_4")
+	# area5 
+	C_AREA_5 = RuleClick(roi_front=(540,432,169,68), roi_back=(540,432,169,68), name="area_5")
+	# area6 
+	C_AREA_6 = RuleClick(roi_front=(876,432,165,74), roi_back=(876,432,165,74), name="area_6")
+	# area7 
+	C_AREA_7 = RuleClick(roi_front=(538,557,149,71), roi_back=(538,557,149,71), name="area_7")
+	# area8 
+	C_AREA_8 = RuleClick(roi_front=(876,562,150,67), roi_back=(876,562,150,67), name="area_8")
+	# 在点击进攻后如果未进入战斗画面则点击的安全区域 
+	C_SAFE_AREA = RuleClick(roi_front=(182,213,160,229), roi_back=(182,213,160,229), name="safe_area")
+
+
+	# Image Rule Assets
+	# 区域1攻略失败 
+	I_AREA_1_IS_FAILURE = RuleImage(roi_front=(673,146,63,32), roi_back=(421,127,325,134), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域2攻略失败 
+	I_AREA_2_IS_FAILURE = RuleImage(roi_front=(1011,146,63,30), roi_back=(757,125,327,140), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域3攻略失败 
+	I_AREA_3_IS_FAILURE = RuleImage(roi_front=(665,283,73,40), roi_back=(419,254,327,144), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域4攻略失败 
+	I_AREA_4_IS_FAILURE = RuleImage(roi_front=(1000,283,72,38), roi_back=(756,260,325,139), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域5攻略失败 
+	I_AREA_5_IS_FAILURE = RuleImage(roi_front=(669,419,65,29), roi_back=(418,392,328,142), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域6攻略失败 
+	I_AREA_6_IS_FAILURE = RuleImage(roi_front=(988,416,84,37), roi_back=(755,395,328,141), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域7攻略失败 
+	I_AREA_7_IS_FAILURE = RuleImage(roi_front=(672,556,61,37), roi_back=(420,530,326,127), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域8攻略失败 
+	I_AREA_8_IS_FAILURE = RuleImage(roi_front=(1004,556,64,29), roi_back=(756,530,327,124), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域1攻略失败(最近一次) 
+	I_AREA_1_IS_FAILURE_NEW = RuleImage(roi_front=(673,146,63,32), roi_back=(421,123,325,138), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域2攻略失败(最近一次) 
+	I_AREA_2_IS_FAILURE_NEW = RuleImage(roi_front=(1011,146,63,30), roi_back=(757,126,327,139), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域3攻略失败(最近一次) 
+	I_AREA_3_IS_FAILURE_NEW = RuleImage(roi_front=(665,283,73,40), roi_back=(419,261,327,137), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区4攻略失败(最近一次) 
+	I_AREA_4_IS_FAILURE_NEW = RuleImage(roi_front=(1000,283,72,38), roi_back=(756,258,325,141), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域5攻略失败(最近一次) 
+	I_AREA_5_IS_FAILURE_NEW = RuleImage(roi_front=(669,419,65,29), roi_back=(418,394,328,140), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域6攻略失败(最近一次) 
+	I_AREA_6_IS_FAILURE_NEW = RuleImage(roi_front=(988,416,84,37), roi_back=(755,395,328,141), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域7攻略失败(最近一次) 
+	I_AREA_7_IS_FAILURE_NEW = RuleImage(roi_front=(672,556,61,37), roi_back=(420,533,326,124), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域8攻略失败(最近一次) 
+	I_AREA_8_IS_FAILURE_NEW = RuleImage(roi_front=(1004,556,64,29), roi_back=(756,532,327,122), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+
+
+	# Image Rule Assets
+	# 区域1已攻破 
+	I_AREA_1_FINISHED = RuleImage(roi_front=(658,141,93,91), roi_back=(421,127,325,134), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_1.png")
+	# 区域2已攻破 
+	I_AREA_2_FINISHED = RuleImage(roi_front=(983,137,100,100), roi_back=(757,125,327,140), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_1.png")
+	# 区域3已攻破 
+	I_AREA_3_FINISHED = RuleImage(roi_front=(681,312,47,37), roi_back=(419,254,327,144), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_1.png")
+	# 区域4已攻破 
+	I_AREA_4_FINISHED = RuleImage(roi_front=(996,271,100,100), roi_back=(756,260,325,139), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_1.png")
+	# 区域5已攻破 
+	I_AREA_5_FINISHED = RuleImage(roi_front=(647,404,100,100), roi_back=(418,392,328,142), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_1.png")
+	# 区域6已攻破 
+	I_AREA_6_FINISHED = RuleImage(roi_front=(1015,448,56,35), roi_back=(755,395,328,141), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_1.png")
+	# 区域7已攻破 
+	I_AREA_7_FINISHED = RuleImage(roi_front=(643,543,100,100), roi_back=(420,530,326,127), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_1.png")
+	# 区域8已攻破 
+	I_AREA_8_FINISHED = RuleImage(roi_front=(983,541,100,100), roi_back=(756,530,327,124), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_1.png")
+	# 区域1已攻破新 
+	I_AREA_1_FINISHED_NEW = RuleImage(roi_front=(658,141,93,91), roi_back=(421,127,325,134), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_2.png")
+	# 区域2已攻破新 
+	I_AREA_2_FINISHED_NEW = RuleImage(roi_front=(983,137,100,100), roi_back=(757,125,327,140), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_2.png")
+	# 区域3已攻破新 
+	I_AREA_3_FINISHED_NEW = RuleImage(roi_front=(681,312,47,37), roi_back=(419,254,327,144), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_2.png")
+	# 区域4已攻破新 
+	I_AREA_4_FINISHED_NEW = RuleImage(roi_front=(996,271,100,100), roi_back=(756,260,325,139), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_2.png")
+	# 区域5已攻破新 
+	I_AREA_5_FINISHED_NEW = RuleImage(roi_front=(647,404,100,100), roi_back=(418,392,328,142), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_2.png")
+	# 区域6已攻破新 
+	I_AREA_6_FINISHED_NEW = RuleImage(roi_front=(1015,448,56,35), roi_back=(755,395,328,141), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_2.png")
+	# 区域7已攻破新 
+	I_AREA_7_FINISHED_NEW = RuleImage(roi_front=(643,543,100,100), roi_back=(420,530,326,127), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_2.png")
+	# 区域8已攻破新 
+	I_AREA_8_FINISHED_NEW = RuleImage(roi_front=(983,541,100,100), roi_back=(756,530,327,124), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/finished_2.png")
+
+
+	# Image Rule Assets
+	# description 
+	I_TOPPA_RECORD = RuleImage(roi_front=(66,628,64,39), roi_back=(66,628,64,39), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/res_toppa_record.png")
+
+
+	# Ocr Rule Assets
+	# 进攻回合数 
+	O_NUMBER = RuleOcr(roi=(271,560,48,31), area=(271,560,48,31), mode="DigitCounter", method="Default", keyword="", name="number")
+
 

+ 14 - 0
tasks/DevRyouToppa/config.py

@@ -0,0 +1,14 @@
+from pydantic import BaseModel, Field
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.config_base import ConfigBase
+from tasks.Component.config_scheduler import Scheduler
+
+
+class RaidConfig(BaseModel):
+    is_skip_difficult: bool = Field(default=True, description='是否跳过难度较高的结界,失败后不再攻打该结界')
+
+
+class DevRyouToppa(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    raid_config: RaidConfig = Field(default_factory=RaidConfig)
+    general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)

+ 56 - 0
tasks/DevRyouToppa/res/click.json

@@ -0,0 +1,56 @@
+[
+  {
+    "itemName": "area_1",
+    "roiFront": "533,162,177,74",
+    "roiBack": "533,162,177,74",
+    "description": "area1"
+  },
+  {
+    "itemName": "area_2",
+    "roiFront": "863,164,181,71",
+    "roiBack": "863,164,181,71",
+    "description": "area2"
+  },
+  {
+    "itemName": "area_3",
+    "roiFront": "532,292,181,87",
+    "roiBack": "532,292,181,87",
+    "description": "area3"
+  },
+  {
+    "itemName": "area_4",
+    "roiFront": "863,301,171,62",
+    "roiBack": "863,301,171,62",
+    "description": "area4"
+  },
+  {
+    "itemName": "area_5",
+    "roiFront": "540,432,169,68",
+    "roiBack": "540,432,169,68",
+    "description": "area5"
+  },
+  {
+    "itemName": "area_6",
+    "roiFront": "876,432,165,74",
+    "roiBack": "876,432,165,74",
+    "description": "area6"
+  },
+  {
+    "itemName": "area_7",
+    "roiFront": "538,557,149,71",
+    "roiBack": "538,557,149,71",
+    "description": "area7"
+  },
+  {
+    "itemName": "area_8",
+    "roiFront": "876,562,150,67",
+    "roiBack": "876,562,150,67",
+    "description": "area8"
+  },
+  {
+    "itemName": "safe_area",
+    "roiFront": "182,213,160,229",
+    "roiBack": "182,213,160,229",
+    "description": "在点击进攻后如果未进入战斗画面则点击的安全区域"
+  }
+]

+ 146 - 0
tasks/DevRyouToppa/res/failure.json

@@ -0,0 +1,146 @@
+[
+  {
+    "itemName": "area_1_is_failure",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "673,146,63,32",
+    "roiBack": "421,127,325,134",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域1攻略失败"
+  },
+  {
+    "itemName": "area_2_is_failure",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "1011,146,63,30",
+    "roiBack": "757,125,327,140",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域2攻略失败"
+  },
+  {
+    "itemName": "area_3_is_failure",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "665,283,73,40",
+    "roiBack": "419,254,327,144",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域3攻略失败"
+  },
+  {
+    "itemName": "area_4_is_failure",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "1000,283,72,38",
+    "roiBack": "756,260,325,139",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域4攻略失败"
+  },
+  {
+    "itemName": "area_5_is_failure",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "669,419,65,29",
+    "roiBack": "418,392,328,142",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域5攻略失败"
+  },
+  {
+    "itemName": "area_6_is_failure",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "988,416,84,37",
+    "roiBack": "755,395,328,141",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域6攻略失败"
+  },
+  {
+    "itemName": "area_7_is_failure",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "672,556,61,37",
+    "roiBack": "420,530,326,127",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域7攻略失败"
+  },
+  {
+    "itemName": "area_8_is_failure",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "1004,556,64,29",
+    "roiBack": "756,530,327,124",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域8攻略失败"
+  },
+  {
+    "itemName": "area_1_is_failure_new",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "673,146,63,32",
+    "roiBack": "421,123,325,138",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域1攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_2_is_failure_new",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "1011,146,63,30",
+    "roiBack": "757,126,327,139",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域2攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_3_is_failure_new",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "665,283,73,40",
+    "roiBack": "419,261,327,137",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域3攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_4_is_failure_new",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "1000,283,72,38",
+    "roiBack": "756,258,325,141",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区4攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_5_is_failure_new",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "669,419,65,29",
+    "roiBack": "418,394,328,140",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域5攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_6_is_failure_new",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "988,416,84,37",
+    "roiBack": "755,395,328,141",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域6攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_7_is_failure_new",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "672,556,61,37",
+    "roiBack": "420,533,326,124",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域7攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_8_is_failure_new",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "1004,556,64,29",
+    "roiBack": "756,532,327,122",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域8攻略失败(最近一次)"
+  }
+]

+ 146 - 0
tasks/DevRyouToppa/res/finished.json

@@ -0,0 +1,146 @@
+[
+  {
+    "itemName": "area_1_finished",
+    "imageName": "finished_1.png",
+    "roiFront": "658,141,93,91",
+    "roiBack": "421,127,325,134",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域1已攻破"
+  },
+  {
+    "itemName": "area_2_finished",
+    "imageName": "finished_1.png",
+    "roiFront": "983,137,100,100",
+    "roiBack": "757,125,327,140",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域2已攻破"
+  },
+  {
+    "itemName": "area_3_finished",
+    "imageName": "finished_1.png",
+    "roiFront": "681,312,47,37",
+    "roiBack": "419,254,327,144",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域3已攻破"
+  },
+  {
+    "itemName": "area_4_finished",
+    "imageName": "finished_1.png",
+    "roiFront": "996,271,100,100",
+    "roiBack": "756,260,325,139",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域4已攻破"
+  },
+  {
+    "itemName": "area_5_finished",
+    "imageName": "finished_1.png",
+    "roiFront": "647,404,100,100",
+    "roiBack": "418,392,328,142",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域5已攻破"
+  },
+  {
+    "itemName": "area_6_finished",
+    "imageName": "finished_1.png",
+    "roiFront": "1015,448,56,35",
+    "roiBack": "755,395,328,141",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域6已攻破"
+  },
+  {
+    "itemName": "area_7_finished",
+    "imageName": "finished_1.png",
+    "roiFront": "643,543,100,100",
+    "roiBack": "420,530,326,127",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域7已攻破"
+  },
+  {
+    "itemName": "area_8_finished",
+    "imageName": "finished_1.png",
+    "roiFront": "983,541,100,100",
+    "roiBack": "756,530,327,124",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域8已攻破"
+  },
+  {
+    "itemName": "area_1_finished_new",
+    "imageName": "finished_2.png",
+    "roiFront": "658,141,93,91",
+    "roiBack": "421,127,325,134",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域1已攻破新"
+  },
+  {
+    "itemName": "area_2_finished_new",
+    "imageName": "finished_2.png",
+    "roiFront": "983,137,100,100",
+    "roiBack": "757,125,327,140",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域2已攻破新"
+  },
+  {
+    "itemName": "area_3_finished_new",
+    "imageName": "finished_2.png",
+    "roiFront": "681,312,47,37",
+    "roiBack": "419,254,327,144",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域3已攻破新"
+  },
+  {
+    "itemName": "area_4_finished_new",
+    "imageName": "finished_2.png",
+    "roiFront": "996,271,100,100",
+    "roiBack": "756,260,325,139",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域4已攻破新"
+  },
+  {
+    "itemName": "area_5_finished_new",
+    "imageName": "finished_2.png",
+    "roiFront": "647,404,100,100",
+    "roiBack": "418,392,328,142",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域5已攻破新"
+  },
+  {
+    "itemName": "area_6_finished_new",
+    "imageName": "finished_2.png",
+    "roiFront": "1015,448,56,35",
+    "roiBack": "755,395,328,141",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域6已攻破新"
+  },
+  {
+    "itemName": "area_7_finished_new",
+    "imageName": "finished_2.png",
+    "roiFront": "643,543,100,100",
+    "roiBack": "420,530,326,127",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域7已攻破新"
+  },
+  {
+    "itemName": "area_8_finished_new",
+    "imageName": "finished_2.png",
+    "roiFront": "983,541,100,100",
+    "roiBack": "756,530,327,124",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域8已攻破新"
+  }
+]

BIN
tasks/DevRyouToppa/res/finished_1.png


BIN
tasks/DevRyouToppa/res/finished_2.png


+ 11 - 0
tasks/DevRyouToppa/res/image.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "toppa_record",
+    "imageName": "res_toppa_record.png",
+    "roiFront": "66,628,64,39",
+    "roiBack": "66,628,64,39",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  }
+]

BIN
tasks/DevRyouToppa/res/loser_sign_1.png


BIN
tasks/DevRyouToppa/res/loser_sign_2.png


+ 11 - 0
tasks/DevRyouToppa/res/ocr.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "number",
+    "roiFront": "271,560,48,31",
+    "roiBack": "271,560,48,31",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "进攻回合数"
+  }
+]

BIN
tasks/DevRyouToppa/res/res_toppa_record.png


+ 236 - 0
tasks/DevRyouToppa/script_task.py

@@ -0,0 +1,236 @@
+# This Python file uses the following encoding: utf-8
+
+import time
+import random
+from datetime import datetime, timedelta
+from module.base.utils import point2str
+from module.exception import TaskEnd
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_kekkai_toppa
+from tasks.RealmRaid.assets import RealmRaidAssets
+from tasks.DevRyouToppa.assets import DevRyouToppaAssets
+from module.atom.image_grid import ImageGrid
+from module.logger import logger
+from tasks.Secret.assets import SecretAssets
+
+default_index = [0, 1, 2, 3, 4, 5, 6, 7]
+area_map = (
+    {
+        "fail_sign": (DevRyouToppaAssets.I_AREA_1_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_1_IS_FAILURE),
+        "rule_click": DevRyouToppaAssets.C_AREA_1,
+        "finished_sign": (DevRyouToppaAssets.I_AREA_1_FINISHED, DevRyouToppaAssets.I_AREA_1_FINISHED_NEW)
+    },
+    {
+        "fail_sign": (DevRyouToppaAssets.I_AREA_2_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_2_IS_FAILURE),
+        "rule_click": DevRyouToppaAssets.C_AREA_2,
+        "finished_sign": (DevRyouToppaAssets.I_AREA_2_FINISHED, DevRyouToppaAssets.I_AREA_2_FINISHED_NEW)
+    },
+    {
+        "fail_sign": (DevRyouToppaAssets.I_AREA_3_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_3_IS_FAILURE),
+        "rule_click": DevRyouToppaAssets.C_AREA_3,
+        "finished_sign": (DevRyouToppaAssets.I_AREA_3_FINISHED, DevRyouToppaAssets.I_AREA_3_FINISHED_NEW)
+    },
+    {
+        "fail_sign": (DevRyouToppaAssets.I_AREA_4_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_4_IS_FAILURE),
+        "rule_click": DevRyouToppaAssets.C_AREA_4,
+        "finished_sign": (DevRyouToppaAssets.I_AREA_4_FINISHED, DevRyouToppaAssets.I_AREA_4_FINISHED_NEW)
+    },
+    {
+        "fail_sign": (DevRyouToppaAssets.I_AREA_5_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_5_IS_FAILURE),
+        "rule_click": DevRyouToppaAssets.C_AREA_5,
+        "finished_sign": (DevRyouToppaAssets.I_AREA_5_FINISHED, DevRyouToppaAssets.I_AREA_5_FINISHED_NEW)
+    },
+    {
+        "fail_sign": (DevRyouToppaAssets.I_AREA_6_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_6_IS_FAILURE),
+        "rule_click": DevRyouToppaAssets.C_AREA_6,
+        "finished_sign": (DevRyouToppaAssets.I_AREA_6_FINISHED, DevRyouToppaAssets.I_AREA_6_FINISHED_NEW)
+    },
+    {
+        "fail_sign": (DevRyouToppaAssets.I_AREA_7_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_7_IS_FAILURE),
+        "rule_click": DevRyouToppaAssets.C_AREA_7,
+        "finished_sign": (DevRyouToppaAssets.I_AREA_7_FINISHED, DevRyouToppaAssets.I_AREA_7_FINISHED_NEW)
+    },
+    {
+        "fail_sign": (DevRyouToppaAssets.I_AREA_8_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_8_IS_FAILURE),
+        "rule_click": DevRyouToppaAssets.C_AREA_8,
+        "finished_sign": (DevRyouToppaAssets.I_AREA_8_FINISHED, DevRyouToppaAssets.I_AREA_8_FINISHED_NEW)
+    }
+)
+
+
+def random_delay(min_value: float = 1.0, max_value: float = 2.0, decimal: int = 1):
+    """
+    生成一个指定范围内的随机小数
+    """
+    random_float_in_range = random.uniform(min_value, max_value)
+    return (round(random_float_in_range, decimal))
+
+
+class ScriptTask(GeneralBattle, GameUi, SwitchSoul, DevRyouToppaAssets):
+    medal_grid: ImageGrid = None
+    area_index: list = []
+
+    def run(self):
+        """
+        执行
+        :return:
+        """
+        options = self.config.dev_ryou_toppa
+        self.ui_get_current_page()
+        self.ui_goto(page_kekkai_toppa)
+
+        # 确认进入结界突破界面
+        self.wait_until_appear(self.I_TOPPA_RECORD)
+        if not self.area_index:
+            self.area_index.extend(default_index)
+        index = 0
+
+        # 开始突破
+        while True:
+            res = self.attack_area(index)
+            # 如果战斗失败或区域不可用,则弹出当前区域索引,开始进攻下一个
+            if not res:
+                try:
+                    self.area_index.pop(0)
+                    index = self.area_index[0]
+                except IndexError:
+                    # 每次出现 IndexError 说明8个区域都不可用,需要滚动列表。
+                    self.area_index.extend(default_index)
+                    self.flush_area_cache()
+                    index = 0
+
+    def check_area(self, index: int):
+        """
+        检查该区域是否攻略失败
+        :return:
+        """
+        f1, f2 = area_map[index].get("fail_sign")
+        f3, f4 = area_map[index].get("finished_sign")
+        self.screenshot()
+        # 如果该区域已经被攻破则退出
+        # Ps: 这时候能打过的都打过了,没有能攻打的结界了, 代表任务已经完成,set_next_run time=1d
+        if self.appear(f3, threshold=0.8) or self.appear(f4, threshold=0.8):
+            self.set_next_run(task='DevRyouToppa', finish=True, success=True)
+            raise TaskEnd
+        # 如果该区域攻略失败返回 False
+        if self.appear(f1, threshold=0.8) or self.appear(f2, threshold=0.8):
+            logger.info('Area [%s] is futile attack, skip.' % str(index + 1))
+            return False
+        return True
+
+    def attack_area(self, index: int):
+        """
+        :return: 战斗成功(True) or 战斗失败(False) or 区域不可用(False) or 没有进攻机会(设定下次运行并退出)
+        """
+        # 先判断是否有进攻机会, 如果没有,set_next_run ,时间等于 (30-60) 分钟后的随机时间
+        if not self.has_ticket():
+            logger.info("We have no chance to attack. Try again after 1 hour.")
+            target = datetime.now() + timedelta(minutes=random.randint(30, 59), seconds=random.randint(1, 59))
+            self.set_next_run(task='DevRyouToppa', success=True, target=target)
+            raise TaskEnd
+        # 每次进攻前检查区域可用性
+        if not self.check_area(index):
+            return False
+
+        # 正式进攻会设定 2s - 10s 的随机延迟,避免攻击间隔及其相近被检测为脚本。
+        delay = random_delay()
+        time.sleep(delay)
+        rcl = area_map[index].get("rule_click")
+        # 点击攻击区域,等待攻击按钮出现。
+        self.ui_click(rcl, stop=RealmRaidAssets.I_FIRE)
+
+        # 塔塔开!
+        while True:
+            self.screenshot()
+            # 如果进入战斗
+            if self.appear(self.I_EXIT, threshold=0.8):
+                logger.info("Start attach area [%s]" % str(index + 1))
+                break
+            if self.appear(RealmRaidAssets.I_FIRE, threshold=0.8):
+                self.appear_then_click(RealmRaidAssets.I_FIRE, threshold=0.8)
+                time.sleep(1.5)
+                self.screenshot()
+                self.appear_then_click(RealmRaidAssets.I_FIRE, threshold=0.8)
+                time.sleep(1.5)
+                self.screenshot()
+                # 点击两次点击后如果还出现进攻按钮则判断该区域已被攻打过
+                # 不使用 ocr 的原因是怕不好识别导致重复点击被检测
+                if self.appear(self.I_EXIT, threshold=0.8):
+                    logger.info("Start attach area [%s]" % str(index + 1))
+                    break
+                else:
+                    self.click(self.C_SAFE_AREA)
+                    time.sleep(2)
+                return False
+
+        # 等待战斗结束
+        # TO-DO 后续更改默认值
+        return self.battle_wait(random_click_swipt_enable=True)
+
+    def flush_area_cache(self):
+        time.sleep(2)
+        duration = 0.352
+        count = random.randint(1, 3)
+        for i in range(count):
+            # 测试过很多次 win32api, win32gui 的 MOUSEEVENTF_WHEEL, WM_MOUSEWHEEL
+            # 都出现过很多次离奇的事件,索性放弃了使用以下方法,参数是精心调试的
+            # 每次执行刚好刷新一组(2个)设定随机刷新 1 - 3 次
+            safe_pos_x = random.randint(540, 1000)
+            safe_pos_y = random.randint(320, 540)
+            p1 = (safe_pos_x, safe_pos_y)
+            p2 = (safe_pos_x, safe_pos_y - 101)
+            logger.info('Swipe %s -> %s, %s ' % (point2str(*p1), point2str(*p2), duration))
+            self.device.swipe_adb(p1, p2, duration=duration)
+            time.sleep(2)
+
+    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")
+        while 1:
+            self.screenshot()
+            if self.appear(SecretAssets.I_SE_BATTLE_WIN):
+                logger.info('Win battle')
+                self.ui_click_until_disappear(SecretAssets.I_SE_BATTLE_WIN)
+                return True
+            if self.appear_then_click(self.I_WIN, interval=1):
+                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
+
+    def has_ticket(self) -> bool:
+        """
+        如果没有票了,那么就返回False
+        :return:
+        """
+        # 21点后无限进攻机会
+        if datetime.now().hour >= 21:
+            return True
+        self.wait_until_appear(self.I_TOPPA_RECORD)
+        self.screenshot()
+        cu, res, total = self.O_NUMBER.ocr(self.device.image)
+        if cu == 0 and cu + res == total:
+            logger.warning(f'Execute round failed, no ticket')
+            return False
+        return True
+
+
+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()

+ 36 - 0
tasks/MyOrochi/assets.py

@@ -0,0 +1,36 @@
+from module.atom.image import RuleImage
+from module.atom.click import RuleClick
+from module.atom.long_click import RuleLongClick
+from module.atom.swipe import RuleSwipe
+from module.atom.ocr import RuleOcr
+from module.atom.list import RuleList
+
+# This file was automatically generated by ./dev_tools/assets_extract.py.
+# Don't modify it manually.
+class MyOrochiAssets: 
+
+
+	# Click Rule Assets
+	# 结束时的安全点击区域 
+	C_SAFE_AREA_1 = RuleClick(roi_front=(32,173,194,390), roi_back=(32,173,194,390), name="safe_area_1")
+	# 结束时的安全点击区域2 
+	C_SAFE_AREA_2 = RuleClick(roi_front=(1082,187,170,429), roi_back=(1082,187,170,429), name="safe_area_2")
+
+
+	# Image Rule Assets
+	# 第二个坑位标识 
+	I_SECOND_PIT_POSITION = RuleImage(roi_front=(597,204,100,100), roi_back=(597,204,100,100), threshold=0.8, method="Template matching", file="./tasks/MyOrochi/res/res_second_pit_position.png")
+	# 调整按钮 
+	I_FIRE_SIGN = RuleImage(roi_front=(1169,603,98,81), roi_back=(1169,603,98,81), threshold=0.8, method="Template matching", file="./tasks/MyOrochi/res/res_fire_sign.png")
+	# 御魂金币
+	I_ORICHI_GLOD = RuleImage(roi_front=(820,182,80,61), roi_back=(0,0,1279,719), threshold=0.8, method="Template matching", file="./tasks/MyOrochi/res/res_orichi_glod.png")
+	# 魂字标识 
+	I_ORICHI_END = RuleImage(roi_front=(574,495,123,102), roi_back=(574,495,123,102), threshold=0.8, method="Template matching", file="./tasks/MyOrochi/res/res_orichi_end.png")
+	# 太鼓标识 
+	I_GU = RuleImage(roi_front=(432,88,100,100), roi_back=(432,88,100,100), threshold=0.8, method="Template matching", file="./tasks/MyOrochi/res/res_gu.png")
+	# 房间标识 
+	I_IN_ROOM = RuleImage(roi_front=(15,524,77,79), roi_back=(15,524,77,79), threshold=0.8, method="Template matching", file="./tasks/MyOrochi/res/res_in_room.png")
+	# 判断是否进入战斗 
+	I_IN_FIGHT = RuleImage(roi_front=(87,17,41,34), roi_back=(87,17,41,34), threshold=0.8, method="Template matching", file="./tasks/MyOrochi/res/res_in_fight.png")
+
+

+ 20 - 0
tasks/MyOrochi/config.py

@@ -0,0 +1,20 @@
+from pydantic import BaseModel, Field
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.config_base import ConfigBase
+from tasks.Component.config_scheduler import Scheduler
+from enum import Enum
+
+
+class RoleMode(str, Enum):
+    CAPTAIN = '队长'
+    MEMBER = '队员'
+
+
+class MyOrochiConfig(BaseModel):
+    mode: RoleMode = Field(title='角色模式', default=RoleMode.CAPTAIN, description='默认是队长模式')
+
+
+class MyOrochi(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    orochi_config: MyOrochiConfig = Field(default_factory=MyOrochiConfig)
+    general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)

+ 14 - 0
tasks/MyOrochi/res/click.json

@@ -0,0 +1,14 @@
+[
+  {
+    "itemName": "safe_area_1",
+    "roiFront": "32,173,194,390",
+    "roiBack": "32,173,194,390",
+    "description": "结束时的安全点击区域"
+  },
+  {
+    "itemName": "safe_area_2",
+    "roiFront": "1082,187,170,429",
+    "roiBack": "1082,187,170,429",
+    "description": "结束时的安全点击区域2"
+  }
+]

+ 65 - 0
tasks/MyOrochi/res/image.json

@@ -0,0 +1,65 @@
+[
+  {
+    "itemName": "second_pit_position",
+    "imageName": "res_second_pit_position.png",
+    "roiFront": "597,204,100,100",
+    "roiBack": "597,204,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "第二个坑位标识"
+  },
+  {
+    "itemName": "fire_sign",
+    "imageName": "res_fire_sign.png",
+    "roiFront": "1169,603,98,81",
+    "roiBack": "1169,603,98,81",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "调整按钮"
+  },
+  {
+    "itemName": "orichi_glod",
+    "imageName": "res_orichi_glod.png",
+    "roiFront": "820,182,80,61",
+    "roiBack": "0,0,1279,719",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "御魂金币"
+  },
+  {
+    "itemName": "orichi_end",
+    "imageName": "res_orichi_end.png",
+    "roiFront": "574,495,123,102",
+    "roiBack": "574,495,123,102",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "魂字标识"
+  },
+  {
+    "itemName": "gu",
+    "imageName": "res_gu.png",
+    "roiFront": "432,88,100,100",
+    "roiBack": "432,88,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "太鼓标识"
+  },
+  {
+    "itemName": "in_room",
+    "imageName": "res_in_room.png",
+    "roiFront": "15,524,77,79",
+    "roiBack": "15,524,77,79",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "房间标识"
+  },
+  {
+    "itemName": "in_fight",
+    "imageName": "res_in_fight.png",
+    "roiFront": "87,17,41,34",
+    "roiBack": "87,17,41,34",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "判断是否进入战斗"
+  }
+]

BIN
tasks/MyOrochi/res/res_fire_sign.png


BIN
tasks/MyOrochi/res/res_gu.png


BIN
tasks/MyOrochi/res/res_in_fight.png


BIN
tasks/MyOrochi/res/res_in_room.png


BIN
tasks/MyOrochi/res/res_orichi_end.png


BIN
tasks/MyOrochi/res/res_orichi_glod.png


BIN
tasks/MyOrochi/res/res_second_pit_position.png


+ 107 - 0
tasks/MyOrochi/script_task.py

@@ -0,0 +1,107 @@
+# This Python file uses the following encoding: utf-8
+import time
+
+import random
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.GameUi.game_ui import GameUi
+from tasks.DevExploration.assets import DevExplorationAssets
+from tasks.MyOrochi.assets import MyOrochiAssets
+from module.logger import logger
+from tasks.MyOrochi.config import RoleMode
+
+safe_click = (MyOrochiAssets.C_SAFE_AREA_1, MyOrochiAssets.C_SAFE_AREA_2)
+
+
+def random_delay(min_value: float = 1.0, max_value: float = 2.0, decimal: int = 1):
+    """
+    生成一个指定范围内的随机小数
+    """
+    random_float_in_range = random.uniform(min_value, max_value)
+    return (round(random_float_in_range, decimal))
+
+
+class ScriptTask(GeneralBattle, GameUi, DevExplorationAssets):
+
+    def run(self):
+        options = self.config.my_orochi
+        if options.orochi_config.mode == RoleMode.CAPTAIN:
+            logger.info("Run Role: %s" % str(options.orochi_config.mode))
+            return self._run_captain()
+        elif options.orochi_config.mode == RoleMode.MEMBER:
+            logger.info("Run Role: %s" % str(options.orochi_config.mode))
+            return self._run_member()
+        else:
+            logger.exception("Invalid mode, please choice [captain] or [member]")
+
+    def _run_captain(self):
+        count = 1
+        while True:
+            self.screenshot()
+            if self.in_room():
+                self.wait_until_disappear(MyOrochiAssets.I_SECOND_PIT_POSITION)
+                # time.sleep(random_delay(0.3, 1, decimal=2))
+                self.ui_click_until_disappear(MyOrochiAssets.I_FIRE_SIGN)
+            if self.in_fight():
+                logger.hr('检测到进入战斗: %s' % str(count), level=1)
+                self._run_battle()
+                count += 1
+            time.sleep(0.2)
+
+    def _run_member(self):
+        count = 1
+        while True:
+            self.screenshot()
+            if self.in_fight():
+                logger.hr('检测到进入战斗: %s' % str(count), level=1)
+                self._run_battle()
+                count += 1
+            time.sleep(0.2)
+
+    def _run_battle(self):
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        self.device.click_record_clear()
+        while True:
+            self.screenshot()
+            if self.appear(MyOrochiAssets.I_GU):
+                for i in range(random.randint(2, 4)):
+                    self.click(random.choice(safe_click))
+                    time.sleep(random_delay(0.08, 0.2, decimal=2))
+            if self.appear(MyOrochiAssets.I_ORICHI_END):
+                interval = random_delay(0.1, 0.2, decimal=2)
+                self.ui_click_u_disappear(click=random.choice(safe_click),
+                                          stop=MyOrochiAssets.I_ORICHI_END, interval=interval)
+                return True
+            if self.appear(MyOrochiAssets.I_ORICHI_GLOD):
+                interval = random_delay(0.12, 0.25, decimal=2)
+                self.ui_click_u_disappear(click=random.choice(safe_click),
+                                          stop=MyOrochiAssets.I_ORICHI_GLOD, interval=interval)
+                return True
+            if self.appear(self.I_FALSE):
+                logger.warning('False battle')
+                self.ui_click_until_disappear(self.I_FALSE)
+                return False
+            time.sleep(0.2)
+
+    def in_fight(self):
+        self.screenshot()
+        if self.appear(self.I_EXIT):
+            return True
+        else:
+            return False
+
+    def in_room(self):
+        self.screenshot()
+        if self.appear(MyOrochiAssets.I_IN_ROOM):
+            return True
+        else:
+            return False
+
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+
+    config = Config('oas2')
+    device = Device(config)
+    t = ScriptTask(config, device)
+    t.run()

+ 1 - 1
tasks/Orochi/assets.py

@@ -20,7 +20,7 @@ class OrochiAssets:
 	# description 
 	I_OROCHI_UNLOCK = RuleImage(roi_front=(562,564,26,29), roi_back=(550,553,100,51), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_unlock.png")
 	# 点击挑战 
-	I_OROCHI_FIRE = RuleImage(roi_front=(1095,577,131,124), roi_back=(1095,577,131,124), threshold=0.6, method="Template matching", file="./tasks/Orochi/o/o_orochi_fire.png")
+	I_OROCHI_FIRE = RuleImage(roi_front=(1095,577,131,124), roi_back=(1095,577,131,124), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_wild_fire.png")
 	# 式神录 
 	I_SHI_RECORDS = RuleImage(roi_front=(821,638,48,45), roi_back=(821,638,48,45), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_shi_records.png")
 	# description 

+ 25 - 9
tasks/base_task.py

@@ -174,7 +174,7 @@ class BaseTask(GlobalGameAssets):
     def wait_until_appear(self,
                           target: RuleImage,
                           skip_first_screenshot=False,
-                          wait_time: int=None) -> bool:
+                          wait_time: int = None) -> bool:
         """
         等待直到出现目标
         :param wait_time: 等待时间,单位秒
@@ -427,7 +427,7 @@ class BaseTask(GlobalGameAssets):
                 sleep(1)  # 等待滑动完成, 还没想好如何优化
 
     def set_next_run(self, task: str, finish: bool = False,
-                     success: bool=None, server: bool=True, target: datetime=None) -> None:
+                     success: bool = None, server: bool = True, target: datetime = None) -> None:
         """
         设置下次运行时间  当然这个也是可以重写的
         :param target: 可以自定义的下次运行时间
@@ -491,8 +491,7 @@ class BaseTask(GlobalGameAssets):
 
         return True
 
-
-    def ui_click(self, click, stop):
+    def ui_click(self, click, stop, interval=1):
         """
         循环的一个操作,直到出现stop
         :param click:
@@ -503,11 +502,30 @@ class BaseTask(GlobalGameAssets):
             self.screenshot()
             if self.appear(stop):
                 break
-            if isinstance(click, RuleImage) and self.appear_then_click(click, interval=1):
+            if isinstance(click, RuleImage) and self.appear_then_click(click, interval=interval):
+                continue
+            if isinstance(click, RuleClick) and self.click(click, interval=interval):
+                continue
+            elif isinstance(click, RuleOcr) and self.ocr_appear_click(click, interval=interval):
+                continue
+
+    def ui_click_u_disappear(self, click, stop, interval=1):
+        """
+        循环的一个操作,直到 stop 消失
+        :param click:
+        :param stop:
+        :param interval:
+        :return:
+        """
+        while 1:
+            self.screenshot()
+            if not self.appear(stop):
+                break
+            if isinstance(click, RuleImage) and self.appear_then_click(click, interval=interval):
                 continue
-            if isinstance(click, RuleClick) and self.click(click, interval=1):
+            if isinstance(click, RuleClick) and self.click(click, interval=interval):
                 continue
-            elif isinstance(click, RuleOcr) and self.ocr_appear_click(click, interval=1):
+            elif isinstance(click, RuleOcr) and self.ocr_appear_click(click, interval=interval):
                 continue
 
     def ui_click_until_disappear(self, click):
@@ -522,5 +540,3 @@ class BaseTask(GlobalGameAssets):
                 break
             elif self.appear_then_click(click, interval=1):
                 continue
-
-