فهرست منبع

feat(task) Realm Raid done!

runhey 3 سال پیش
والد
کامیت
645526681f
50فایلهای تغییر یافته به همراه760 افزوده شده و 93 حذف شده
  1. 1 1
      module/config/config_menu.py
  2. 2 0
      module/config/config_model.py
  3. 2 2
      module/dev_tools/assets_extract.py
  4. 5 4
      module/device/method/window.py
  5. 4 3
      module/ocr/sub_ocr.py
  6. 1 1
      script.py
  7. 8 8
      tasks/CoinChallenge/assets.py
  8. 43 0
      tasks/GameUi/assets.py
  9. 44 0
      tasks/GameUi/game_ui.py
  10. 101 0
      tasks/GameUi/res/image.json
  11. 20 0
      tasks/GameUi/res/ocr.json
  12. BIN
      tasks/GameUi/res/res_back_blue.png
  13. BIN
      tasks/GameUi/res/res_home_collect.png
  14. BIN
      tasks/GameUi/res/res_home_concentric_team.png
  15. BIN
      tasks/GameUi/res/res_home_friend.png
  16. BIN
      tasks/GameUi/res/res_home_guild.png
  17. BIN
      tasks/GameUi/res/res_home_help.png
  18. BIN
      tasks/GameUi/res/res_home_mall.png
  19. BIN
      tasks/GameUi/res/res_home_omnyouji.png
  20. BIN
      tasks/GameUi/res/res_home_shikikami.png
  21. BIN
      tasks/GameUi/res/res_home_team.png
  22. BIN
      tasks/GameUi/res/res_home_tsk.png
  23. 4 0
      tasks/GeneralBattle/assets.py
  24. 15 34
      tasks/GeneralBattle/config_general_battle.py
  25. 56 6
      tasks/GeneralBattle/general_battle.py
  26. 0 0
      tasks/GeneralBattle/res/image.json
  27. BIN
      tasks/GeneralBattle/res/res_exit.png
  28. BIN
      tasks/GeneralBattle/res/res_exit_ensure.png
  29. 41 1
      tasks/RealmRaid/assets.py
  30. 30 1
      tasks/RealmRaid/config.py
  31. 6 7
      tasks/RealmRaid/config_scheduler.py
  32. 137 0
      tasks/RealmRaid/res/image.json
  33. 20 0
      tasks/RealmRaid/res/ocr.json
  34. BIN
      tasks/RealmRaid/res/res_back_red.png
  35. BIN
      tasks/RealmRaid/res/res_fire.png
  36. BIN
      tasks/RealmRaid/res/res_fresh.png
  37. BIN
      tasks/RealmRaid/res/res_fresh_ensure.png
  38. BIN
      tasks/RealmRaid/res/res_lock.png
  39. BIN
      tasks/RealmRaid/res/res_medal_0.png
  40. BIN
      tasks/RealmRaid/res/res_medal_1.png
  41. BIN
      tasks/RealmRaid/res/res_medal_2.png
  42. BIN
      tasks/RealmRaid/res/res_medal_3.png
  43. BIN
      tasks/RealmRaid/res/res_medal_4.png
  44. BIN
      tasks/RealmRaid/res/res_medal_5.png
  45. BIN
      tasks/RealmRaid/res/res_realm_raid.png
  46. BIN
      tasks/RealmRaid/res/res_shikigami.png
  47. BIN
      tasks/RealmRaid/res/res_soul_raid.png
  48. BIN
      tasks/RealmRaid/res/res_unlock.png
  49. 175 0
      tasks/RealmRaid/script_task.py
  50. 45 25
      tasks/base_task.py

+ 1 - 1
module/config/config_menu.py

@@ -19,7 +19,7 @@ class ConfigMenu:
         # 刷御魂
         self.menu["Soul Zones"] = ['Orochi', 'OrochiMoans', 'OrochiJudgement', 'Sougenbi', 'FallenSun', 'EternitySea']
         # 日常的任务
-        self.menu["Daily Task"] = ['AreaBoss', 'GoldYoukai', 'ExperienceYoukai', 'Nian']
+        self.menu["Daily Task"] = ['AreaBoss', 'GoldYoukai', 'ExperienceYoukai', 'Nian', 'RealmRaid']
 
         # 开发工具
         self.menu["Tools"] = ['Image Rule', 'Ocr Rule', 'Click Rule', 'Long Click Rule', 'Swipe Rule']

+ 2 - 0
module/config/config_model.py

@@ -23,6 +23,7 @@ from tasks.OrochiJudgement.config import OrochiJudgement
 from tasks.Sougenbi.config import Sougenbi
 from tasks.FallenSun.config import FallenSun
 from tasks.EternitySea.config import EternitySea
+from tasks.RealmRaid.config import RealmRaid
 
 
 
@@ -39,6 +40,7 @@ class ConfigModel(BaseModel):
     experience_youkai: ExperienceYoukai = Field(default_factory=ExperienceYoukai)
     gold_youkai: GoldYoukai = Field(default_factory=GoldYoukai)
     nian: Nian = Field(default_factory=Nian)
+    realm_raid: RealmRaid = Field(default_factory=RealmRaid)
 
     # 这些是刷御魂的
     orochi: Orochi = Field(default_factory=Orochi)

+ 2 - 2
module/dev_tools/assets_extract.py

@@ -166,7 +166,7 @@ class OcrExtractor:
         swipe rule 提取
         :param data:  json解析后的数据
         """
-        self._result = '\n\n\t# Swipe Rule Assets\n'
+        self._result = '\n\n\t# Ocr Rule Assets\n'
         for item in data:
             self._result += self.extract_item(item)
 
@@ -182,7 +182,7 @@ class OcrExtractor:
         :return:
         """
         description: str = f'\t# {item["description"]} \n'
-        name: str = f'\tS_{name_transform(item["itemName"])} = RuleOcr(' \
+        name: str = f'\tO_{name_transform(item["itemName"])} = RuleOcr(' \
                     f'roi=({item["roiFront"]}), ' \
                     f'area=({item["roiBack"]}), ' \
                     f'mode="{item["mode"]}", ' \

