runhey 3 лет назад
Родитель
Сommit
cffef77714
49 измененных файлов с 838 добавлено и 39 удалено
  1. 2 2
      module/atom/image.py
  2. 227 0
      module/atom/list.py
  3. 85 12
      module/dev_tools/assets_extract.py
  4. 1 1
      module/gui/qml/Component/RuleFile2.qml
  5. 1 0
      tasks/AreaBoss/assets.py
  6. 1 0
      tasks/CoinChallenge/assets.py
  7. 97 0
      tasks/Component/GeneralBattle/assets.py
  8. 110 0
      tasks/Component/GeneralBattle/click.json
  9. 164 0
      tasks/Component/GeneralBattle/image.json
  10. BIN
      tasks/Component/GeneralBattle/res_buff.png
  11. BIN
      tasks/Component/GeneralBattle/res_buff_awaken.png
  12. BIN
      tasks/Component/GeneralBattle/res_buff_exp_100.png
  13. BIN
      tasks/Component/GeneralBattle/res_buff_exp_50.png
  14. BIN
      tasks/Component/GeneralBattle/res_buff_gold_100.png
  15. BIN
      tasks/Component/GeneralBattle/res_buff_gold_50.png
  16. BIN
      tasks/Component/GeneralBattle/res_buff_soul.png
  17. BIN
      tasks/Component/GeneralBattle/res_exit.png
  18. BIN
      tasks/Component/GeneralBattle/res_exit_ensure.png
  19. BIN
      tasks/Component/GeneralBattle/res_false.png
  20. BIN
      tasks/Component/GeneralBattle/res_local.png
  21. BIN
      tasks/Component/GeneralBattle/res_prepare_dark.png
  22. BIN
      tasks/Component/GeneralBattle/res_prepare_highlight.png
  23. BIN
      tasks/Component/GeneralBattle/res_preset.png
  24. BIN
      tasks/Component/GeneralBattle/res_preset_ensure.png
  25. BIN
      tasks/Component/GeneralBattle/res_reward.png
  26. BIN
      tasks/Component/GeneralBattle/res_statistics.png
  27. BIN
      tasks/Component/GeneralBattle/res_win.png
  28. 16 0
      tasks/Component/GeneralBattle/swipe.json
  29. 1 0
      tasks/DemonEncounter/assets.py
  30. 1 0
      tasks/EternitySea/assets.py
  31. 1 0
      tasks/ExperienceYoukai/assets.py
  32. 1 0
      tasks/FallenSun/assets.py
  33. 1 0
      tasks/GameUi/assets.py
  34. 1 0
      tasks/General/assets.py
  35. 1 0
      tasks/GeneralBattle/assets.py
  36. 1 0
      tasks/GlobalGame/assets.py
  37. 1 0
      tasks/GoldYoukai/assets.py
  38. 1 0
      tasks/Hunt/assets.py
  39. 1 0
      tasks/Nian/assets.py
  40. 8 1
      tasks/Orochi/assets.py
  41. 57 0
      tasks/Orochi/res/list.json
  42. 1 0
      tasks/OrochiJudgement/assets.py
  43. 1 0
      tasks/OrochiMoans/assets.py
  44. 1 0
      tasks/RealmRaid/assets.py
  45. 1 0
      tasks/Restart/assets.py
  46. 1 0
      tasks/Script/assets.py
  47. 1 0
      tasks/Sougenbi/assets.py
  48. 1 0
      tasks/Utils/assets.py
  49. 51 23
      tasks/base_task.py

+ 2 - 2
module/atom/image.py

@@ -17,8 +17,8 @@ class RuleImage:
         初始化
         :param roi_front: 前置roi
         :param roi_back: 后置roi 用于匹配的区域