+ 5 - 4
module/device/method/window.py

@@ -132,23 +132,24 @@ class Window(Handle):
 
         x = int(x / self.window_scale_rate)
         y = int(y / self.window_scale_rate)
+        mumu_head_height = int(36/self.window_scale_rate)
         # print(f"我点击的x:{x}, y:{y}")
         emulator_type = len(self.control_handle_list)
         if emulator_type == 2:  # mumu模拟器
-            SendMessage(self.control_handle_list[0], WM_LBUTTONDOWN, 0, MAKELONG(x, y))  # 模拟鼠标按下 先是父窗口 上面的框高度是57
-            time.sleep((random.randint(200, 400)) / 1000.0)  # 点击弹起改为随机,时间100ms-200ms
+            SendMessage(self.control_handle_list[0], WM_LBUTTONDOWN, 0, MAKELONG(x, y+mumu_head_height))  # 模拟鼠标按下 先是父窗口 上面的框高度是57
+            time.sleep((random.randint(100, 200)) / 1000.0)  # 点击弹起改为随机,时间100ms-200ms
             SendMessage(self.control_handle_list[1], WM_LBUTTONUP, 0, MAKELONG(x, y))  # 模拟鼠标弹起 后是子窗口
         elif emulator_type > 2:  # 夜神模拟器
             SendMessage(self.control_handle_list[0], WM_LBUTTONDOWN, 0, MAKELONG(x, y))  # 模拟鼠标按下 先是父窗口 上面的框高度是57
             SendMessage(self.control_handle_list[1], WM_LBUTTONDOWN, 0, MAKELONG(x, y))
             SendMessage(self.control_handle_list[2], WM_LBUTTONDOWN, 0, MAKELONG(x, y))
             SendMessage(self.control_handle_list[3], WM_LBUTTONDOWN, 0, MAKELONG(x, y))
-            time.sleep((random.randint(200, 400)) / 1000.0)  # 点击弹起改为随机,时间100ms-200ms
+            time.sleep((random.randint(100, 200)) / 1000.0)  # 点击弹起改为随机,时间100ms-200ms
             SendMessage(self.control_handle_list[3], WM_LBUTTONUP, 0, MAKELONG(x, y))  # 模拟鼠标弹起 后是子窗口
         elif emulator_type == 1:  # 雷电模拟器
             clickPos = MAKELONG(x, y)
             SendMessage(self.control_handle_list[0], WM_LBUTTONDOWN, 0, clickPos)  # 模拟鼠标按下
-            time.sleep((random.randint(200, 400)) / 1000.0)  # 点击弹起改为随机,时间100ms-200ms
+            time.sleep((random.randint(100, 300)) / 1000.0)  # 点击弹起改为随机,时间100ms-200ms
             SendMessage(self.control_handle_list[0], WM_LBUTTONUP, 0, clickPos)  # 模拟鼠标弹起
 
     def long_click_window_message(self, x: int, y: int, duration: float):

+ 4 - 3
module/ocr/sub_ocr.py

@@ -50,12 +50,13 @@ class Full(BaseCor):
                 boxed_results[index].box[2, 1] - boxed_results[index].box[0, 1],     # height
             ) for index in index_list]
             box = merge_area(area_list)
-            self.area = box
-            return box
+            self.area = box[0]+self.roi[0], box[1]+self.roi[1], box[2], box[3]
         else:
             box = boxed_results[index_list[0]].box
             self.area = box[0, 0]+self.roi[0], box[0, 1]+self.roi[1], box[1, 0] - box[0, 0], box[2, 1] - box[0, 1]
-            return self.area
+
+        logger.info(f"OCR [{self.name}: {keyword}] detected in {self.area}")
+        return self.area
 
 class Single(BaseCor):
     """

+ 1 - 1
script.py

@@ -444,4 +444,4 @@ class Script:
 if __name__ == "__main__":
     script = Script("oas1")
     print(script.get_next_task())
-    script.run("AreaBoss")
+    script.run("RealmRaid")

+ 8 - 8
tasks/CoinChallenge/assets.py

@@ -36,21 +36,21 @@ class CoinChallengeAssets:
 	L_NEW3 = RuleLongClick(roi_front=(112,156,100,100), roi_back=(469,200,100,100), duration=1000, name="new3")
 
 
-	# Swipe Rule Assets
+	# Ocr Rule Assets
 	# Ocr-description 
-	S_NEW_FULL = RuleOcr(roi=(255,129,628,100), area=(637,418,100,100), mode="Full", method="Default", keyword="探索", name="new_full")
+	O_NEW_FULL = RuleOcr(roi=(255,129,628,100), area=(637,418,100,100), mode="Full", method="Default", keyword="探索", name="new_full")
 	# Ocr-description 
-	S_NEW_SINGLE_V = RuleOcr(roi=(564,255,105,159), area=(0,0,100,100), mode="Single", method="Default", keyword="式神育成", name="new_single_v")
+	O_NEW_SINGLE_V = RuleOcr(roi=(564,255,105,159), area=(0,0,100,100), mode="Single", method="Default", keyword="式神育成", name="new_single_v")
 	# Ocr-description 
-	S_NEW_SINGLE_H = RuleOcr(roi=(78,19,143,63), area=(314,169,100,100), mode="Single", method="Default", keyword="式神育成", name="new_single_h")
+	O_NEW_SINGLE_H = RuleOcr(roi=(78,19,143,63), area=(314,169,100,100), mode="Single", method="Default", keyword="式神育成", name="new_single_h")
 	# Ocr-description 
-	S_DIGIT = RuleOcr(roi=(434,173,25,43), area=(0,0,100,100), mode="Digit", method="Default", keyword="", name="digit")
+	O_DIGIT = RuleOcr(roi=(434,173,25,43), area=(0,0,100,100), mode="Digit", method="Default", keyword="", name="digit")
 	# Ocr-description 
-	S_DIGIT_COUNTER = RuleOcr(roi=(1134,6,100,56), area=(0,0,100,100), mode="DigitCounter", method="Default", keyword="", name="digit_counter")
+	O_DIGIT_COUNTER = RuleOcr(roi=(1134,6,100,56), area=(0,0,100,100), mode="DigitCounter", method="Default", keyword="", name="digit_counter")
 	# Ocr-description 
-	S_DURATION = RuleOcr(roi=(923,256,100,46), area=(0,0,100,100), mode="Duration", method="Default", keyword="育成_结界卡剩余时间", name="duration")
+	O_DURATION = RuleOcr(roi=(923,256,100,46), area=(0,0,100,100), mode="Duration", method="Default", keyword="育成_结界卡剩余时间", name="duration")
 	# Ocr-description 
-	S_NEW_DUR_00 = RuleOcr(roi=(848,624,76,37), area=(0,0,100,100), mode="Duration", method="Default", keyword="", name="new_dur_00")
+	O_NEW_DUR_00 = RuleOcr(roi=(848,624,76,37), area=(0,0,100,100), mode="Duration", method="Default", keyword="", name="new_dur_00")
 
 
 	# Swipe Rule Assets

+ 43 - 0
tasks/GameUi/assets.py

@@ -0,0 +1,43 @@
+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
+
+# This file was automatically generated by module/dev_tools/assets_extract.py.
+# Don't modify it manually.
+class GameUiAssets: 
+
+
+	# Image Rule Assets
+	# 左上角蓝色的返回 
+	I_BACK_BLUE = RuleImage(roi_front=(32,31,50,53), roi_back=(1,2,139,120), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_back_blue.png")
+	# 式神录 
+	I_HOME_SHIKIKAMI = RuleImage(roi_front=(1092,611,73,41), roi_back=(1092,611,73,41), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_home_shikikami.png")
+	# 阴阳术 
+	I_HOME_OMNYOUJI = RuleImage(roi_front=(989,613,59,58), roi_back=(989,613,59,58), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_home_omnyouji.png")
+	# description 
+	I_HOME_FRIEND = RuleImage(roi_front=(876,619,60,53), roi_back=(876,619,60,53), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_home_friend.png")
+	# 花合战 
+	I_HOME_TSK = RuleImage(roi_front=(764,608,66,56), roi_back=(764,608,66,56), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_home_tsk.png")
+	# 商店 
+	I_HOME_MALL = RuleImage(roi_front=(654,620,51,55), roi_back=(654,620,51,55), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_home_mall.png")
+	# 阴阳寮 
+	I_HOME_GUILD = RuleImage(roi_front=(540,607,53,50), roi_back=(540,607,53,50), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_home_guild.png")
+	# 组队 
+	I_HOME_TEAM = RuleImage(roi_front=(430,616,49,61), roi_back=(430,616,49,61), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_home_team.png")
+	# 同心队 
+	I_HOME_CONCENTRIC_TEAM = RuleImage(roi_front=(310,618,67,60), roi_back=(310,618,67,60), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_home_concentric_team.png")
+	# 珍旅居 
+	I_HOME_HELP = RuleImage(roi_front=(201,617,56,57), roi_back=(201,617,56,57), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_home_help.png")
+	# 图鉴 
+	I_HOME_COLLECT = RuleImage(roi_front=(92,607,48,74), roi_back=(92,607,48,74), threshold=0.8, method="Template matching", file="./tasks/GameUi/res/res_home_collect.png")
+
+
+	# Ocr Rule Assets
+	# 庭院到探索 
+	O_HOME_EXPLORE = RuleOcr(roi=(310,105,858,194), area=(0,0,100,100), mode="Full", method="Default", keyword="探索", name="home_explore")
+	# Ocr-description 
+	O_NEW = RuleOcr(roi=(0,0,100,100), area=(0,0,100,100), mode="Single", method="Default", keyword="", name="new")
+
+

+ 44 - 0
tasks/GameUi/game_ui.py

@@ -0,0 +1,44 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import time
+
+from tasks.GameUi.assets import GameUiAssets
+from tasks.base_task import BaseTask
+from tasks.GeneralBattle.general_battle import GeneralBattle
+from tasks.AreaBoss.assets import AreaBossAssets
+from module.logger import logger
+
+
+class GameUi(BaseTask, GameUiAssets):
+
+    def home_explore(self) -> bool:
+        """
+        使用ocr识别到探索按钮并点击
+        :return:
+        """
+        while 1:
+            self.screenshot()
+            if self.ocr_appear_click(self.O_HOME_EXPLORE, interval=2):
+                continue
+            if self.appear(self.I_BACK_BLUE, threshold=0.6):
+                break
+        logger.info(f'Click {self.O_HOME_EXPLORE.name}')
+        return True
+
+    def explore_home(self) -> bool:
+        """
+
+        :return:
+        """
+        while 1:
+            self.screenshot()
+            if self.appear_then_click(self.I_BACK_BLUE, threshold=0.6, interval=2):
+                continue
+            if self.appear(self.I_HOME_SHIKIKAMI, threshold=0.6):
+                break
+        logger.info(f'Click {self.I_HOME_SHIKIKAMI.name}')
+        return True
+
+
+

+ 101 - 0
tasks/GameUi/res/image.json

@@ -0,0 +1,101 @@
+[
+  {
+    "itemName": "back_blue",
+    "imageName": "res_back_blue.png",
+    "roiFront": "32,31,50,53",
+    "roiBack": "1,2,139,120",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角蓝色的返回"
+  },
+  {
+    "itemName": "home_shikikami",
+    "imageName": "res_home_shikikami.png",
+    "roiFront": "1092,611,73,41",
+    "roiBack": "1092,611,73,41",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "式神录"
+  },
+  {
+    "itemName": "home_omnyouji",
+    "imageName": "res_home_omnyouji.png",
+    "roiFront": "989,613,59,58",
+    "roiBack": "989,613,59,58",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "阴阳术"
+  },
+  {
+    "itemName": "home_friend",
+    "imageName": "res_home_friend.png",
+    "roiFront": "876,619,60,53",
+    "roiBack": "876,619,60,53",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "home_tsk",
+    "imageName": "res_home_tsk.png",
+    "roiFront": "764,608,66,56",
+    "roiBack": "764,608,66,56",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "花合战"
+  },
+  {
+    "itemName": "home_mall",
+    "imageName": "res_home_mall.png",
+    "roiFront": "654,620,51,55",
+    "roiBack": "654,620,51,55",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "商店"
+  },
+  {
+    "itemName": "home_guild",
+    "imageName": "res_home_guild.png",
+    "roiFront": "540,607,53,50",
+    "roiBack": "540,607,53,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "阴阳寮"
+  },
+  {
+    "itemName": "home_team",
+    "imageName": "res_home_team.png",
+    "roiFront": "430,616,49,61",
+    "roiBack": "430,616,49,61",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "组队"
+  },
+  {
+    "itemName": "home_concentric_team",
+    "imageName": "res_home_concentric_team.png",
+    "roiFront": "310,618,67,60",
+    "roiBack": "310,618,67,60",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "同心队"
+  },
+  {
+    "itemName": "home_help",
+    "imageName": "res_home_help.png",
+    "roiFront": "201,617,56,57",
+    "roiBack": "201,617,56,57",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "珍旅居"
+  },
+  {
+    "itemName": "home_collect",
+    "imageName": "res_home_collect.png",
+    "roiFront": "92,607,48,74",
+    "roiBack": "92,607,48,74",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "图鉴"
+  }
+]

+ 20 - 0
tasks/GameUi/res/ocr.json

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "home_explore",
+    "roiFront": "310,105,858,194",
+    "roiBack": "0,0,100,100",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "探索",
+    "description": "庭院到探索"
+  },
+  {
+    "itemName": "new",
+    "roiFront": "0,0,100,100",
+    "roiBack": "0,0,100,100",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  }
+]

BIN
tasks/GameUi/res/res_back_blue.png


BIN
tasks/GameUi/res/res_home_collect.png


BIN
tasks/GameUi/res/res_home_concentric_team.png


BIN
tasks/GameUi/res/res_home_friend.png


BIN
tasks/GameUi/res/res_home_guild.png


BIN
tasks/GameUi/res/res_home_help.png


BIN
tasks/GameUi/res/res_home_mall.png


BIN
tasks/GameUi/res/res_home_omnyouji.png


BIN
tasks/GameUi/res/res_home_shikikami.png


BIN
tasks/GameUi/res/res_home_team.png


BIN
tasks/GameUi/res/res_home_tsk.png


+ 4 - 0
tasks/GeneralBattle/assets.py

@@ -81,6 +81,10 @@ class GeneralBattleAssets:
 	I_LOCAL = RuleImage(roi_front=(25,563,30,34), roi_back=(25,563,30,34), threshold=0.8, method="Template matching", file="./tasks/GeneralBattle/res/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/GeneralBattle/res/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/GeneralBattle/res/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/GeneralBattle/res/res_exit_ensure.png")
 
 
 	# Swipe Rule Assets

+ 15 - 34
tasks/GeneralBattle/config_general_battle.py

@@ -16,54 +16,35 @@ class GreenMarkType(str, Enum):
 class GeneralBattleConfig(BaseModel):
 
     # 是否锁定阵容, 有些的战斗是外边的锁定阵容甚至有些的战斗没有锁定阵容的
-    lock_team_enable: bool = Field(default=False,
-                                   description='default is false')
+    lock_team_enable: bool = Field(default=False, description='[锁定阵容]:默认为False \n如果锁定阵容将无法启用预设队伍、加成功能')
 
     # 是否启动 预设队伍
-    preset_enable: bool = Field(default=False,
-                                description='default is false')
+    preset_enable: bool = Field(default=False, description='[启用预设]:默认为False')
     # 选哪一个预设组
-    preset_group: int = Field(default=1,
-                              description='default is 1, max is 7, min is 1',
-                              ge=1, le=7)
+    preset_group: int = Field(default=1, description='[设置预设组]:默认为1, 可选[1-7]', ge=1, le=7)
     # 选哪一个队伍
-    preset_team: int = Field(default=1,
-                             description='default is 1, min is 1, max is 4',
-                             ge=1, le=4)
-
+    preset_team: int = Field(default=1, description='[设置预设队伍]:默认为1, 可选[1-5]', ge=1, le=5)
     # 是否启动开启buff
-    buff_enable: bool = Field(default=False,
-                               description='default is false')
+    buff_enable: bool = Field(default=False, description='[启用加成]:默认为False')
     # 是否点击觉醒Buff
-    buff_awake_click: bool = Field(default=False,
-                                   description='default is false')
+    buff_awake_click: bool = Field(default=False, description='[觉醒加成]:默认为False')
     # 是否点击御魂buff
-    buff_soul_click: bool = Field(default=False,
-                                  description='default is false')
+    buff_soul_click: bool = Field(default=False, description='[御魂加成]:默认为False')
     # 是否点击金币50buff
-    buff_gold_50_click: bool = Field(default=False,
-                                    description='default is false')
+    buff_gold_50_click: bool = Field(default=False, description='[金币50加成]:默认为False')
     # 是否点击金币100buff
-    buff_gold_100_click: bool = Field(default=False,
-                                        description='default is false')
+    buff_gold_100_click: bool = Field(default=False, description='[金币100加成]:默认为False')
     # 是否点击经验50buff
-    buff_exp_50_click: bool = Field(default=False,
-                                    description='default is false')
+    buff_exp_50_click: bool = Field(default=False, description='[经验50加成]:默认为False')
     # 是否点击经验100buff
-    buff_exp_100_click: bool = Field(default=False,
-                                    description='default is false')
+    buff_exp_100_click: bool = Field(default=False, description='[经验100加成]:默认为False')
 
     # 是否开启绿标
-    green_enable: bool = Field(default=False,
-                                 description='default is false')
+    green_enable: bool = Field(default=False, description='[启用绿标]:默认为False')
     # 选哪一个绿标
-    green_mark: GreenMarkType = Field(default=GreenMarkType.GREEN_LEFT1,
-                                        description='default is GREEN_LEFT1')
+    green_mark: GreenMarkType = Field(default=GreenMarkType.GREEN_LEFT1, description='[设置绿标]:默认为左一 \n可选[左一, 左二, 左三, 左四, 左五, 主阴阳师]')
 
     # 是否启动战斗时随机点击或者随机滑动
-    random_click_swipt_enable: bool = Field(default=False,
-                                        description='default is false')
-    # 是否启动战斗时随机滑动
-    # random_swipe_enable: bool = Field(default=False,
-    #                                     description='default is false')
+    random_click_swipt_enable: bool = Field(default=False, description='[战斗时随机点击或滑动]:默认为False \n防封优化,请注意这个与绿标功能冲突,可能会乱点绿标')
+
 

+ 56 - 6
tasks/GeneralBattle/general_battle.py

@@ -30,12 +30,12 @@ class GeneralBattle(BaseTask, GeneralBattleAssets):
 
         # 如果没有锁定队伍。那么可以根据配置设定队伍
         if not config.lock_team_enable:
-            logger.info("lock team is not enable")
+            logger.info("Lock team is not enable")
             # 如果启动更换队伍
             if config.preset_enable:
-                logger.info("preset is enable")
+                logger.info("Preset is enable")
                 # 点击预设按钮
-                logger.info("click preset button")
+                logger.info("Click preset button")
                 while 1:
                     self.screenshot()
                     if self.appear_then_click(self.I_PRESET, threshold=0.8):
@@ -90,20 +90,20 @@ class GeneralBattle(BaseTask, GeneralBattleAssets):
 
             # 点击准备按钮
             self.wait_until_appear(self.I_PREPARE_HIGHLIGHT)
-            logger.info("click prepare button")
             while 1:
                 self.screenshot()
                 if self.appear_then_click(self.I_PREPARE_HIGHLIGHT, interval=1.5):
                     continue
-                if not self.appear(self.I_PRESET):
+                if not self.appear(self.I_BUFF):
                     break
+            logger.info("Click prepare ensure button")
 
             # 照顾一下某些模拟器慢的
             time.sleep(0.1)
 
         # 绿标
         if config.green_enable:
-            logger.info("green is enable")
+            logger.info("Green is enable")
             x, y = None, None
             match config.green_mark:
                 case GreenMarkType.GREEN_LEFT1: x, y = self.C_GREEN_LEFT_1.coord()
@@ -185,3 +185,53 @@ class GeneralBattle(BaseTask, GeneralBattleAssets):
         else:
             return False
 
+
+    def run_general_battle_back(self, config: dict=None) -> bool:
+        """
+        进入挑战然后直接返回
+        :param config:
+        :return:
+        """
+        # 如果没有锁定队伍那么在点击准备后才退出的
+        if not config.lock_team_enable:
+            # 点击准备按钮
+            self.wait_until_appear(self.I_PREPARE_HIGHLIGHT)
+            while 1:
+                self.screenshot()
+                if self.appear_then_click(self.I_PREPARE_HIGHLIGHT, interval=1.5):
+                    continue
+                if not self.appear(self.I_PRESET):
+                    break
+            logger.info(f"Click {self.I_PREPARE_HIGHLIGHT.name}")
+
+        # 点击返回
+        while 1:
+            self.screenshot()
+            if self.appear_then_click(self.I_EXIT, interval=1.5):
+                continue
+            if self.appear(self.I_EXIT_ENSURE):
+                break
+        logger.info(f"Click {self.I_EXIT.name}")
+
+        # 点击返回确认
+        while 1:
+            self.screenshot()
+            if self.appear_then_click(self.I_EXIT_ENSURE, interval=1.5):
+                continue
+            if self.appear(self.I_FALSE):
+                break
+        logger.info(f"Click {self.I_EXIT_ENSURE.name}")
+
+        # 点击失败确认
+        self.wait_until_appear(self.I_FALSE)
+        while 1:
+            self.screenshot()
+            if self.appear_then_click(self.I_FALSE, interval=1.5):
+                continue
+            if not self.appear(self.I_FALSE):
+                break
+        logger.info(f"Click {self.I_FALSE.name}")
+
+        return True
+
+

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
tasks/GeneralBattle/res/image.json


BIN
tasks/GeneralBattle/res/res_exit.png


BIN
tasks/GeneralBattle/res/res_exit_ensure.png


+ 41 - 1
tasks/RealmRaid/assets.py

@@ -7,5 +7,45 @@ from module.atom.ocr import RuleOcr
 # This file was automatically generated by module/dev_tools/assets_extract.py.
 # Don't modify it manually.
 class RealmRaidAssets: 
-	pass
+
+
+	# Image Rule Assets
+	# 点击结界突破的图片 
+	I_REALM_RAID = RuleImage(roi_front=(246,628,63,64), roi_back=(246,628,63,64), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_realm_raid.png")
+	# 五个勋章 
+	I_MEDAL_5 = RuleImage(roi_front=(238,205,212,53), roi_back=(216,187,919,364), threshold=0.9, method="Template matching", file="./tasks/RealmRaid/res/res_medal_5.png")
+	# description 
+	I_MEDAL_4 = RuleImage(roi_front=(241,483,193,46), roi_back=(228,178,899,362), threshold=0.9, method="Template matching", file="./tasks/RealmRaid/res/res_medal_4.png")
+	# description 
+	I_MEDAL_3 = RuleImage(roi_front=(240,210,193,41), roi_back=(229,189,894,345), threshold=0.9, method="Template matching", file="./tasks/RealmRaid/res/res_medal_3.png")
+	# description 
+	I_MEDAL_2 = RuleImage(roi_front=(572,478,198,48), roi_back=(217,193,923,354), threshold=0.9, method="Template matching", file="./tasks/RealmRaid/res/res_medal_2.png")
+	# description 
+	I_MEDAL_1 = RuleImage(roi_front=(570,206,199,52), roi_back=(237,198,892,336), threshold=0.9, method="Template matching", file="./tasks/RealmRaid/res/res_medal_1.png")
+	# 没有勋章的 
+	I_MEDAL_0 = RuleImage(roi_front=(510,336,202,51), roi_back=(231,200,898,336), threshold=0.9, method="Template matching", file="./tasks/RealmRaid/res/res_medal_0.png")
+	# 右上角红色的关闭 
+	I_BACK_RED = RuleImage(roi_front=(1178,101,57,64), roi_back=(1178,101,57,64), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_back_red.png")
+	# 没有锁的状态图标 
+	I_UNLOCK = RuleImage(roi_front=(818,579,38,42), roi_back=(818,579,38,42), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_unlock.png")
+	# 以锁的状态图片 
+	I_LOCK = RuleImage(roi_front=(818,579,36,41), roi_back=(818,579,36,41), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_lock.png")
+	# 刷新按钮 
+	I_FRESH = RuleImage(roi_front=(957,564,182,66), roi_back=(957,564,182,66), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_fresh.png")
+	# 点击的式神录 
+	I_SHIKIGAMI = RuleImage(roi_front=(1206,608,54,51), roi_back=(1206,608,54,51), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_shikigami.png")
+	# 进攻 
+	I_FIRE = RuleImage(roi_front=(982,494,136,63), roi_back=(140,129,1024,584), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_fire.png")
+	# 打完个后出现的领取奖励 
+	I_SOUL_RAID = RuleImage(roi_front=(577,502,100,100), roi_back=(577,502,100,100), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_soul_raid.png")
+	# 刷新确认 
+	I_FRESH_ENSURE = RuleImage(roi_front=(672,403,173,59), roi_back=(672,403,173,59), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_fresh_ensure.png")
+
+
+	# Ocr Rule Assets
+	# 刷新的时间 
+	O_FRESH_TIME = RuleOcr(roi=(1042,582,85,36), area=(0,0,100,100), mode="Duration", method="Default", keyword="", name="fresh_time")
+	# 右上角 突破卷的数量 
+	O_NUMBER = RuleOcr(roi=(1139,13,91,39), area=(0,0,100,100), mode="DigitCounter", method="Default", keyword="", name="number")
+
 

+ 30 - 1
tasks/RealmRaid/config.py

@@ -2,5 +2,34 @@
 # @author runhey
 # github https://github.com/runhey
 from pydantic import BaseModel, Field
+from enum import Enum
+
+from tasks.RealmRaid.config_scheduler import Scheduler
+from tasks.GeneralBattle.config_general_battle import GeneralBattleConfig
+
+
+class RaidMode(str, Enum):
+    NORMAL = 'retreat_four_attack_nine'
+    ATTACK_ALL = 'attack_all'
+
+class AttackNumber(str, Enum):
+    NINE = 'nine'
+    ALL = 'all'
+
+class RaidConfig(BaseModel):
+    raid_mode: RaidMode = Field(title='Raid Mode', default=RaidMode.NORMAL,
+                                description='[挑战模式]:默认为退四打九\n 退四打九指每次执行前都会退出四次,然后在进攻九次')
+    attack_number: AttackNumber = Field(title='Attack Number', default=AttackNumber.ALL,
+                                        description='[挑战次数]:默认为all,一直打到没有\n nine为打九次')
+
+class RealmRaid(BaseModel):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    raid_config: RaidConfig = Field(default_factory=RaidConfig)
+    general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
+
+
+
+
+
+
 
-from tasks.RealmRaid.config_scheduler import Scheduler

+ 6 - 7
tasks/RealmRaid/config_scheduler.py

@@ -2,14 +2,13 @@
 # @author runhey
 # github https://github.com/runhey
 from enum import Enum
-from datetime import datetime, time
+from datetime import datetime, timedelta
 from pydantic import BaseModel, ValidationError, validator, Field
 
 class Scheduler(BaseModel):
-    enable: bool = Field(default=False,
-                         description='none')
-    next_run: datetime = Field(default="2023-01-01 00:00:00",
-                               description='none')
-    priority: int = Field(default=3,
-                          description='default 3')
+    enable: bool = Field(default=False, description='[是否启用]:默认为False')
+    next_run: datetime = Field(default="2023-01-01 00:00:00", description='[下次执行时间]:默认为2023-01-01 00:00:00\n 清空后回车设置当前的时间')
+    interval_days: int = Field(default=1, description='[间隔天数]:默认为1\n 可选0-7')
+    interval_hours: int = Field(default=0, description='[间隔小时]:默认为0\n 可选0-23')
+    interval_minutes: int = Field(default=0, description='[间隔分钟]:默认为0\n 可选0-59')
 

+ 137 - 0
tasks/RealmRaid/res/image.json

@@ -0,0 +1,137 @@
+[
+  {
+    "itemName": "realm_raid",
+    "imageName": "res_realm_raid.png",
+    "roiFront": "246,628,63,64",
+    "roiBack": "246,628,63,64",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "点击结界突破的图片"
+  },
+  {
+    "itemName": "medal_5",
+    "imageName": "res_medal_5.png",
+    "roiFront": "238,205,212,53",
+    "roiBack": "216,187,919,364",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "五个勋章"
+  },
+  {
+    "itemName": "medal_4",
+    "imageName": "res_medal_4.png",
+    "roiFront": "241,483,193,46",
+    "roiBack": "228,178,899,362",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "medal_3",
+    "imageName": "res_medal_3.png",
+    "roiFront": "240,210,193,41",
+    "roiBack": "229,189,894,345",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "medal_2",
+    "imageName": "res_medal_2.png",
+    "roiFront": "572,478,198,48",
+    "roiBack": "217,193,923,354",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "medal_1",
+    "imageName": "res_medal_1.png",
+    "roiFront": "570,206,199,52",
+    "roiBack": "237,198,892,336",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "description"
+  },
+  {
+    "itemName": "medal_0",
+    "imageName": "res_medal_0.png",
+    "roiFront": "510,336,202,51",
+    "roiBack": "231,200,898,336",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "没有勋章的"
+  },
+  {
+    "itemName": "back_red",
+    "imageName": "res_back_red.png",
+    "roiFront": "1178,101,57,64",
+    "roiBack": "1178,101,57,64",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "右上角红色的关闭"
+  },
+  {
+    "itemName": "unlock",
+    "imageName": "res_unlock.png",
+    "roiFront": "818,579,38,42",
+    "roiBack": "818,579,38,42",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "没有锁的状态图标"
+  },
+  {
+    "itemName": "lock",
+    "imageName": "res_lock.png",
+    "roiFront": "818,579,36,41",
+    "roiBack": "818,579,36,41",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "以锁的状态图片"
+  },
+  {
+    "itemName": "fresh",
+    "imageName": "res_fresh.png",
+    "roiFront": "957,564,182,66",
+    "roiBack": "957,564,182,66",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "刷新按钮"
+  },
+  {
+    "itemName": "shikigami",
+    "imageName": "res_shikigami.png",
+    "roiFront": "1206,608,54,51",
+    "roiBack": "1206,608,54,51",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "点击的式神录"
+  },
+  {
+    "itemName": "fire",
+    "imageName": "res_fire.png",
+    "roiFront": "982,494,136,63",
+    "roiBack": "140,129,1024,584",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "进攻"
+  },
+  {
+    "itemName": "soul_raid",
+    "imageName": "res_soul_raid.png",
+    "roiFront": "577,502,100,100",
+    "roiBack": "577,502,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "打完个后出现的领取奖励"
+  },
+  {
+    "itemName": "fresh_ensure",
+    "imageName": "res_fresh_ensure.png",
+    "roiFront": "672,403,173,59",
+    "roiBack": "672,403,173,59",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "刷新确认"
+  }
+]

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

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "fresh_time",
+    "roiFront": "1042,582,85,36",
+    "roiBack": "0,0,100,100",
+    "mode": "Duration",
+    "method": "Default",
+    "keyword": "",
+    "description": "刷新的时间"
+  },
+  {
+    "itemName": "number",
+    "roiFront": "1139,13,91,39",
+    "roiBack": "0,0,100,100",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "右上角 突破卷的数量"
+  }
+]

BIN
tasks/RealmRaid/res/res_back_red.png


BIN
tasks/RealmRaid/res/res_fire.png


BIN
tasks/RealmRaid/res/res_fresh.png


BIN
tasks/RealmRaid/res/res_fresh_ensure.png


BIN
tasks/RealmRaid/res/res_lock.png


BIN
tasks/RealmRaid/res/res_medal_0.png


BIN
tasks/RealmRaid/res/res_medal_1.png


BIN
tasks/RealmRaid/res/res_medal_2.png


BIN
tasks/RealmRaid/res/res_medal_3.png


BIN
tasks/RealmRaid/res/res_medal_4.png


BIN
tasks/RealmRaid/res/res_medal_5.png


BIN
tasks/RealmRaid/res/res_realm_raid.png


BIN
tasks/RealmRaid/res/res_shikigami.png


BIN
tasks/RealmRaid/res/res_soul_raid.png


BIN
tasks/RealmRaid/res/res_unlock.png


+ 175 - 0
tasks/RealmRaid/script_task.py

@@ -0,0 +1,175 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import time
+
+from tasks.base_task import BaseTask
+from tasks.GeneralBattle.general_battle import GeneralBattle
+from tasks.GameUi.game_ui import GameUi
+from tasks.RealmRaid.assets import RealmRaidAssets
+from tasks.RealmRaid.config import RealmRaid, RaidMode, AttackNumber
+from module.logger import logger
+from module.exception import TaskEnd
+
+class ScriptTask(GeneralBattle, GameUi, RealmRaidAssets):
+
+    def run(self):
+        """
+        执行
+        :return:
+        """
+        config = self.config.realm_raid
+        self.home_explore()
+
+        # 点击突破
+        while 1:
+            self.screenshot()
+            if self.appear_then_click(self.I_REALM_RAID, interval=1):
+                continue
+            if self.appear(self.I_BACK_RED, threshold=0.6):
+                break
+        logger.info(f'Click {self.I_REALM_RAID.name}')
+
+        # 判断是不是锁定阵容
+        if config.general_battle_config.lock_team_enable:
+            while 1:
+                self.screenshot()
+                if self.appear_then_click(self.I_UNLOCK, interval=1):
+                    continue
+                if self.appear(self.I_LOCK, threshold=0.9):
+                    break
+            logger.info(f'Click {self.I_UNLOCK.name}')
+        else:
+            while 1:
+                self.screenshot()
+                if self.appear_then_click(self.I_LOCK, interval=1):
+                    continue
+                if self.appear(self.I_UNLOCK, threshold=0.9):
+                    break
+            logger.info(f'Click {self.I_LOCK.name}')
+
+        # 判断是只打九次还是打完去
+        if config.raid_config.attack_number == AttackNumber.NINE:
+            self.execute_round(config)
+        else:
+            while 1:
+                if self.execute_round(config):
+                    continue
+                else:
+                    break
+
+        # 点击 右上角的关闭
+        while 1:
+            self.screenshot()
+            if self.appear_then_click(self.I_BACK_RED, interval=1):
+                continue
+            if self.appear(self.I_REALM_RAID, threshold=0.6):
+                break
+        logger.info(f'Click {self.I_BACK_RED.name}')
+
+        # 点击左上角的关闭
+        self.explore_home()
+
+        self.set_next_run(task='RealmRaid')
+        raise TaskEnd
+
+
+    def is_ticket(self) -> bool:
+        """
+        如果没有票了,那么就返回False
+        :return:
+        """
+        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
+
+    def medal_fire(self) -> bool:
+        """
+        点击勋章
+        :return:
+        """
+        # 点击勋章的挑战 和挑战
+        is_click = False
+        while 1:
+            self.screenshot()
+
+            if self.appear(self.I_FIRE, threshold=0.8):
+                break
+
+            if self.appear_then_click(self.I_SOUL_RAID, interval=1.5):
+                while 1:
+                    self.screenshot()
+                    if self.appear_then_click(self.I_SOUL_RAID, interval=1.5):
+                        continue
+                    if not self.appear(self.I_SOUL_RAID, threshold=0.6):
+                        break
+                continue
+
+            if is_click:
+                continue
+            if self.appear_then_click(self.I_MEDAL_5, interval=1.5):
+                is_click = True
+                continue
+            if self.appear_then_click(self.I_MEDAL_4, interval=1.5):
+                is_click = True
+                continue
+            if self.appear_then_click(self.I_MEDAL_3, interval=1.5):
+                is_click = True
+                continue
+            if self.appear_then_click(self.I_MEDAL_2, interval=1.5):
+                is_click = True
+                continue
+            if self.appear_then_click(self.I_MEDAL_1, interval=1.5):
+                is_click = True
+                continue
+            if self.appear_then_click(self.I_MEDAL_0, interval=1.5):
+                is_click = True
+                continue
+        logger.info(f'Click Medal')
+
+        # 点击挑战
+        self.wait_until_appear(self.I_FIRE)
+        while 1:
+            self.screenshot()
+            if self.appear_then_click(self.I_FIRE, interval=2):
+                continue
+            if not self.appear(self.I_FIRE, threshold=0.8):
+                break
+        logger.info(f'Click {self.I_FIRE.name}')
+
+    def execute_round(self, config: RealmRaid) -> bool:
+        """
+        执行一轮 除非票不够,一直到到九次
+        :return:
+        """
+        # 如果没有票了,就退出
+        if not self.is_ticket():
+            return False
+
+        # 判断是退四打九还是全部打
+        if config.raid_config.raid_mode == RaidMode.NORMAL:
+            logger.info(f'Execute round, retreat four attack nine')
+            self.medal_fire()
+            self.run_general_battle_back(config.general_battle_config)
+
+            self.medal_fire()
+            self.run_general_battle_back(config.general_battle_config)
+
+            self.medal_fire()
+            self.run_general_battle_back(config.general_battle_config)
+
+            self.medal_fire()
+            self.run_general_battle_back(config.general_battle_config)
+
+        # 打九次
+        for i in range(9):
+            if not self.is_ticket():
+                return False
+            self.medal_fire()
+            self.run_general_battle(config.general_battle_config)
+            self.wait_until_appear(self.I_BACK_RED)
+
+        return True

+ 45 - 25
tasks/base_task.py

@@ -3,9 +3,10 @@
 # github https://github.com/runhey
 import numpy as np
 
-from datetime import datetime
+from datetime import datetime, timedelta
 from typing import Union
 
+from module.config.utils import convert_to_underscore
 from module.atom.image import RuleImage
 from module.atom.click import RuleClick
 from module.atom.long_click import RuleLongClick
@@ -35,6 +36,8 @@ class BaseTask:
 
         self.interval_timer = {}  # 这个是用来记录每个匹配的运行间隔的,用于控制运行频率
 
+        self.start_time = datetime.now()  # 启动的时间
+
 
 
 
@@ -245,12 +248,13 @@ class BaseTask:
         if interval:
             self.interval_timer[click.name].reset()
 
-    def ocr(self, target: RuleOcr, interval: float=None):
+    def ocr_appear(self, target: RuleOcr, interval: float=None) -> bool:
         """