-        :param method: 匹配方法
-        :param threshold: 阈值
+        :param method: 匹配方法 "Template matching"
+        :param threshold: 阈值  0.8
         :param file: 相对路径, 带后缀
         """
         self.roi_front: list = list(roi_front)

+ 227 - 0
module/atom/list.py

@@ -0,0 +1,227 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+
+import cv2
+import random
+import numpy as np
+
+from random import randint
+
+from ppocronnx.predict_system import BoxedResult
+from module.atom.ocr import RuleOcr
+from module.atom.image import RuleImage
+from module.logger import logger
+
+
+class RuleList:
+
+    def __init__(self, folder: str, direction: str, mode: str, roi_back: tuple, size: tuple, array: list[str]) -> None:
+        """
+        初始化
+        :param folder:
+        :param direction:
+        :param mode:
+        :param roi_back:
+        :param size:
+        :param array:
+        """
+        self.folder = folder
+        self.is_vertical = direction == "vertical"
+        self.is_image = mode == "image"
+        self.is_ocr = mode == "ocr"
+        self.roi_back: list = list(roi_back)
+        self.size: list = list(size)
+        # 这个表示一个区域中一次所能显示的最大数量
+        self.max_show: int = self.roi_back[3] // self.size[1] if self.is_vertical else self.roi_back[2] // self.size[0]
+
+        self.array: list = array
+
+        # 以下是需要计算的
+        self.appear_area: list = None  # 出现的区域
+        self.is_bottom = False  # 表示是否已经滑动到底部了
+        self._target = None  # 目标
+        self.targets = {}  # 目标列表 只是针对image
+
+    def swipe_pos(self, number: int=2, after: bool=True) -> tuple:
+        """
+        返回滑动的起始位置和终点位置
+        :param number:
+        :param after:
+        :return:
+        """
+        center: tuple = (self.roi_back[0] + self.roi_back[2]) // 2, (self.roi_back[1] + self.roi_back[3]) // 2
+        distance: int = self.size[1] * number if self.is_vertical else self.size[0] * number
+        random_start: int = randint(- self.size[0] // 4, self.size[0] // 4) if self.is_vertical else randint(- self.size[1] // 4, self.size[1] // 4)
+        random_end: int = randint(- self.size[0] // 4, self.size[0] // 4) if self.is_vertical else randint(- self.size[1] // 4, self.size[1] // 4)
+
+        x1, y1, x2, y2 = None, None, None, None
+        if self.is_vertical:
+            if after:
+                # 竖直方向向下滑动, 那就是起始点是在下面 终点是在上面
+                x1, y1 = center[0]+random_start, center[1] + distance//2
+                x2, y2 = center[0]+random_end, center[1] - distance//2
+            else:
+                # 竖直方向向上滑动, 那就是起始点是在上面 终点是在下面
+                x1, y1 = center[0]+random_start, center[1] - distance//2
+                x2, y2 = center[0]+random_end, center[1] + distance//2
+        else:
+            if after:
+                # 水平方向向右滑动, 那就是起始点是在右面 终点是在左面
+                x1, y1 = center[0] + distance//2, center[1]+random_start
+                x2, y2 = center[0] - distance//2, center[1]+random_end
+            else:
+                # 水平方向向左滑动, 那就是起始点是在左面 终点是在右面
+                x1, y1 = center[0] - distance//2, center[1]+random_start
+                x2, y2 = center[0] + distance//2, center[1]+random_end
+
+        if x1 is None or y1 is None or x2 is None or y2 is None:
+            raise Exception("滑动位置计算错误")
+        return x1, y1, x2, y2
+
+    def target_check(self, name: str) -> bool:
+        """
+        检查输入的名称
+        :param name:
+        :return:
+        """
+        # 首先获取构建类的信息
+        # roi_front = None
+        # for item in self.array:
+        #     if item["itemName"] == name:
+        #         roi_front = item["roiFront"].split(",")
+        #         break
+        # if roi_front is None:
+        #     logger.error(f'Not found {name} in {self.array}')
+        #     return False
+        file = self.folder + "/" + name + ".png"
+
+        # 保证匹配的目标 是正确的
+        if self.is_image:
+            if self._target is None or isinstance(self._target, RuleOcr):
+                self._target = RuleImage(roi_front=self.roi_back, roi_back=self.roi_back, method="Template matching", threshold=0.8, file=file)
+            # 如果不对的话,就重新构建
+            elif self._target.name != name:
+                self._target = RuleImage(roi_front=self.roi_back, roi_back=self.roi_back, method="Template matching", threshold=0.8, file=file)
+            else:
+                pass
+        elif self.is_ocr:
+            if self._target is None or isinstance(self._target, RuleImage):
+                self._target = RuleOcr(roi=self.roi_back, area=(0, 0, 10, 10), mode="Full", method="Default",
+                                       keyword=name, name=name)
+            elif self._target.name != name:
+                self._target.name = name
+                self._target.keyword = name
+        else:
+            logger.error(f'Not found {name} in {self.array}')
+            return False
+
+    def targets_check(self, targets: list):
+        """
+        检查输入的图片名是缓存有
+        :param targets:
+        :return:
+        """
+        for item in targets:
+            if item in self.targets:
+                continue
+            # 如果还没有缓存的话就先缓存
+            file = self.folder + "/" + item + ".png"
+            self.targets[item] = RuleImage(roi_front=self.roi_back, roi_back=self.roi_back,
+                                           method="Template matching", threshold=0.8, file=file)
+
+    def image_appear(self, image: np.array, name: str) -> bool | tuple:
+        """
+        判断是否出现了某个图片
+        :param image: 屏幕的截图
+        :param name:
+        :return: 如果在当前的显示中,返回可以点击的坐标.如果不是出现就是返回False
+        """
+        if self.is_image and isinstance(name, str):
+            self.target_check(name)
+            appear = self._target.match(image)
+            if appear:
+                return self._target.coord()
+            else:
+                return False
+        elif self.is_image and isinstance(name, list):
+            self.targets_check(name)
+            for item in name:
+                appear = self.targets[item].match(image)
+                if appear:
+                    return self.targets[item].coord()
+            return False
+
+        else:
+            logger.error(f'Mode is not image')
+            return False
+
+    def ocr_appear(self, image: np.array, name: str):
+        """
+        判断是否出现了某个文字,
+        :param image: 屏幕的截图
+        :param name:
+        :return: 如果是出现的返回可以点击的坐标 x , y
+        如果是在当前显示的前面则返回小于零的int, 如果是在当前显示的后面则返回大于零的int,
+        """
+        if self.is_image:
+            return False
+        self.target_check(name)
+
+        # 开始一次ocr的检测
+        boxed_results: list[BoxedResult] = self._target.detect_and_ocr(image)
+        if not boxed_results:
+            logger.warning(f'Not angy result in image')
+            return 0, 0
+
+        # 判断所有的结果,给获取的列表建立引索
+        # index_list = self._target.filter(boxed_results, name)
+        # logger.info(index_list)
+        box = None
+        for item in boxed_results:
+            if item.ocr_text == name and item.score > RuleOcr.score:
+                box = item.box
+                break
+        if box is not None:
+            rec_x, rec_y, rec_w, rec_h = box[0, 0], box[0, 1], box[1, 0] - box[0, 0], box[2, 1] - box[0, 1]
+            x = rec_x + rec_w // 2
+            y = rec_y + rec_h // 2
+            return x, y
+
+        # if index_list and len(index_list) >= 1:
+        #     box = boxed_results[index_list[0]].box
+        #     rec_x, rec_y, rec_w, rec_h = box[0, 0], box[0, 1], box[1, 0] - box[0, 0], box[2, 1] - box[0, 1]
+        #     return rec_x+self.roi_back[0], rec_y+self.roi_back[1], rec_w, rec_h
+
+        # 如果没有找到,那么应该不是在当前的页面,需要获取当前的信息判断是往前滑动还是往后滑动
+        else:
+            keyword_list: list = [item.ocr_text for item in boxed_results if item.score > RuleOcr.score]
+
+            start_index = self.array.index(keyword_list[0])
+            end_index = self.array.index(keyword_list[-1])
+            if name in keyword_list:
+                distance_start = 0
+                distance_end = 0
+
+            current_index = self.array.index(name)
+            distance_start = 0
+            distance_end = 0
+            if current_index < start_index or current_index > end_index:
+                distance_start = current_index - start_index
+                distance_end = current_index - end_index
+            # 如果目标的是在当前的显示的前面, 则distance为负的
+            # 如果目标的是在当前的显示的后面, 则distance为正的
+            # 所有前面返回的是负的,后面返回的是正的
+            if distance_start == 0 and distance_end == 0:
+                logger.error(f'{name} not found in {keyword_list}')
+
+            return (distance_start + distance_end) // 2
+
+
+if __name__ == '__main__':
+    L_N33AME = RuleList(folder="./tasks/Orochi/res", direction="vertical", mode="ocr", roi_back=(160, 130, 317, 500),
+                        size=(301, 86),
+                        array=["壹层", "贰层", "叁层", "肆层", "伍层", "陆层", "柒层", "捌层", "玖层", "拾层", "悲鸣", "神罚"])
+    image = cv2.imread("D:/watu_list_text204237.png")
+    print(L_N33AME.ocr_appear(image, "柒层"))
+    print(L_N33AME.ocr_appear(image, "神罚"))

+ 85 - 12
module/dev_tools/assets_extract.py

@@ -18,6 +18,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.
@@ -191,18 +192,70 @@ class OcrExtractor:
                     f'name="{item["itemName"]}")\n'
         return description + name
 
+
+class ListExtractor:
+    def __init__(self, file: str, data: dict) -> None:
+        """
+        List rule 提取
+        :param data:  json解析后的数据
+        """
+        self.file = str(Path(file).resolve().relative_to((Path.cwd()).resolve()).as_posix())
+        self.image_path = Path(self.file).parent.as_posix()
+        self._result = '\n\n\t# List Rule Assets\n'
+
+        if not isinstance(data, dict):
+            raise TypeError("data must be dict")
+
+        self._result += self.extract(data)
+
+    @property
+    def result(self) -> str:
+        return self._result
+
+    def extract(self, data) -> str:
+        """
+        解析每一项,返回字符串
+        :param data:
+        :return:
+        """
+        width, height = 0, 0
+        array: list = []
+        for item in data["list"]:
+            roi_front = item["roiFront"].split(",")
+            width += int(roi_front[2])
+            height += int(roi_front[3])
+            array.append(f'"{item["itemName"]}"')
+        width = int(width / len(data["list"]))
+        height = int(height / len(data["list"]))
+        array = ', '.join(array)
+
+        description: str = f'\t# {data["description"]} \n'
+        name: str = f'\tL_{name_transform(data["name"])} = RuleList(' \
+                    f'folder="./{str(self.image_path)}", ' \
+                    f'direction="{data["direction"]}", ' \
+                    f'mode="{data["type"]}", ' \
+                    f'roi_back=({data["roiBack"]}), ' \
+                    f'size=({width}, {height}), ' \
+                    f'\n\t\t\t\t\t array=[{str(array)}])\n'
+        return description + name
+
+
+
+
+
 class AssetsExtractor:
 
-    def __init__(self, task_name: str) -> None:
+    def __init__(self, task_path: str) -> None:
         """
         assets 提取某个任务文件夹下的所以的资源
         :param task_name: 任务名
         """
-        self.task_name = task_name
-        self.task_path = Path.cwd() / MODULE_FOLDER / task_name
-        self.assets_file = Path.cwd() / MODULE_FOLDER / task_name / ASSETS_FILE
 
-        self.class_name = f'\nclass {task_name}Assets: \n'
+        self.task_path = Path(task_path)
+        self.task_name = self.task_path.name
+        self.assets_file = self.task_path / ASSETS_FILE
+
+        self.class_name = f'\nclass {self.task_name}Assets: \n'
 
         self._result = ''
         for import_exp in IMPORT_EXP:
@@ -226,8 +279,8 @@ class AssetsExtractor:
         """
         with open(file, 'r', encoding='utf-8') as f:
             data = json.load(f)
-        if not isinstance(data, list):
-            logger.error(f'{file} 文件解析错误,不是list')
+        if not isinstance(data, list) and not isinstance(data, dict):
+            logger.error(f'{file} 文件解析错误,不是list 或者 dict')
             return None
         return data
 
@@ -289,6 +342,18 @@ class AssetsExtractor:
             return True
         return False
 
+    @classmethod
+    def is_list_file(cls, data) -> bool:
+        """
+
+        :param data:
+        :return:
+        """
+        if isinstance(data, dict) and 'name' in data:
+            return True
+        return False
+
+
     def write_file(self) -> None:
         """
         将自身的_resule写入文件
@@ -307,6 +372,10 @@ class AssetsExtractor:
             data = self.read_file(file)
             if not data:
                 continue
+
+            if self.is_list_file(data):
+                result += ListExtractor(file, data).result
+                continue
             if self.is_image_file(data):
                 result += ImageExtractor(file, data).result
             elif self.is_click_file(data):
@@ -335,16 +404,20 @@ class AllAssetsExtractor:
         logger.info('All assets extract')
         self.task_path = Path.cwd() / MODULE_FOLDER
         self.task_list = [x.name for x in self.task_path.iterdir() if x.is_dir()]
-        process_map(self.work, self.task_list, max_workers=4)
+
+        self.task_paths = [str(x) for x in self.task_path.iterdir() if x.is_dir()]
+        # 删除有Component的任务, 同时将其子路径加入任务列表
+        self.task_paths = [x for x in self.task_paths if 'Component' not in x]
+        self.task_paths.extend([str(x) for x in (self.task_path / 'Component').iterdir() if x.is_dir()])
+
+        process_map(self.work, self.task_paths, max_workers=4)
 
     @staticmethod
-    def work(task_name: str):
-        me = AssetsExtractor(task_name)
+    def work(task_path: str):
+        me = AssetsExtractor(task_path)
         me.extract()
 
 
 
 if __name__ == "__main__":
-    # c = AssetsExtractor('CoinChallenge')
-    # c.extract()
     AllAssetsExtractor()

+ 1 - 1
module/gui/qml/Component/RuleFile2.qml

@@ -189,7 +189,7 @@ FluArea {
                     }
                     placeholderText:"item name"
                     text: model.itemName
-                    validator: RegularExpressionValidator { regularExpression: /^[a-z0-9_]*$/ }
+//                    validator: RegularExpressionValidator { regularExpression: /^[a-z0-9_]*$/ }
                     onActiveFocusChanged: {
                         if(activeFocus){
                             currentItem = listModel.get(index)

+ 1 - 0
tasks/AreaBoss/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/CoinChallenge/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 97 - 0
tasks/Component/GeneralBattle/assets.py

@@ -0,0 +1,97 @@
+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 module/dev_tools/assets_extract.py.
+# Don't modify it manually.
+class GeneralBattleAssets: 
+
+
+	# Click Rule Assets
+	# 预设队伍1 
+	C_PRESET_TEAM_1 = RuleClick(roi_front=(196,234,464,114), roi_back=(196,234,464,114), name="preset_team_1")
+	# 预设队伍2 
+	C_PRESET_TEAM_2 = RuleClick(roi_front=(197,358,465,103), roi_back=(197,358,465,103), name="preset_team_2")
+	# 预设队伍3 
+	C_PRESET_TEAM_3 = RuleClick(roi_front=(195,480,462,100), roi_back=(195,480,462,100), name="preset_team_3")
+	# 预设队伍4 
+	C_PRESET_TEAM_4 = RuleClick(roi_front=(193,596,464,35), roi_back=(193,596,464,35), name="preset_team_4")
+	# 预设组1 
+	C_PRESET_GROUP_1 = RuleClick(roi_front=(28,238,134,56), roi_back=(28,238,134,56), name="preset_group_1")
+	# 预设组2 
+	C_PRESET_GROUP_2 = RuleClick(roi_front=(31,298,132,60), roi_back=(31,298,132,60), name="preset_group_2")
+	# 预设组3 
+	C_PRESET_GROUP_3 = RuleClick(roi_front=(31,362,135,59), roi_back=(31,362,135,59), name="preset_group_3")
+	# 预设组4 
+	C_PRESET_GROUP_4 = RuleClick(roi_front=(29,427,133,57), roi_back=(29,427,133,57), name="preset_group_4")
+	# 预设组5 
+	C_PRESET_GROUP_5 = RuleClick(roi_front=(31,489,133,60), roi_back=(31,489,133,60), name="preset_group_5")
+	# 预设组6 
+	C_PRESET_GROUP_6 = RuleClick(roi_front=(31,549,132,63), roi_back=(31,549,132,63), name="preset_group_6")
+	# 预设组7 
+	C_PRESET_GROUP_7 = RuleClick(roi_front=(29,615,137,63), roi_back=(29,615,137,63), name="preset_group_7")
+	# 从左开始第一个绿标 
+	C_GREEN_LEFT_1 = RuleClick(roi_front=(128,433,90,150), roi_back=(128,433,90,150), name="green_left_1")
+	# 从左开始第二个绿标 
+	C_GREEN_LEFT_2 = RuleClick(roi_front=(371,385,81,145), roi_back=(371,385,81,145), name="green_left_2")
+	# 从左开始第三个绿标 
+	C_GREEN_LEFT_3 = RuleClick(roi_front=(586,328,100,76), roi_back=(586,328,100,76), name="green_left_3")
+	# 从左开始第四个绿标 
+	C_GREEN_LEFT_4 = RuleClick(roi_front=(817,379,77,133), roi_back=(817,379,77,133), name="green_left_4")
+	# 从左开始第五个绿标 
+	C_GREEN_LEFT_5 = RuleClick(roi_front=(1059,416,85,145), roi_back=(1059,416,85,145), name="green_left_5")
+	# 绿标阴阳师 
+	C_GREEN_MAIN = RuleClick(roi_front=(590,454,88,178), roi_back=(590,454,88,178), name="green_main")
+	# 战斗的时候有一定的概率随机点击 
+	C_RANDOM_CLICK = RuleClick(roi_front=(104,79,1050,507), roi_back=(255,65,100,100), name="random_click")
+
+
+	# Image Rule Assets
+	# 奖励,就是那个魂 
+	I_REWARD = RuleImage(roi_front=(547,518,172,96), roi_back=(547,518,172,96), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_reward.png")
+	# 预设的小图标 
+	I_PRESET = RuleImage(roi_front=(32,650,47,45), roi_back=(32,650,47,45), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_preset.png")
+	# 准备 
+	I_PREPARE_HIGHLIGHT = RuleImage(roi_front=(1128,536,100,100), roi_back=(1128,536,100,100), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_prepare_highlight.png")
+	# 战斗胜利 
+	I_WIN = RuleImage(roi_front=(427,135,100,100), roi_back=(427,135,100,100), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_win.png")
+	# 准备但是界面还未加载这个时候是黑色的 
+	I_PREPARE_DARK = RuleImage(roi_front=(1131,538,100,100), roi_back=(1131,538,100,100), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_prepare_dark.png")
+	# 失败 
+	I_FALSE = RuleImage(roi_front=(413,124,100,100), roi_back=(413,124,100,100), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_false.png")
+	# 确认预设的队伍 
+	I_PRESET_ENSURE = RuleImage(roi_front=(354,641,141,50), roi_back=(354,641,141,50), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_preset_ensure.png")
+	# 选择buff 
+	I_BUFF = RuleImage(roi_front=(113,653,44,62), roi_back=(113,653,44,62), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_buff.png")
+	# 觉醒加成 
+	I_BUFF_AWAKEN = RuleImage(roi_front=(373,126,383,53), roi_back=(373,126,383,53), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_buff_awaken.png")
+	# 御魂加成 
+	I_BUFF_SOUL = RuleImage(roi_front=(377,192,371,56), roi_back=(377,192,371,56), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_buff_soul.png")
+	# 金币加成50 
+	I_BUFF_GOLD_50 = RuleImage(roi_front=(375,259,373,56), roi_back=(375,259,373,56), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_buff_gold_50.png")
+	# 金币加成100 
+	I_BUFF_GOLD_100 = RuleImage(roi_front=(371,329,389,54), roi_back=(371,329,389,54), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_buff_gold_100.png")
+	# 经验加成50 
+	I_BUFF_EXP_50 = RuleImage(roi_front=(378,400,370,50), roi_back=(378,400,370,50), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_buff_exp_50.png")
+	# 经验加成100 
+	I_BUFF_EXP_100 = RuleImage(roi_front=(372,463,386,50), roi_back=(372,463,386,50), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_buff_exp_100.png")
+	# 左下角的位置指针 
+	I_LOCAL = RuleImage(roi_front=(25,563,30,34), roi_back=(25,563,30,34), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_local.png")
+	# description 
+	I_STATISTICS = RuleImage(roi_front=(61,644,33,28), roi_back=(61,644,33,28), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_statistics.png")
+	# 左上角的退出 
+	I_EXIT = RuleImage(roi_front=(14,12,43,41), roi_back=(14,12,43,41), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_exit.png")
+	# 退出确认 
+	I_EXIT_ENSURE = RuleImage(roi_front=(674,388,135,63), roi_back=(674,388,135,63), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/res_exit_ensure.png")
+
+
+	# Swipe Rule Assets
+	# description 
+	S_BATTLE_RANDOM_LEFT = RuleSwipe(roi_front=(122,155,480,426), roi_back=(667,147,461,427), mode="default", name="battle_random_left")
+	# description 
+	S_BATTLE_RANDOM_RIGHT = RuleSwipe(roi_front=(719,138,417,392), roi_back=(237,163,387,394), mode="default", name="battle_random_right")
+
+

+ 110 - 0
tasks/Component/GeneralBattle/click.json

@@ -0,0 +1,110 @@
+[
+    {
+        "itemName": "preset_team_1",
+        "roiFront": "196,234,464,114",
+        "roiBack": "196,234,464,114",
+        "description": "预设队伍1"
+    },
+    {
+        "itemName": "preset_team_2",
+        "roiFront": "197,358,465,103",
+        "roiBack": "197,358,465,103",
+        "description": "预设队伍2"
+    },
+    {
+        "itemName": "preset_team_3",
+        "roiFront": "195,480,462,100",
+        "roiBack": "195,480,462,100",
+        "description": "预设队伍3"
+    },
+    {
+        "itemName": "preset_team_4",
+        "roiFront": "193,596,464,35",
+        "roiBack": "193,596,464,35",
+        "description": "预设队伍4"
+    },
+    {
+        "itemName": "preset_group_1",
+        "roiFront": "28,238,134,56",
+        "roiBack": "28,238,134,56",
+        "description": "预设组1"
+    },
+    {
+        "itemName": "preset_group_2",
+        "roiFront": "31,298,132,60",
+        "roiBack": "31,298,132,60",
+        "description": "预设组2"
+    },
+    {
+        "itemName": "preset_group_3",
+        "roiFront": "31,362,135,59",
+        "roiBack": "31,362,135,59",
+        "description": "预设组3"
+    },
+    {
+        "itemName": "preset_group_4",
+        "roiFront": "29,427,133,57",
+        "roiBack": "29,427,133,57",
+        "description": "预设组4"
+    },
+    {
+        "itemName": "preset_group_5",
+        "roiFront": "31,489,133,60",
+        "roiBack": "31,489,133,60",
+        "description": "预设组5"
+    },
+    {
+        "itemName": "preset_group_6",
+        "roiFront": "31,549,132,63",
+        "roiBack": "31,549,132,63",
+        "description": "预设组6"
+    },
+    {
+        "itemName": "preset_group_7",
+        "roiFront": "29,615,137,63",
+        "roiBack": "29,615,137,63",
+        "description": "预设组7"
+    },
+    {
+        "itemName": "green_left_1",
+        "roiFront": "128,433,90,150",
+        "roiBack": "128,433,90,150",
+        "description": "从左开始第一个绿标"
+    },
+    {
+        "itemName": "green_left_2",
+        "roiFront": "371,385,81,145",
+        "roiBack": "371,385,81,145",
+        "description": "从左开始第二个绿标"
+    },
+    {
+        "itemName": "green_left_3",
+        "roiFront": "586,328,100,76",
+        "roiBack": "586,328,100,76",
+        "description": "从左开始第三个绿标"
+    },
+    {
+        "itemName": "green_left_4",
+        "roiFront": "817,379,77,133",
+        "roiBack": "817,379,77,133",
+        "description": "从左开始第四个绿标"
+    },
+    {
+        "itemName": "green_left_5",
+        "roiFront": "1059,416,85,145",
+        "roiBack": "1059,416,85,145",
+        "description": "从左开始第五个绿标"
+    },
+    {
+        "itemName": "green_main",
+        "roiFront": "590,454,88,178",
+        "roiBack": "590,454,88,178",
+        "description": "绿标阴阳师"
+    },
+    {
+        "itemName": "random_click",
+        "roiFront": "104,79,1050,507",
+        "roiBack": "255,65,100,100",
+        "description": "战斗的时候有一定的概率随机点击"
+    }
+]

+ 164 - 0
tasks/Component/GeneralBattle/image.json

@@ -0,0 +1,164 @@
+[
+  {
+    "itemName": "reward",
+    "imageName": "res_reward.png",
+    "roiFront": "547,518,172,96",
+    "roiBack": "547,518,172,96",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "奖励,就是那个魂"
+  },
+  {
+    "itemName": "preset",
+    "imageName": "res_preset.png",
+    "roiFront": "32,650,47,45",
+    "roiBack": "32,650,47,45",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "预设的小图标"
+  },
+  {
+    "itemName": "prepare_highlight",
+    "imageName": "res_prepare_highlight.png",
+    "roiFront": "1128,536,100,100",
+    "roiBack": "1128,536,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "准备"
+  },
+  {
+    "itemName": "win",
+    "imageName": "res_win.png",
+    "roiFront": "427,135,100,100",
+    "roiBack": "427,135,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "战斗胜利"
+  },
+  {
+    "itemName": "prepare_dark",
+    "imageName": "res_prepare_dark.png",
+    "roiFront": "1131,538,100,100",
+    "roiBack": "1131,538,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "准备但是界面还未加载这个时候是黑色的"
+  },
+  {
+    "itemName": "false",
+    "imageName": "res_false.png",
+    "roiFront": "413,124,100,100",
+    "roiBack": "413,124,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "失败"
+  },
+  {
+    "itemName": "preset_ensure",
+    "imageName": "res_preset_ensure.png",
+    "roiFront": "354,641,141,50",
+    "roiBack": "354,641,141,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "确认预设的队伍"
+  },
+  {
+    "itemName": "buff",
+    "imageName": "res_buff.png",
+    "roiFront": "113,653,44,62",
+    "roiBack": "113,653,44,62",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "选择buff"
+  },
+  {
+    "itemName": "buff_awaken",
+    "imageName": "res_buff_awaken.png",
+    "roiFront": "373,126,383,53",
+    "roiBack": "373,126,383,53",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "觉醒加成"
+  },
+  {
+    "itemName": "buff_soul",
+    "imageName": "res_buff_soul.png",
+    "roiFront": "377,192,371,56",
+    "roiBack": "377,192,371,56",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "御魂加成"
+  },
+  {
+    "itemName": "buff_gold_50",
+    "imageName": "res_buff_gold_50.png",
+    "roiFront": "375,259,373,56",
+    "roiBack": "375,259,373,56",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "金币加成50"
+  },
+  {
+    "itemName": "buff_gold_100",
+    "imageName": "res_buff_gold_100.png",
+    "roiFront": "371,329,389,54",
+    "roiBack": "371,329,389,54",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "金币加成100"
+  },
+  {
+    "itemName": "buff_exp_50",
+    "imageName": "res_buff_exp_50.png",
+    "roiFront": "378,400,370,50",
+    "roiBack": "378,400,370,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "经验加成50"
+  },
+  {
+    "itemName": "buff_exp_100",
+    "imageName": "res_buff_exp_100.png",
+    "roiFront": "372,463,386,50",
+    "roiBack": "372,463,386,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "经验加成100"
+  },
+  {
+    "itemName": "local",
+    "imageName": "res_local.png",
+    "roiFront": "25,563,30,34",
+    "roiBack": "25,563,30,34",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左下角的位置指针"
+  },
+  {
+    "itemName": "statistics",
+    "imageName": "res_statistics.png",
+    "roiFront": "61,644,33,28",
+    "roiBack": "61,644,33,28",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "exit",
+    "imageName": "res_exit.png",
+    "roiFront": "14,12,43,41",
+    "roiBack": "14,12,43,41",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角的退出"
+  },
+  {
+    "itemName": "exit_ensure",
+    "imageName": "res_exit_ensure.png",
+    "roiFront": "674,388,135,63",
+    "roiBack": "674,388,135,63",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "退出确认"
+  }
+]

BIN
tasks/Component/GeneralBattle/res_buff.png


BIN
tasks/Component/GeneralBattle/res_buff_awaken.png


BIN
tasks/Component/GeneralBattle/res_buff_exp_100.png


BIN
tasks/Component/GeneralBattle/res_buff_exp_50.png


BIN
tasks/Component/GeneralBattle/res_buff_gold_100.png


BIN
tasks/Component/GeneralBattle/res_buff_gold_50.png


BIN
tasks/Component/GeneralBattle/res_buff_soul.png


BIN
tasks/Component/GeneralBattle/res_exit.png


BIN
tasks/Component/GeneralBattle/res_exit_ensure.png


BIN
tasks/Component/GeneralBattle/res_false.png


BIN
tasks/Component/GeneralBattle/res_local.png


BIN
tasks/Component/GeneralBattle/res_prepare_dark.png


BIN
tasks/Component/GeneralBattle/res_prepare_highlight.png


BIN
tasks/Component/GeneralBattle/res_preset.png


BIN
tasks/Component/GeneralBattle/res_preset_ensure.png


BIN
tasks/Component/GeneralBattle/res_reward.png


BIN
tasks/Component/GeneralBattle/res_statistics.png


BIN
tasks/Component/GeneralBattle/res_win.png


+ 16 - 0
tasks/Component/GeneralBattle/swipe.json

@@ -0,0 +1,16 @@
+[
+    {
+        "itemName": "battle_random_left",
+        "roiFront": "122,155,480,426",
+        "roiBack": "667,147,461,427",
+        "mode": "default",
+        "description": "description"
+    },
+    {
+        "itemName": "battle_random_right",
+        "roiFront": "719,138,417,392",
+        "roiBack": "237,163,387,394",
+        "mode": "default",
+        "description": "description"
+    }
+]

+ 1 - 0
tasks/DemonEncounter/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/EternitySea/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/ExperienceYoukai/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/FallenSun/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/GameUi/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/General/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/GeneralBattle/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/GlobalGame/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/GoldYoukai/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/Hunt/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/Nian/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 8 - 1
tasks/Orochi/assets.py

@@ -3,9 +3,16 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.
 class OrochiAssets: 
-	pass
+
+
+	# List Rule Assets
+	# 这个是御魂界面选择不同层数的 
+	L_N33AME = RuleList(folder="./tasks/Orochi/res", direction="vertical", mode="ocr", roi_back=(160,130,317,500), size=(301, 86), 
+					 array=["壹层", "贰层", "叁层", "肆层", "伍层", "陆层", "柒层", "捌层", "玖层", "拾层", "悲鸣", "神罚"])
+
 

+ 57 - 0
tasks/Orochi/res/list.json

@@ -0,0 +1,57 @@
+{
+  "name": "n33ame",
+  "direction": "vertical",
+  "type": "ocr",
+  "roiBack": "160,130,317,500",
+  "description": "这个是御魂界面选择不同层数的",
+  "list": [
+    {
+      "itemName": "壹层",
+      "roiFront": "169,142,303,86"
+    },
+    {
+      "itemName": "贰层",
+      "roiFront": "168,253,300,85"
+    },
+    {
+      "itemName": "叁层",
+      "roiFront": "165,422,306,93"
+    },
+    {
+      "itemName": "肆层",
+      "roiFront": "167,312,304,90"
+    },
+    {
+      "itemName": "伍层",
+      "roiFront": "168,425,299,82"
+    },
+    {
+      "itemName": "陆层",
+      "roiFront": "166,316,298,89"
+    },
+    {
+      "itemName": "柒层",
+      "roiFront": "171,312,298,93"
+    },
+    {
+      "itemName": "捌层",
+      "roiFront": "169,203,302,89"
+    },
+    {
+      "itemName": "玖层",
+      "roiFront": "167,206,302,81"
+    },
+    {
+      "itemName": "拾层",
+      "roiFront": "166,315,298,84"
+    },
+    {
+      "itemName": "悲鸣",
+      "roiFront": "167,427,305,85"
+    },
+    {
+      "itemName": "神罚",
+      "roiFront": "165,534,305,86"
+    }
+  ]
+}

+ 1 - 0
tasks/OrochiJudgement/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/OrochiMoans/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/RealmRaid/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/Restart/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/Script/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/Sougenbi/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 1 - 0
tasks/Utils/assets.py

@@ -3,6 +3,7 @@ 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 module/dev_tools/assets_extract.py.
 # Don't modify it manually.

+ 51 - 23
tasks/base_task.py

@@ -12,6 +12,7 @@ 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
 from module.ocr.base_ocr import OcrMode, OcrMethod
 from module.logger import logger
 from module.base.timer import Timer
@@ -29,7 +30,6 @@ class BaseTask:
 
     limit_time: datetime  # 限制运行的时间,是软时间,不是硬时间
 
-
     def __init__(self, config: Config, device: Device) -> None:
         self.config = config
         self.device = device
@@ -38,9 +38,6 @@ class BaseTask:
 
         self.start_time = datetime.now()  # 启动的时间
 
-
-
-
     def screenshot(self):
         """
         截图 引入中间函数的目的是 为了解决如协作的这类突发的事件