-        ocr识别目标  根据不同的target的类型返回不同的数据
+        ocr识别目标
         :param interval:
         :param target:
-        :return:
+        :return: 如果target有keyword或者是keyword存在,返回是True,否则返回False
+                 但是没有指定keyword,返回的是匹配到的值,具体取决于target的mode
         """
         if not isinstance(target, RuleOcr):
             return None
@@ -267,36 +271,28 @@ class BaseTask:
             if not self.interval_timer[target.name].reached():
                 return None
 
-        result = target.ocr(self.device.image, target.keyword)
+        result = target.ocr(self.device.image)
+        appear = False
 
-        # 执行后,如果有限制时间,则重置限制时间
-        if interval:
-            self.interval_timer[target.name].reset()
-
-        return result
 
-    def ocr_appear(self, target: RuleOcr, interval: float=None) -> bool:
-        """
-        ocr识别目标
-        :param interval:
-        :param target:
-        :return: 如果target有keyword或者是keyword存在,返回是True,否则返回False
-                 但是没有指定keyword,返回的是匹配到的值,具体取决于target的mode
-        """
-        result = self.ocr(target, interval)
         if not target.keyword or target.keyword == '':
-            return False
+            appear = False
         match target.mode:
             case OcrMode.FULL:  # 全匹配
-                return result != (0, 0, 0, 0)
+                appear = result != (0, 0, 0, 0)
             case OcrMode.SINGLE:
-                return result == target.keyword
+                appear = result == target.keyword
             case OcrMode.DIGIT:
-                return result == int(target.keyword)
+                appear = result == int(target.keyword)
             case OcrMode.DIGITCOUNTER:
-                return result == target.ocr_str_digit_counter(target.keyword)
+                appear = result == target.ocr_str_digit_counter(target.keyword)
             case OcrMode.DURATION:
-                return result == target.parse_time(target.keyword)
+                appear = result == target.parse_time(target.keyword)
+
+        if interval and appear:
+            self.interval_timer[target.name].reset()
+
+        return appear
 
     def ocr_appear_click(self,
                          target: RuleOcr,
@@ -324,4 +320,28 @@ class BaseTask:
             self.device.click(x=x, y=y, control_name=target.name)
 
 
+    def set_next_run(self, task: str, finish: bool=False) -> None:
+        """
+        设置下次运行时间  当然这个也是可以重写的
+        :param task: 任务名称,大驼峰的
+        :param finish: 是完成任务后的时间为基准还是开始任务的时间为基准
+        :return:
+        """
+        task = convert_to_underscore(task)
+        task_object = getattr(self.config.model, task, None)
+        if not task_object:
+            logger.warning(f'No task named {task}')
+            return
+
+        if finish:
+            start_time = datetime.now()
+        else:
+            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,)
+        next_run = start_time + delta
+
+        task_object.scheduler.next_run = next_run
+        self.config.save()
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است