@@ -48,7 +45,7 @@ class BaseTask:
         """
         return self.device.screenshot()
 
-    def appear(self, target: RuleImage, interval: float =None, threshold: float =None):
+    def appear(self, target: RuleImage, interval: float = None, threshold: float = None):
         """
 
         :param target: 匹配的目标可以是RuleImage, 也可以是RuleOcr
@@ -77,10 +74,10 @@ class BaseTask:
 
     def appear_then_click(self,
                           target: RuleImage,
-                          action: Union[RuleClick, RuleLongClick]=None,
-                          interval: float=None,
-                          threshold: float=None,
-                          duration: float=None):
+                          action: Union[RuleClick, RuleLongClick] = None,
+                          interval: float = None,
+                          threshold: float = None,
+                          duration: float = None):
         """
         出现了就点击,默认点击图片的位置,如果添加了click参数,就点击click的位置
         :param duration: 如果是长按,可以手动指定duration,不指定默认.单位是ms!!!!
@@ -102,9 +99,9 @@ class BaseTask:
             x, y = action.coord()
             if isinstance(action, RuleLongClick):
                 if duration is None:
-                    self.device.long_click(x, y, duration=action.duration/1000, control_name=target.name)
+                    self.device.long_click(x, y, duration=action.duration / 1000, control_name=target.name)
                 else:
-                    self.device.long_click(x, y, duration=duration/1000, control_name=target.name)
+                    self.device.long_click(x, y, duration=duration / 1000, control_name=target.name)
             elif isinstance(action, RuleClick):
                 self.device.click(x, y, control_name=target.name)
 
@@ -129,7 +126,7 @@ class BaseTask:
 
     def wait_until_appear_then_click(self,
                                      target: RuleImage,
-                                     action: Union[RuleClick, RuleLongClick]=None) -> None:
+                                     action: Union[RuleClick, RuleLongClick] = None) -> None:
         """
         等待直到出现目标,然后点击
         :param action:
@@ -140,7 +137,7 @@ class BaseTask:
         if action is None:
             self.device.click(target.coord(), control_name=target.name)
         elif isinstance(action, RuleLongClick):
-            self.device.long_click(target.coord(), duration=action.duration/1000, control_name=target.name)
+            self.device.long_click(target.coord(), duration=action.duration / 1000, control_name=target.name)
         elif isinstance(action, RuleClick):
             self.device.click(target.coord(), control_name=target.name)
 
@@ -186,7 +183,7 @@ class BaseTask:
                 logger.warning(f'wait_until_stable({target}) timeout')
                 break
 
-    def swipe(self, swipe: RuleSwipe, interval: float =None) -> None:
+    def swipe(self, swipe: RuleSwipe, interval: float = None) -> None:
         """
 
         :param interval:
@@ -216,7 +213,7 @@ class BaseTask:
             # logger.info(f'Swipe {swipe.name}')
             self.interval_timer[swipe.name].reset()
 
-    def click(self, click: Union[RuleClick, RuleLongClick]=None, interval: float =None) -> None:
+    def click(self, click: Union[RuleClick, RuleLongClick] = None, interval: float = None) -> None:
         """
         点击或者长按
         :param interval:
@@ -240,7 +237,7 @@ class BaseTask:
 
         x, y = click.coord()
         if isinstance(click, RuleLongClick):
-            self.device.long_click(x=x, y=y, duration=click.duration/1000, control_name=click.name)
+            self.device.long_click(x=x, y=y, duration=click.duration / 1000, control_name=click.name)
         elif isinstance(click, RuleClick):
             self.device.click(x=x, y=y, control_name=click.name)
 
@@ -248,7 +245,7 @@ class BaseTask:
         if interval:
             self.interval_timer[click.name].reset()
 
-    def ocr_appear(self, target: RuleOcr, interval: float=None) -> bool:
+    def ocr_appear(self, target: RuleOcr, interval: float = None) -> bool:
         """
         ocr识别目标
         :param interval:
@@ -274,7 +271,6 @@ class BaseTask:
         result = target.ocr(self.device.image)
         appear = False
 
-
         if not target.keyword or target.keyword == '':
             appear = False
         match target.mode:
@@ -296,8 +292,8 @@ class BaseTask:
 
     def ocr_appear_click(self,
                          target: RuleOcr,
-                         action: Union[RuleClick, RuleLongClick]=None,
-                         interval: float=None,
+                         action: Union[RuleClick, RuleLongClick] = None,
+                         interval: float = None,
                          duration: float = None) -> bool:
         """
         ocr识别目标,如果目标存在,则触发动作
@@ -319,8 +315,41 @@ class BaseTask:
             x, y = target.coord()
             self.device.click(x=x, y=y, control_name=target.name)
 
+    def list_find(self, target: RuleList, name: str | list[str]) -> bool:
+        """
+        会一致在列表寻找目标,找到了就退出。
+        如果是图片列表会一直往下找
+        如果是纯文字的,会自动识别自己的位置,根据位置选择向前还是向后翻
+        :param target:
+        :param name:
+        :return:
+        """
+        if target.is_image:
+            while True:
+                self.screenshot()
+                result = target.image_appear(self.device.image, name=name)
+                if result is not None:
+                    return result
+                x1, y1, x2, y2 = target.swipe_pos()
+                self.device.swipe(p1=(x1, y1), p2=(x2, y2))
+
+        elif target.is_ocr:
+            while True:
+                self.screenshot()
+                result = target.ocr_appear(self.device.image, name=name)
+                if isinstance(result, tuple):
+                    return result
+
+                after = True
+                if isinstance(result, int) and result > 0:
+                    after = True
+                elif isinstance(result, int) and result < 0:
+                    after = False
+
+                x1, y1, x2, y2 = target.swipe_pos(after=after)
+                self.device.swipe(p1=(x1, y1), p2=(x2, y2))
 
-    def set_next_run(self, task: str, finish: bool=False) -> None:
+    def set_next_run(self, task: str, finish: bool = False) -> None:
         """
         设置下次运行时间  当然这个也是可以重写的
         :param task: 任务名称,大驼峰的
@@ -339,9 +368,8 @@ class BaseTask:
             start_time = self.start_time
         delta = timedelta(days=task_object.scheduler.interval_days,
                           hours=task_object.scheduler.interval_hours,
-                          minutes=task_object.scheduler.interval_minutes,)
+                          minutes=task_object.scheduler.interval_minutes, )
         next_run = start_time + delta
 
         task_object.scheduler.next_run = next_run
         self.config.save()
-