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

Merge remote-tracking branch 'origin/dev' into autodokan

# Conflicts:
#	module/config/config.py
ChengRanORZ 1 год назад
Родитель
Сommit
14cc4c6770
72 измененных файлов с 1015 добавлено и 290 удалено
  1. 35 0
      config/findjade/find_jade.json
  2. 3 3
      dev_tools/assets_test.py
  3. 0 1
      dev_tools/generate_requirements.py
  4. 5 0
      module/atom/image.py
  5. 20 11
      module/config/config.py
  6. 1 0
      module/config/config_menu.py
  7. 36 37
      module/config/config_model.py
  8. 4 0
      module/notify/notify.py
  9. 2 2
      requirements-in.txt
  10. 5 3
      requirements.txt
  11. BIN
      tasks/AbyssShadows/__pycache__/assets.cpython-310.pyc
  12. BIN
      tasks/AbyssShadows/__pycache__/script_task.cpython-310.pyc
  13. 1 1
      tasks/Component/GeneralBuff/general_buff.py
  14. 7 3
      tasks/Component/SwitchAccount/switch_account_config.py
  15. 53 75
      tasks/Component/config_base.py
  16. 14 36
      tasks/Component/config_scheduler.py
  17. 2 0
      tasks/DailyTrifles/assets.py
  18. BIN
      tasks/DailyTrifles/love/friendship_up.png
  19. 9 0
      tasks/DailyTrifles/love/image.json
  20. 4 0
      tasks/DailyTrifles/script_task.py
  21. 1 1
      tasks/DemonEncounter/config.py
  22. 43 2
      tasks/Duel/config.py
  23. 2 0
      tasks/EternitySea/assets.py
  24. 9 0
      tasks/EternitySea/res/image.json
  25. BIN
      tasks/EternitySea/res/res_back_bottom.png
  26. 14 1
      tasks/EternitySea/script_task.py
  27. 1 1
      tasks/Exploration/assets.py
  28. 1 1
      tasks/Exploration/res/image.json
  29. 12 0
      tasks/FindJade/README.md
  30. 30 0
      tasks/FindJade/WantedQuestsEx.py
  31. 12 0
      tasks/FindJade/assets.py
  32. 159 0
      tasks/FindJade/config.py
  33. 113 0
      tasks/FindJade/script_task.py
  34. 2 0
      tasks/GameUi/assets.py
  35. 1 1
      tasks/GameUi/page.py
  36. 9 0
      tasks/GameUi/page/page_img_3.json
  37. BIN
      tasks/GameUi/page/store_dlc_close.png
  38. 1 1
      tasks/KekkaiActivation/config.py
  39. 4 1
      tasks/KekkaiActivation/script_task.py
  40. 1 1
      tasks/KekkaiUtilize/config.py
  41. 2 0
      tasks/Orochi/script_task.py
  42. 3 3
      tasks/RealmRaid/assets.py
  43. 6 6
      tasks/RealmRaid/res/partition.json
  44. 6 6
      tasks/Restart/assets.py
  45. BIN
      tasks/Restart/harvest/harvest_harvest_mail_copy.png
  46. 0 0
      tasks/Restart/harvest/harvest_harvest_zidu.png
  47. 10 1
      tasks/Restart/harvest/image.json
  48. 9 5
      tasks/Restart/login.py
  49. 2 2
      tasks/Restart/login/image.json
  50. 21 6
      tasks/Restart/script_task.py
  51. 14 0
      tasks/Secret/script_task.py
  52. 1 1
      tasks/SoulsTidy/script_task.py
  53. 1 1
      tasks/TrueOrochi/config.py
  54. 16 2
      tasks/WantedQuests/assets.py
  55. 6 0
      tasks/WantedQuests/click.json
  56. 27 20
      tasks/WantedQuests/config.py
  57. 8 3
      tasks/WantedQuests/explore.py
  58. 20 2
      tasks/WantedQuests/invite/image.json
  59. BIN
      tasks/WantedQuests/invite/wq_invite_cancel.png
  60. BIN
      tasks/WantedQuests/invite/wq_invite_diff_svr_highlight.png
  61. BIN
      tasks/WantedQuests/invite/wq_invite_friend_list_appear.png
  62. 176 35
      tasks/WantedQuests/script_task.py
  63. 38 2
      tasks/WantedQuests/wq/image.json
  64. BIN
      tasks/WantedQuests/wq/wq_trace_disable.png
  65. BIN
      tasks/WantedQuests/wq/wq_trace_one_check_opened.png
  66. BIN
      tasks/WantedQuests/wq/wq_trace_one_disable.png
  67. BIN
      tasks/WantedQuests/wq/wq_trace_one_enable.png
  68. BIN
      tasks/WantedQuests/wq/wq_trace_one_realworld.png
  69. 1 1
      tasks/WeeklyTrifles/assets.py
  70. 7 6
      tasks/WeeklyTrifles/script_task.py
  71. 2 2
      tasks/WeeklyTrifles/secret/image.json
  72. 23 4
      tasks/base_task.py

+ 35 - 0
config/findjade/find_jade.json

@@ -0,0 +1,35 @@
+{
+  "find_jade_accounts_info": [
+    {
+      "character": "小号1",
+      "svr": "万事屋",
+      "account": "150****4444",
+      "accountAlias": "150★***4444#150*★**4444#150**★*4444#150***★4444",
+      "appleOrAndroid": true,
+      "last_complete_time": "2024-11-12 18:02:28.342305"
+    },
+    {
+      "character": "小号2",
+      "svr": "祈世之舞",
+      "account": "150****4444",
+      "accountAlias": "150★***4444#150*★**4444#150**★*4444#150***★4444",
+      "appleOrAndroid": true,
+      "last_complete_time": "2024-11-12 18:03:08.517909"
+    }],
+  "invite_info_list": [
+    {
+      "name": "大号1",
+      "default_invite_type": "JadeAndFood",
+      "invite_history": [
+        {
+          "cooperation_type": 2,
+          "time": "2024-11-05 18:08:53.597534"
+        }]
+    },
+    {
+      "name": "大号2",
+      "default_invite_type": "JadeAndFood",
+      "invite_history": []
+    }],
+  "updateHandle": "<bound method ScriptTask.save_jade_json of <script_task.ScriptTask object at 0x000001C5E7229D50>>"
+}

+ 3 - 3
dev_tools/assets_test.py

@@ -34,10 +34,10 @@ def detect_ocr(file: str, target: RuleOcr):
 
 
 # 图片文件路径 可以是相对路径
-IMAGE_FILE = r"D:\Project\OnmyojiAutoScript\log\error\1731668941132\2024-11-15_19-09-00-887294.png"
+IMAGE_FILE = r"D:\Project\OnmyojiAutoScript\log\error\1734235242044\2024-12-15_12-00-42-005384.png"
 if __name__ == '__main__':
-    from tasks.WantedQuests.assets import WantedQuestsAssets
-    targe = WantedQuestsAssets.I_WQ_BOX
+    from tasks.Exploration.assets import ExplorationAssets
+    targe = ExplorationAssets.I_BATTLE_REWARD
     print(detect_image(IMAGE_FILE, targe))
 
     # ocr demo

+ 0 - 1
dev_tools/generate_requirements.py

@@ -3,7 +3,6 @@
 # github https://github.com/runhey
 import argparse
 import subprocess
-import time
 
 from module.logger import logger
 

+ 5 - 0
module/atom/image.py

@@ -149,6 +149,11 @@ class RuleImage:
 
         source = self.corp(image)
         mat = self.image
+
+        if mat is None or mat.shape[0] == 0 or mat.shape[1] == 0:
+            logger.error(f"Template image is invalid: {mat.shape}") #检测模板尺寸,不合法则不进行匹配,避免两次截图画面完全相同造成模板不合法
+            return True  # 如果模板图像无效,直接返回 True
+
         res = cv2.matchTemplate(source, mat, cv2.TM_CCOEFF_NORMED)
         min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)  # 最小匹配度,最大匹配度,最小匹配度的坐标,最大匹配度的坐标
         # logger.attr(self.name, max_val)

+ 20 - 11
module/config/config.py

@@ -26,6 +26,9 @@ from module.exception import RequestHumanTakeover, ScriptError
 from module.logger import logger
 
 
+
+
+
 class Function:
     def __init__(self, key: str, data: dict):
         """
@@ -122,6 +125,13 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
     def lock_config(self) -> Lock:
         return Lock()
 
+    @cached_property
+    def notifier(self):
+        notifier = Notifier(self.model.script.error.notify_config, enable=self.model.script.error.notify_enable)
+        notifier.config_name = self.config_name.upper()
+        logger.info(f'Notifier: {notifier.config_name}')
+        return notifier
+
     def gui_args(self, task: str) -> str:
         """
         获取给gui显示的参数
@@ -248,7 +258,8 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
         data = {"running": running, "pending": pending, "waiting": waiting}
         return data
 
-    def task_call(self, task: str = None, force_call=True):
+
+    def task_call(self, task: str=None, force_call=True):
         """
         回调任务,这会是在任务结束后调用
         :param task: 调用的任务的大写名称
@@ -273,7 +284,7 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
             return False
 
     def task_delay(self, task: str, start_time: datetime = None,
-                   success: bool = None, server: bool = True, target: datetime = None) -> None:
+                   success: bool=None, server: bool=True, target: datetime=None) -> None:
         """
         设置下次运行时间  当然这个也是可以重写的
         :param target: 可以自定义的下次运行时间
@@ -337,7 +348,7 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
         run = min(run).replace(microsecond=0)
         next_run = run
 
-        if server and hasattr(scheduler, 'server_update') and (target is None):
+        if server and hasattr(scheduler, 'server_update'):
             # 加入随机延迟时间
             float_seconds = (scheduler.float_time.hour * 3600 +
                              scheduler.float_time.minute * 60 +
@@ -373,17 +384,15 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
         # 设置
         logger.attr(f'{task}.scheduler.next_run', next_run)
 
-    @cached_property
-    def notifier(self):
-        notifier = Notifier(self.model.script.error.notify_config, enable=self.model.script.error.notify_enable)
-        notifier.config_name = self.config_name.upper()
-        logger.info(f'Notifier: {notifier.config_name}')
-        return notifier
+
 
 
 if __name__ == '__main__':
     config = Config(config_name='oas1')
-    config.update_scheduler()
-    print(config.waiting_task)
+    config.notifier.push(title="0000", content="dddddddd")
 
     # print(config.get_next())
+
+
+
+

+ 1 - 0
module/config/config_menu.py

@@ -32,6 +32,7 @@ class ConfigMenu:
             "Exploration",
             "Hyakkiyakou",
             "HeroTest",
+            "FindJade"
         ]
         # 阴阳寮
         self.menu["Guild"] = ['KekkaiUtilize', 'KekkaiActivation', 'RealmRaid', 'RyouToppa', 'Dokan', 'CollectiveMissions',

+ 36 - 37
module/config/config_model.py

@@ -62,6 +62,7 @@ from tasks.GoryouRealm.config import GoryouRealm
 from tasks.Hyakkiyakou.config import Hyakkiyakou
 from tasks.HeroTest.config import HeroTest
 
+from tasks.FindJade.config import FindJade
 # ----------------------------------------------------------------------------------------------------------------------
 
 # 每周任务---------------------------------------------------------------------------------------------------------------
@@ -119,6 +120,7 @@ class ConfigModel(ConfigBase):
     goryou_realm: GoryouRealm = Field(default_factory=GoryouRealm)
     hyakkiyakou: Hyakkiyakou = Field(default_factory=Hyakkiyakou)
     hero_test: HeroTest = Field(default_factory=HeroTest)
+    find_jade: FindJade = Field(default_factory=FindJade)
 
     # 这些是每周任务
     true_orochi: TrueOrochi = Field(default_factory=TrueOrochi)
@@ -134,10 +136,6 @@ class ConfigModel(ConfigBase):
     dokan: Dokan = Field(default_factory=Dokan)
     abyss_shadows: AbyssShadows = Field(default_factory=AbyssShadows)
 
-    # @validator('script')
-    # def script_validator(cls, v):
-    #     if v is None:
-    #         return Script()
 
     def __init__(self, config_name: str=None) -> None:
         """
@@ -225,7 +223,7 @@ class ConfigModel(ConfigBase):
 
         :return:
         """
-        self.write_json(self.config_name, self.dict())
+        self.write_json(self.config_name, self.model_dump())
 
     @staticmethod
     def type(key: str) -> str:
@@ -243,16 +241,6 @@ class ConfigModel(ConfigBase):
             classname = re.findall(r"'([^']*)'", field_type)[0]
             return classname
 
-    # @root_validator
-    # def on_on_property_change(cls, values):
-    #     """
-    #     当属性改变时保存
-    #     :param values:
-    #     :return:
-    #     """
-    #     logger.info(f'property change auto save')
-    #     cls.save()
-
     @staticmethod
     def deep_get(obj, keys: str, default=None):
         """
@@ -298,21 +286,20 @@ class ConfigModel(ConfigBase):
             logger.warning(f'{task} is no inexistence')
             return {}
 
-        def properties_groups(sch) -> dict:
-            properties = {}
-            for key, value in sch["properties"].items():
-                properties[key] = re.search(r"/([^/]+)$", value['$ref']).group(1)
-            return properties
-
         def extract_groups(sch):
             # 从schema 中提取未解析的group的数据
-            properties = properties_groups(sch)
+            # properties = properties_groups(sch)
+            results = {}
+            properties = {}
+            for key, value in sch["properties"].items():
+                if 'items' in value:
+                    properties[key] = re.search(r"/([^/]+)$", value['items']['$ref']).group(1)
+                else:
+                    properties[key] = re.search(r"/([^/]+)$", value['$ref']).group(1)
 
-            result = {}
             for key, value in properties.items():
-                result[key] = sch["definitions"][value]
-
-            return result
+                results[key] = sch["$defs"][value]
+            return results
 
         def merge_value(groups, jsons, definitions) -> list[dict]:
             # 将 groups的参数,同导出的json一起合并, 用于前端显示
@@ -326,20 +313,26 @@ class ConfigModel(ConfigBase):
                 item["default"] = value["default"]
                 item["value"] = jsons[key] if key in jsons else value["default"]
                 item["type"] = value["type"] if "type" in value else "enum"
-                if 'allOf' in value:
-                    # list
-                    enum_key = re.search(r"/([^/]+)$", value['allOf'][0]['$ref']).group(1)
+                if '$ref' in value:  # list
+                    enum_key = re.search(r"/([^/]+)$", value['$ref']).group(1)
                     item["enumEnum"] = definitions[enum_key]["enum"]
-                # TODO: 最大值最小值
+                # if 'allOf' in value:
+                #     enum_key = re.search(r"/([^/]+)$", value['allOf'][0]['$ref']).group(1)
+                #     item["enumEnum"] = definitions[enum_key]["enum"]
                 result.append(item)
             return result
 
-        schema = task.schema()
+        schema = task.model_json_schema()
         groups = extract_groups(schema)
+        groups_value = groups.copy()
 
         result: dict[str, list] = {}
-        for key, value in task.dict().items():
-            result[key] = merge_value(groups[key], value, schema["definitions"])
+        for key, value in task.model_dump().items():
+            if key not in groups:
+                for group_name in groups.keys():
+                    if group_name in key:
+                        groups_value[key] = groups[group_name]
+            result[key] = merge_value(groups_value[key], value, schema["$defs"])
 
         return result
 
@@ -373,9 +366,15 @@ class ConfigModel(ConfigBase):
 
         task_object = getattr(self, task, None)
         group_object = getattr(task_object, group, None)
+        if group_object is None:  # deal list
+            matchs = re.findall(r'\d+', group)
+            index = int(matchs[-1]) - 1 if matchs else None
+            task_object_list = list(dict(task_object))
+            for k, v in dict(task_object).items():
+                if k not in group:
+                    continue
+                group_object = v[index] if group_object is None else None
         argument_object = getattr(group_object, argument, None)
-        # print(group_object)
-        # print(argument_object)
 
         if argument_object is None:
             logger.error(f'Set arg {task}.{group}.{argument}.{value} failed')
@@ -426,6 +425,7 @@ class ConfigModel(ConfigBase):
         data = self.read_json(self.config_name)
         super().__init__(**data)
 
+
 if __name__ == "__main__":
     try:
         c = ConfigModel("oas1")
@@ -433,5 +433,4 @@ if __name__ == "__main__":
         print(e)
         c = ConfigModel()
 
-    # c.save()
-    print(c.script_task('Orochi'))
+    c.script_set_arg('Duel', 'test_list_2', 'switch_all_soul', 'false')

+ 4 - 0
module/notify/notify.py

@@ -9,6 +9,7 @@ from onepush.core import Provider
 from onepush.exceptions import OnePushException
 from onepush.providers.custom import Custom
 from requests import Response
+from smtplib import SMTPResponseException
 
 from module.logger import logger
 onepush.core.log = logger
@@ -91,6 +92,9 @@ class Notifier:
                             logger.warning(
                                 f"Return message:{return_data['wording']}")
                             return False
+        except SMTPResponseException:
+            logger.warning("Appear SMTPResponseException")
+            pass
         except OnePushException:
             logger.exception("Push notify failed")
             return False

+ 2 - 2
requirements-in.txt

@@ -11,11 +11,11 @@ anytree==2.8.0
 pywin32==306
 zerorpc==0.6.3
 wrapt==1.15.0
-pydantic==1.10.7
+pydantic==2.10.0
 inflection==0.5.1
 tqdm==4.65.0
 ppocr-onnx==0.0.3.9
-onepush==1.2.0
+onepush==1.3.0
 paho-mqtt==1.6.1
 fastapi==0.104.1
 uvicorn==0.23.2

+ 5 - 3
requirements.txt

@@ -7,6 +7,7 @@
 
 
 adbutils==0.11.0          # via -r requirements-in.txt, uiautomator2
+annotated-types==0.7.0    # via pydantic
 anyio==3.7.1              # via fastapi, starlette
 anytree==2.8.0            # via -r requirements-in.txt
 apkutils2==1.0.0          # via adbutils
@@ -41,7 +42,7 @@ mpmath==1.3.0             # via sympy
 msgpack==1.0.7            # via zerorpc
 numpy==1.24.3             # via -r requirements-in.txt, onnxruntime, opencv-python, ppocr-onnx, shapely
 oashya==0.0.7             # via -r requirements-in.txt
-onepush==1.2.0            # via -r requirements-in.txt
+onepush==1.3.0            # via -r requirements-in.txt
 onnxruntime==1.16.3       # via ppocr-onnx
 opencv-python==4.7.0.72   # via -r requirements-in.txt, ppocr-onnx
 packaging==20.9           # via deprecation, onnxruntime, uiautomator2
@@ -53,7 +54,8 @@ protobuf==4.25.1          # via onnxruntime
 py==1.11.0                # via retry
 pyclipper==1.3.0.post5    # via ppocr-onnx
 pycparser==2.21           # via cffi
-pydantic==1.10.7          # via -r requirements-in.txt, fastapi
+pydantic==2.10.0          # via -r requirements-in.txt, fastapi
+pydantic-core==2.27.0     # via pydantic
 pyelftools==0.30          # via apkutils2
 pygments==2.17.2          # via rich
 pyparsing==3.1.1          # via packaging
@@ -70,7 +72,7 @@ sniffio==1.3.0            # via anyio
 starlette==0.27.0         # via fastapi
 sympy==1.12               # via onnxruntime
 tqdm==4.65.0              # via -r requirements-in.txt
-typing-extensions==4.9.0  # via fastapi, pydantic, uvicorn
+typing-extensions==4.12.2  # via fastapi, pydantic, pydantic-core, uvicorn
 uiautomator2==2.16.17     # via -r requirements-in.txt
 uiautomator2cache==0.3.0.1  # via -r requirements-in.txt
 urllib3==2.1.0            # via requests

BIN
tasks/AbyssShadows/__pycache__/assets.cpython-310.pyc


BIN
tasks/AbyssShadows/__pycache__/script_task.cpython-310.pyc


+ 1 - 1
tasks/Component/GeneralBuff/general_buff.py

@@ -61,7 +61,7 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
         self.reject_invite()
         self.screenshot()
         area = buff.ocr(self.device.image)
-        if area == tuple([0, 0, 0, 0]):
+        if area == tuple([432.0, 143.0, 325.0, 21.0]):
             logger.info('No gold 50 buff')
             return None
 

+ 7 - 3
tasks/Component/SwitchAccount/switch_account_config.py

@@ -1,6 +1,7 @@
-from datetime import datetime
 from pydantic import Field, BaseModel
 
+from tasks.Component.config_base import DateTime
+
 
 class AccountInfo(BaseModel):
     """
@@ -15,10 +16,10 @@ class AccountInfo(BaseModel):
     svr: str = Field(default="", description="svr_help")
     account: str = Field(default="", description="account_help")
     # 为防止ocr出错 暂定格式 字符串以#分割
-    accountAlias: str = Field(default="", description="")
+    accountAlias: str = Field(default="", description="account_alias_help")
     appleOrAndroid: bool = Field(default=True, description="apple_or_android_help")
     # 上一次执行成功的时间 ,防止出错时重复登录浪费时间
-    last_complete_time: datetime = Field(default=datetime(1970, 1, 1, 1, 1, 1), description="last_complete_time_help")
+    last_complete_time: DateTime = Field(default=DateTime.fromisoformat("2023-01-01 00:00:00"), description="last_complete_time_help")
 
     def is_account_alias(self, ocr_account):
         tmp_account = AccountInfo.preprocessAccount(self.account)
@@ -43,3 +44,6 @@ class AccountInfo(BaseModel):
         @rtype:
         """
         return account.split('@')[0]
+
+    def is_valid(self):
+        return self.character!="" and self.character is not None

+ 53 - 75
tasks/Component/config_base.py

@@ -1,13 +1,15 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
-from typing import Any
-from collections.abc import Callable, Generator
+import re
 from datetime import timedelta, time, datetime
+from typing import Any
 
-from pydantic import BaseModel, datetime_parse
-from pydantic.fields import ModelField
-
+from pydantic import BaseModel
+from pydantic import (BeforeValidator,
+                      PlainSerializer,
+                      WithJsonSchema)
+from typing_extensions import Annotated
 
 
 def format_timedelta(tdelta: timedelta):
@@ -16,76 +18,52 @@ def format_timedelta(tdelta: timedelta):
     minutes, seconds = divmod(rem, 60)
     return f"{days:02d} {hours:02d}:{minutes:02d}:{seconds:02d}"
 
-
-class MultiLine(str):
-    # @classmethod
-    # def __get_validators__(cls) -> Generator[Callable, None, None]:
-    #     yield cls.validate
-    #
-    # @classmethod
-    # def validate(cls, value: str, field: ModelField):
-    #     return cls(value)
-
-    @classmethod
-    def __modify_schema__(
-        cls, field_schema: dict[str, Any], field: ModelField | None
-    ):
-        if field:
-            field_schema['type'] = 'multi_line'
-
-class TimeDelta(timedelta):
-    def __str__(self):
-        return format_timedelta(self)
-
-    def __repr__(self):
-        return format_timedelta(self)
-
-    @classmethod
-    def __modify_schema__(
-            cls, field_schema: dict[str, Any], field: ModelField | None
-    ):
-        if field:
-            field_schema['type'] = 'time_delta'
-
-class DateTime(datetime):
-    @classmethod
-    def __modify_schema__(
-            cls, field_schema: dict[str, Any], field: ModelField | None
-    ):
-        if field:
-            field_schema['type'] = 'date_time'
-
-
-class Time(time):
-    """
-    尝试将字符串转换为time对象, 但是不生效
-    """
-    @classmethod
-    def __get_validators__(cls):
-        yield cls.validate
-
-    @classmethod
-    def validate(cls, value):
-        # print(f' Time validate: {value} type: {type(value)}')
-        if isinstance(value, str):
-            hour, minute, second = map(int, value.split(":"))
-            return cls(hour, minute, second)
-        elif isinstance(value, time):
-            return value
-        else:
-            raise ValueError("Invalid time format")
-
-    @classmethod
-    def __modify_schema__(
-            cls, field_schema: dict[str, Any], field: ModelField | None
-    ):
-        if field:
-            field_schema['type'] = 'time'
+def datadelta_validator(v: Any) -> timedelta:
+    if isinstance(v, str):
+        try:
+            pattern = r'(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})'
+            match = re.match(pattern, v)
+            if match:
+                days = int(match.group(1))
+                hours = int(match.group(2))
+                minutes = int(match.group(3))
+                seconds = int(match.group(4))
+                return TimeDelta(days=days, hours=hours, minutes=minutes, seconds=seconds)
+            return TimeDelta(days=1, hours=0, minutes=0, seconds=0)
+        except ValueError:
+            raise ValueError('Invalid interval value. Expected format: seconds')
+    return v
+
+def datetime_validator(v: Any) -> datetime:
+    if isinstance(v, str):
+        return datetime.fromisoformat(v)
+    return v
+
+def time_validator(v: Any) -> time:
+    if isinstance(v, str):
+        return time.fromisoformat(v)
+    return v
+
+
+MultiLine = Annotated[str,
+                      WithJsonSchema({'type': 'multi_line'}),]
+
+
+TimeDelta = Annotated[timedelta,
+                      BeforeValidator(datadelta_validator),
+                      PlainSerializer(format_timedelta, return_type=str),
+                      WithJsonSchema({'type': 'time_delta'}),]
+
+DateTime = Annotated[datetime,
+                     BeforeValidator(datetime_validator),
+                     PlainSerializer(lambda v: v.strftime('%Y-%m-%d %H:%M:%S'), return_type=str),
+                     WithJsonSchema({'type': 'date_time'}),]
+
+Time = Annotated[time,
+                 BeforeValidator(time_validator),
+                 PlainSerializer(lambda v: v.strftime('%H:%M:%S'), return_type=str),
+                 WithJsonSchema({'type': 'time'}),]
 
 # ---------------------------------------------------------------------------------------------------------------------
 class ConfigBase(BaseModel):
-    # 这个是导出json时候的配置,但是新的是导出dict,所以的无效
-    class Config:
-        json_encoders = {
-            TimeDelta: format_timedelta
-        }
+    pass

+ 14 - 36
tasks/Component/config_scheduler.py

@@ -1,16 +1,13 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
-import re
-from enum import Enum
-from datetime import datetime, timedelta, time
-from pydantic import BaseModel, ValidationError, validator, Field
+from pydantic import Field
 
 from tasks.Component.config_base import ConfigBase, TimeDelta, DateTime, Time
 
 class Scheduler(ConfigBase):
     enable: bool = Field(default=False, description='enable_help')
-    next_run: DateTime = Field(default="2023-01-01 00:00:00", description='next_run_help')
+    next_run: DateTime = Field(default=DateTime.fromisoformat("2023-01-01 00:00:00"), description='next_run_help')
     priority: int = Field(default=5, description='priority_help')
 
     success_interval: TimeDelta = Field(default=TimeDelta(days=1), description='success_interval_help')
@@ -19,38 +16,19 @@ class Scheduler(ConfigBase):
     delay_date: int = Field(default=1, description='delay_date_help', ge=1, le=31)
     float_time: Time = Field(default=Time(hour=0, minute=0, second=0), description='float_time_help')
 
-    @validator('next_run', pre=True, always=True)
-    def parse_next_run(cls, value):
-        if isinstance(value, str):
-            try:
-                return datetime.fromisoformat(value)
-            except ValueError:
-                raise ValueError('Invalid next_run value. Expected format: YYYY-MM-DD HH:MM:SS')
-        return value
-
-    @validator('success_interval', 'failure_interval', pre=True)
-    def parse_interval(cls, value):
-        if isinstance(value, str):
-            try:
-                pattern = r'(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})'
-                match = re.match(pattern, value)
-                if match:
-                    days = int(match.group(1))
-                    hours = int(match.group(2))
-                    minutes = int(match.group(3))
-                    seconds = int(match.group(4))
-                    return TimeDelta(days=days, hours=hours, minutes=minutes, seconds=seconds)
-                return TimeDelta(days=1, hours=0, minutes=0, seconds=0)
-            except ValueError:
-                raise ValueError('Invalid interval value. Expected format: seconds')
-        return value
-
 
 if __name__ == "__main__":
-    s = Scheduler(success_interval='00 00:00:10')
-    if isinstance(s.success_interval, TimeDelta):
-        print(s.success_interval.seconds)
-    print(s.json())
-    print(s.dict())
+    dict_s = {
+        "enable": False,
+        "next_run": "2026-07-19T14:15:37",
+        "priority": 5,
+        "success_interval": "10 00:00:01",
+        "failure_interval": "10 00:00:01",
+        "server_update": "09:03:00",
+        "float_time": "02:00:05"
+    }
+    s = Scheduler(**dict_s)
+    print(s.model_dump())
+
 
 

+ 2 - 0
tasks/DailyTrifles/assets.py

@@ -25,6 +25,8 @@ class DailyTriflesAssets:
 	I_CLICK_BLESS = RuleImage(roi_front=(617,442,92,39), roi_back=(617,442,92,39), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/love/Screenshots_click_bless.png")
 	# 吉闻页 
 	I_LUCK_TITLE = RuleImage(roi_front=(600,52,131,67), roi_back=(600,52,131,67), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/love/Screenshots_luck_title.png")
+	# 好友羁绊提升弹窗 
+	I_FRIENDSHIP_UP = RuleImage(roi_front=(1147,80,27,28), roi_back=(1147,80,27,28), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/love/friendship_up.png")
 
 
 	# Image Rule Assets

BIN
tasks/DailyTrifles/love/friendship_up.png


+ 9 - 0
tasks/DailyTrifles/love/image.json

@@ -61,5 +61,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "吉闻页"
+  },
+  {
+    "itemName": "friendship_up",
+    "imageName": "friendship_up.png",
+    "roiFront": "1147,80,27,28",
+    "roiBack": "1147,80,27,28",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "好友羁绊提升弹窗"
   }
 ]

+ 4 - 0
tasks/DailyTrifles/script_task.py

@@ -50,6 +50,8 @@ class ScriptTask(GameUi, Summon, DailyTriflesAssets):
             self.screenshot()
             if self.appear(self.I_LUCK_TITLE):
                 break
+            if self.appear_then_click(self.I_FRIENDSHIP_UP, interval=1):
+                continue
             if self.appear_then_click(self.I_LUCK_MSG, interval=1):
                 continue
         logger.info('Start luck msg')
@@ -78,6 +80,8 @@ class ScriptTask(GameUi, Summon, DailyTriflesAssets):
             self.screenshot()
             if self.appear(self.I_L_LOVE):
                 break
+            if self.appear_then_click(self.I_FRIENDSHIP_UP, interval=1):
+                continue
             if self.appear_then_click(self.I_L_FRIENDS, interval=1):
                 continue
         logger.info('Start friend love')

+ 1 - 1
tasks/DemonEncounter/config.py

@@ -37,7 +37,7 @@ class DemonConfig(BaseModel):
 
 
 class UtilizeScheduler(Scheduler):
-    priority = Field(default=2, description='priority_help')
+    priority: int = Field(default=2, description='priority_help')
 
 class DemonEncounter(ConfigBase):
     scheduler: UtilizeScheduler = Field(default_factory=UtilizeScheduler)

+ 43 - 2
tasks/Duel/config.py

@@ -1,8 +1,14 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
-from pydantic import BaseModel, Field
-from datetime import time
+from typing import Any, Dict
+from pydantic import (Field,
+                      model_validator,
+                      ValidationError,
+                      model_serializer,
+                      WithJsonSchema,
+                      SerializerFunctionWrapHandler,
+                      GetJsonSchemaHandler)
 
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_base import ConfigBase, Time
@@ -26,4 +32,39 @@ class DuelConfig(ConfigBase):
 class Duel(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     duel_config: DuelConfig = Field(default_factory=DuelConfig)
+    # test_list: list[DuelConfig]
+    #
+    # @model_validator(mode='before')
+    # @classmethod
+    # def check_list(cls, data: dict) -> Any:
+    #     if 'test_list' not in data:
+    #         data['test_list'] = []
+    #     for key, value in data.items():
+    #         if isinstance(value, list):
+    #             continue
+    #         if 'test_list' not in key:
+    #             continue
+    #         try:
+    #             DuelConfig(**value)
+    #             data['test_list'].append(value)
+    #         except ValidationError as e:
+    #             pass
+    #     # 补全list
+    #     while len(data['test_list']) < data['scheduler']['priority']:
+    #         data['test_list'].append(DuelConfig())
+    #     return data
+    #
+    # @model_serializer()
+    # def serializer_model(self, value: Any) -> Dict[str, Any]:
+    #     properties = self.__dict__
+    #     data = {}
+    #     for key,value in properties.items():
+    #         if isinstance(value, list):
+    #             for index, v in enumerate(value):
+    #                 data[f'{key}_{index+1}'] = v.model_dump()
+    #         else:
+    #             data[key] = value.model_dump()
+    #     return data
+
+
 

+ 2 - 0
tasks/EternitySea/assets.py

@@ -23,6 +23,8 @@ class EternitySeaAssets:
 	I_NEWETERNITYSEA_LOCK = RuleImage(roi_front=(556,560,31,37), roi_back=(556,560,31,37), threshold=0.8, method="Template matching", file="./tasks/EternitySea/res/res_neweternitysea_lock.png")
 	# 小小宠物,发现宝藏 
 	I_PET_PRESENT = RuleImage(roi_front=(873,184,62,147), roi_back=(873,184,62,147), threshold=0.8, method="Template matching", file="./tasks/EternitySea/res/res_pet_present.png")
+	# description 
+	I_BACK_BOTTOM = RuleImage(roi_front=(1126,49,46,45), roi_back=(1126,49,46,45), threshold=0.8, method="Template matching", file="./tasks/EternitySea/res/res_back_bottom.png")
 
 
 	# List Rule Assets

+ 9 - 0
tasks/EternitySea/res/image.json

@@ -52,5 +52,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "小小宠物,发现宝藏"
+  },
+  {
+    "itemName": "back_bottom",
+    "imageName": "res_back_bottom.png",
+    "roiFront": "1126,49,46,45",
+    "roiBack": "1126,49,46,45",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
   }
 ]

BIN
tasks/EternitySea/res/res_back_bottom.png


+ 14 - 1
tasks/EternitySea/script_task.py

@@ -17,6 +17,7 @@ from tasks.Orochi.config import UserStatus
 from tasks.EternitySea.config import EternitySea
 from module.exception import RequestHumanTakeover
 from tasks.GameUi.page import page_main, page_soul_zones, page_shikigami_records
+from time import sleep
 
 class ScriptTask(
     GameUi, GeneralBattle, GeneralRoom, GeneralInvite, SwitchSoul, EternitySeaAssets
@@ -219,6 +220,15 @@ class ScriptTask(
                     )
                     break
 
+    def is_room_dead(self) -> bool:
+        # 如果在探索界面或者是出现在组队界面,那就是可能房间死了
+        sleep(0.5)
+        if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+            sleep(0.5)
+            if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+                return True
+        return False
+
     def eternitysea_enter(self) -> bool:
         logger.info('Enter EternitySea')
         while True:
@@ -246,7 +256,10 @@ class ScriptTask(
             self.screenshot()
             if self.appear(self.I_FORM_TEAM, interval=1):
                 return True
-            if self.appear_then_click(self.I_ETERNITY_SEA):
+            if self.appear_then_click(self.I_ETERNITY_SEA, interval=1):
+                continue
+            #有可能点击到录像
+            if self.appear_then_click(self.I_BACK_BOTTOM, interval=1):
                 continue
 
     def _navigate_to_soul_zones(self) -> None:

+ 1 - 1
tasks/Exploration/assets.py

@@ -98,7 +98,7 @@ class ExplorationAssets:
 	# boss 
 	I_BOSS_BATTLE_BUTTON = RuleImage(roi_front=(683,256,38,34), roi_back=(0,0,1276,719), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_boss_battle_button.png")
 	# 战后奖励 
-	I_BATTLE_REWARD = RuleImage(roi_front=(647,395,31,21), roi_back=(1,1,1278,718), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_battle_reward.png")
+	I_BATTLE_REWARD = RuleImage(roi_front=(647,395,31,21), roi_back=(1,1,1278,718), threshold=0.9, method="Template matching", file="./tasks/Exploration/res/res_battle_reward.png")
 	# 妖 
 	I_EXPLORATION_TITLE = RuleImage(roi_front=(1133,124,47,43), roi_back=(1133,124,47,43), threshold=0.7, method="Template matching", file="./tasks/Exploration/res/res_exploration_title.png")
 	# description 

+ 1 - 1
tasks/Exploration/res/image.json

@@ -122,7 +122,7 @@
     "roiFront": "647,395,31,21",
     "roiBack": "1,1,1278,718",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.9,
     "description": "战后奖励"
   },
   {

+ 12 - 0
tasks/FindJade/README.md

@@ -0,0 +1,12 @@
+### **注意事项:**
+
+1. 可以配置多个被邀请对象,但每次只会按从前到后的顺序邀请一个.
+2. 小号配置相关信息见[这里](../../tasks/Component/SwitchAccount/README.md)
+3. 需要额外开启一个模拟器,用以切换登录小号
+4. 要求被邀请对象处于登录状态,与小号是好友关系
+5. 关于配置文件中的 updateHandle,这..我也不知道为什么方法名会出现在这(配置文件的序列化研究了下,没看出什么端倪),不过删掉会出问题,所以还是留着吧.
+
+### **运行中可能出现的问题:**
+1. 小号存在打不过的情况,导致邀请完成后,无法完成任务,需手动搞一下 
+2. 由于本人电脑配置一般(16GB内存,5个模拟器满载),所以部分延时写的挺长,可以根据情况酌情调整
+

+ 30 - 0
tasks/FindJade/WantedQuestsEx.py

@@ -0,0 +1,30 @@
+from tasks.WantedQuests.config import CooperationType, WantedQuestsConfig
+
+
+def need_invite_vip(self):
+    return True
+
+
+def get_invite_vip_name(self, ctype: CooperationType):
+    if not self.fade_conf:
+        return ""
+    return self.fade_conf.get_invite_name(ctype)
+
+
+def next_run(self):
+    pass
+
+
+def invite_success_callback(self, ctype: CooperationType, name: str):
+    if not self.fade_conf:
+        return
+    self.fade_conf.update_invite_history(ctype, name)
+    self.config.save()
+
+
+def get_config(self):
+    config=WantedQuestsConfig()
+    config.invite_friend_name="default"
+    config.cooperation_only=True
+    config.cooperation_type=self.fade_conf.get_cooperation_type_mask()
+    return config

+ 12 - 0
tasks/FindJade/assets.py

@@ -0,0 +1,12 @@
+from module.atom.image import RuleImage
+from module.atom.click import RuleClick
+from module.atom.long_click import RuleLongClick
+from module.atom.swipe import RuleSwipe
+from module.atom.ocr import RuleOcr
+from module.atom.list import RuleList
+
+# This file was automatically generated by ./dev_tools/assets_extract.py.
+# Don't modify it manually.
+class FindJadeAssets: 
+	pass
+

+ 159 - 0
tasks/FindJade/config.py

@@ -0,0 +1,159 @@
+from datetime import datetime, timedelta
+from typing import Any, Dict
+
+from pydantic import Field, BaseModel, model_validator, model_serializer, ValidationError
+
+from deploy.logger import logger
+from tasks.Component.SwitchAccount.switch_account_config import AccountInfo
+from tasks.Component.config_base import ConfigBase, DateTime
+from tasks.Component.config_scheduler import Scheduler
+from tasks.WantedQuests.config import CooperationSelectMaskDescription, CooperationSelectMask, CooperationType
+
+
+class InviteHistoryItem(BaseModel):
+    cooperation_type: CooperationType
+    time: DateTime
+
+
+class InviteInfo(BaseModel):
+    # 被邀请人员昵称
+    name: str = Field(default="", description='name_help')
+    default_invite_type: CooperationSelectMaskDescription = Field(default=CooperationSelectMaskDescription.JadeAndFood,
+                                                                  description='default_invite_type_help')
+
+    # 协作任务类型   上次邀请时间
+    invite_history_1: DateTime = Field(default=DateTime.fromisoformat("2023-01-01 00:00:00"),
+                                       description='invite_history_1_help')
+    invite_history_2: DateTime = Field(default=DateTime.fromisoformat("2023-01-01 00:00:00"),
+                                       description='invite_history_2_help')
+    invite_history_4: DateTime = Field(default=DateTime.fromisoformat("2023-01-01 00:00:00"),
+                                       description='invite_history_4_help')
+    invite_history_8: DateTime = Field(default=DateTime.fromisoformat("2023-01-01 00:00:00"),
+                                       description='invite_history_8_help')
+
+    def need_invite(self, ctype: CooperationType):
+        if not ctype & CooperationSelectMask[self.default_invite_type.value]:
+            return False
+        last_time = self.__getattribute__("invite_history_" + str(ctype))
+
+        now = datetime.now()
+        if now - last_time > timedelta(hours=13):
+            return True
+        if (last_time.hour >= 18 or last_time.hour < 5) and (18 > now.hour >= 5):
+            return True
+        if (5 <= last_time.hour < 18) and now.hour >= 18:
+            return True
+        return False
+
+    def update_invite_history(self, ctype: CooperationType, name=None):
+        if name != self.name:
+            return
+        self.__setattr__("invite_history_" + str(ctype), datetime.now())
+
+    def is_valid(self):
+        return self.name != "" and self.name is not None
+
+
+class FindJadeConfig(ConfigBase, extra='allow'):
+    # 被邀请人数
+    invite_info_count: int = Field(default=1, ge=1, description='invite_info_count_help')
+    # 小号数
+    sup_account_count: int = Field(default=1, ge=1, description='sup_account_count_help')
+
+
+class FindJade(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    find_jade_config: FindJadeConfig = Field(default_factory=FindJadeConfig)
+    # 邀请人员信息
+    invite_info_list: list[InviteInfo] = None
+    # 小号信息
+    sup_account_list: list[AccountInfo] = None
+
+    def get_invite_name(self, ctype: CooperationType):
+        for info in self.invite_info_list:
+            if info.need_invite(ctype):
+                return info.name
+        return ""
+
+    def update_invite_history(self, ctype: CooperationType, name: str):
+        # 更新邀请信息
+        for info in self.invite_info_list:
+            if info.name != name:
+                continue
+            info.update_invite_history(ctype, name)
+
+    def update_account_login_history(self, account: AccountInfo):
+        accountInfoList = self.sup_account_list
+        for info in accountInfoList:
+            if info.character != account.character or info.svr != account.svr:
+                continue
+            info.last_complete_time = datetime.now()
+            break
+
+    def get_cooperation_type_mask(self) -> CooperationSelectMaskDescription:
+        """
+            根据配置中各个邀请人 的邀请类型
+            综合得出该值
+        """
+        result = CooperationSelectMask.NoInvite
+        for info in self.invite_info_list:
+            result |= CooperationSelectMask[info.default_invite_type]
+        name = CooperationSelectMask(result).name
+        return CooperationSelectMaskDescription(name)
+
+    @model_validator(mode='before')
+    @classmethod
+    def validator_all(cls, v: dict) -> Any:
+        invite_info_count = v.get('find_jade_config', {}).get('invite_info_count', 1)
+        sup_account_count = v.get('find_jade_config', {}).get('sup_account_count', 1)
+
+        def validator_list(list_name, data, item_type=None, list_size=1):
+            if list_name not in data:
+                data[list_name] = []
+
+            remove_keys = []
+            for key, value in data.items():
+                if list_name == key or list_name not in key:
+                    continue
+                try:
+                    item = item_type(**value)
+                    if item.is_valid():
+                        data[list_name].append(item)
+                    remove_keys.append(key)
+                except ValidationError as e:
+                    pass
+                except TypeError as e:
+                    pass
+
+            for key in remove_keys:
+                del data[key]
+
+            if item_type is not None:
+                if len(data[list_name]) < list_size:
+                    for i in range(list_size - len(data[list_name])):
+                        data[list_name].append(item_type())
+
+        validator_list('invite_info_list', v, InviteInfo, invite_info_count)
+        validator_list('sup_account_list', v, AccountInfo, sup_account_count)
+
+        return v
+
+    @model_serializer()
+    def serializer_model(self, value: Any) -> Dict[str, Any]:
+        properties = self.__dict__
+        data = {}
+
+        def v_dump(v):
+            try:
+                return v.model_dump()
+            except AttributeError as e:
+                logger.error(e)
+                return v
+
+        for key, value in properties.items():
+            if isinstance(value, list):
+                for index, v in enumerate(value):
+                    data[f'{key}_{index + 1}'] = v_dump(v)
+            else:
+                data[key] = v_dump(value)
+        return data

+ 113 - 0
tasks/FindJade/script_task.py

@@ -0,0 +1,113 @@
+import importlib
+from datetime import datetime, timedelta
+
+from module.exception import TaskEnd, RequestHumanTakeover
+from module.logger import logger
+from tasks.Component.SwitchAccount.switch_account import SwitchAccount
+from tasks.FindJade import WantedQuestsEx
+from tasks.FindJade.assets import FindJadeAssets
+from tasks.FindJade.config import AccountInfo, FindJade
+from tasks.GameUi.game_ui import GameUi
+
+
+class ScriptTask(GameUi, FindJadeAssets):
+    fade_conf: FindJade= None
+
+    def run(self):
+        self.fade_conf = self.config.find_jade
+
+        for accountInfo in self.fade_conf.sup_account_list:
+            logger.info("start %s-%s ", accountInfo.character, accountInfo.svr)
+            if not self.is_need_login(accountInfo):
+                logger.warning("%s Skipped last Login Time:%s", accountInfo.character, accountInfo.last_complete_time)
+                continue
+            suc = SwitchAccount(self.config, self.device, accountInfo).switchAccount()
+            if not suc:
+                logger.warning("switch to %s-%s Failed", accountInfo.character, accountInfo.svr)
+                continue
+            #
+            wq = self.CreatObjectFromModule("WantedQuests", config=self.config, device=self.device)
+            wq.fade_conf = self.fade_conf
+
+            try:
+                wq.run()
+            except TaskEnd as e:
+                logger.warning("%s-%s TaskEnd", accountInfo.character, accountInfo.svr)
+                # 更新配置文件中的时间
+                self.fade_conf.update_account_login_history(accountInfo)
+                self.save_config()
+                continue
+            except RequestHumanTakeover as e:
+                raise
+            except Exception as e:
+                logger.error(e)
+                self.next_run("FindJade", success=False)
+        self.next_run("FindJade", success=True)
+        raise TaskEnd("FindJade")
+        pass
+
+
+    def is_need_login(self, item: AccountInfo):
+        """
+            根据上次登陆时间 判断是否需要登录查找
+        @param item:
+        @type item:
+        """
+        lastTime = item.last_complete_time
+        now = datetime.now()
+        if now - lastTime > timedelta(hours=13):
+            return True
+        if (lastTime.hour >= 18 or lastTime.hour < 5) and (18 > now.hour >= 5):
+            return True
+        if (5 <= lastTime.hour < 18) and now.hour >= 18:
+            return True
+        return False
+
+    def CreatObjectFromModule(self, task_name: str, **kwargs):
+        module_name = 'script_task'
+        from pathlib import Path
+        module_path = str(Path.cwd() / 'tasks' / task_name / (module_name + '.py'))
+
+        spec = importlib.util.spec_from_file_location(module_name, module_path)
+        module = importlib.util.module_from_spec(spec)
+        spec.loader.exec_module(module)
+
+        WQEX = type("WQEX", (module.ScriptTask,), {
+            "need_invite_vip": WantedQuestsEx.need_invite_vip,
+            "get_invite_vip_name": WantedQuestsEx.get_invite_vip_name,
+            "next_run": WantedQuestsEx.next_run,
+            "invite_success_callback": WantedQuestsEx.invite_success_callback,
+            "get_config": WantedQuestsEx.get_config
+        })
+        wq = WQEX(**kwargs)
+        return wq
+
+    def save_config(self):
+        self.config.save()
+
+    def next_run(self, task: str, finish: bool = False,
+                 success: bool = None, server: bool = True, target: datetime = None) -> None:
+        now = datetime.now()
+        if success:
+            if 5 <= now.hour < 18:
+                self.set_next_run(task, target=now.replace(hour=18, minute=5))
+            elif now.hour < 5:
+                self.set_next_run(task, target=now.replace(hour=5, minute=5))
+            else:
+                self.set_next_run(task, target=now.replace(hour=18, minute=5) + timedelta(days=1))
+        else:
+            self.set_next_run(task, target=now + timedelta(minutes=10))
+
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+    # from mypatch import SimplePatch
+
+    # SimplePatch.patch()
+
+    c = Config('oas1')
+    d = Device(c)
+    t = ScriptTask(c, d)
+
+    t.run()

+ 2 - 0
tasks/GameUi/assets.py

@@ -170,6 +170,8 @@ class GameUiAssets:
 	I_BACK_DAILY = RuleImage(roi_front=(33,13,39,50), roi_back=(33,13,39,50), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_back_daily.png")
 	# description 
 	I_NEW = RuleImage(roi_front=(0,0,100,100), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/image_name.png")
+	# 下载拓展包弹窗
+	I_DLC_CLOSE = RuleImage(roi_front=(916,147,24,25), roi_back=(916,147,24,25), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/store_dlc_close.png")
 
 
 	# Image Rule Assets

+ 1 - 1
tasks/GameUi/page.py

@@ -143,7 +143,7 @@ page_daily.link(button=G.I_BACK_Y, destination=page_main)
 page_main.link(button=G.I_MAIN_GOTO_DAILY, destination=page_daily)
 # 商店 mall
 page_mall = Page(G.I_CHECK_MALL)
-page_mall.additional = [G.I_AD_CLOSE_RED, G.I_BACK_Y]
+page_mall.additional = [G.I_AD_CLOSE_RED, G.I_BACK_Y, G.I_DLC_CLOSE]
 page_mall.link(button=G.I_BACK_BLUE, destination=page_main)
 page_main.link(button=G.I_MAIN_GOTO_MALL, destination=page_mall)
 # 阴阳寮 guild

+ 9 - 0
tasks/GameUi/page/page_img_3.json

@@ -187,5 +187,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
+  },
+  {
+    "itemName": "dlc_close",
+    "imageName": "store_dlc_close.png",
+    "roiFront": "916,147,24,25",
+    "roiBack": "916,147,24,25",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "下载拓展包弹窗"
   }
 ]

BIN
tasks/GameUi/page/store_dlc_close.png


+ 1 - 1
tasks/KekkaiActivation/config.py

@@ -12,7 +12,7 @@ from tasks.Component.config_base import ConfigBase, TimeDelta
 from tasks.Utils.config_enum import ShikigamiClass
 
 class ActivationScheduler(Scheduler):
-    priority = Field(default=2, description='priority_help')
+    priority: int = Field(default=2, description='priority_help')
     success_interval: TimeDelta = Field(default=TimeDelta(days=1), description='success_interval_help')
     failure_interval: TimeDelta = Field(default=TimeDelta(hours=10), description='failure_interval_help')
 

+ 4 - 1
tasks/KekkaiActivation/script_task.py

@@ -365,7 +365,10 @@ class ScriptTask(KU, KekkaiActivationAssets):
                 if not self.appear(self.I_REALM_SHIN):
                     continue
                 break
-            if self.appear_then_click(self.I_UI_BACK_BLUE, interval=2.5):
+            # 有时候退出动画太久点了两次退出,需要重新进入
+            if self.appear_then_click(self.I_GUILD_REALM, interval=1.5):
+                continue
+            if self.appear_then_click(self.I_UI_BACK_BLUE, interval=5.5):
                 continue
 
     def harvest_card(self):

+ 1 - 1
tasks/KekkaiUtilize/config.py

@@ -22,7 +22,7 @@ class UtilizeRule(str, Enum):
 
 
 class UtilizeScheduler(Scheduler):
-    priority = Field(default=2, description='priority_help')
+    priority: int = Field(default=2, description='priority_help')
     success_interval: TimeDelta = Field(default=TimeDelta(hours=6), description='success_interval_help')
     failure_interval: TimeDelta = Field(default=TimeDelta(hours=6), description='failure_interval_help')
 

+ 2 - 0
tasks/Orochi/script_task.py

@@ -131,6 +131,8 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
         self.orochi_enter()
         layer = self.config.orochi.orochi_config.layer
         self.check_layer(layer)
+        # https://github.com/runhey/OnmyojiAutoScript/issues/592
+        self.config.orochi.general_battle_config.lock_team_enable = True
         self.check_lock(self.config.orochi.general_battle_config.lock_team_enable)
         # 创建队伍
         logger.info('Create team')

+ 3 - 3
tasks/RealmRaid/assets.py

@@ -97,18 +97,18 @@ class RealmRaidAssets:
 	# 用来分割不同的挑战位置 
 	C_PARTITION_2 = RuleClick(roi_front=(566,148,237,115), roi_back=(566,148,237,115), name="partition_2")
 	# 用来分割不同的挑战位置 
-	C_PARTITION_3 = RuleClick(roi_front=(895,147,232,116), roi_back=(895,147,232,116), name="partition_3")
+	C_PARTITION_3 = RuleClick(roi_front=(900,147,222,116), roi_back=(900,147,222,116), name="partition_3")
 	# 用来分割不同的挑战位置 
 	C_PARTITION_4 = RuleClick(roi_front=(236,283,229,124), roi_back=(236,283,229,124), name="partition_4")
 	# 用来分割不同的挑战位置 
 	C_PARTITION_5 = RuleClick(roi_front=(564,280,237,120), roi_back=(564,280,237,120), name="partition_5")
 	# 用来分割不同的挑战位置 
-	C_PARTITION_6 = RuleClick(roi_front=(899,282,232,120), roi_back=(899,282,232,120), name="partition_6")
+	C_PARTITION_6 = RuleClick(roi_front=(900,282,222,120), roi_back=(900,282,222,120), name="partition_6")
 	# 用来分割不同的挑战位置 
 	C_PARTITION_7 = RuleClick(roi_front=(233,416,236,121), roi_back=(233,416,236,121), name="partition_7")
 	# 用来分割不同的挑战位置 
 	C_PARTITION_8 = RuleClick(roi_front=(567,413,230,124), roi_back=(567,413,230,124), name="partition_8")
 	# 用来分割不同的挑战位置 
-	C_PARTITION_9 = RuleClick(roi_front=(897,418,230,116), roi_back=(897,418,230,116), name="partition_9")
+	C_PARTITION_9 = RuleClick(roi_front=(900,418,222,116), roi_back=(900,418,222,116), name="partition_9")
 
 

+ 6 - 6
tasks/RealmRaid/res/partition.json

@@ -13,8 +13,8 @@
   },
   {
     "itemName": "partition_3",
-    "roiFront": "895,147,232,116",
-    "roiBack": "895,147,232,116",
+    "roiFront": "900,147,222,116",
+    "roiBack": "900,147,222,116",
     "description": "用来分割不同的挑战位置"
   },
   {
@@ -31,8 +31,8 @@
   },
   {
     "itemName": "partition_6",
-    "roiFront": "899,282,232,120",
-    "roiBack": "899,282,232,120",
+    "roiFront": "900,282,222,120",
+    "roiBack": "900,282,222,120",
     "description": "用来分割不同的挑战位置"
   },
   {
@@ -49,8 +49,8 @@
   },
   {
     "itemName": "partition_9",
-    "roiFront": "897,418,230,116",
-    "roiBack": "897,418,230,116",
+    "roiFront": "900,418,222,116",
+    "roiBack": "900,418,222,116",
     "description": "用来分割不同的挑战位置"
   }
 ]

+ 6 - 6
tasks/Restart/assets.py

@@ -1,9 +1,7 @@
-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.image import RuleImage
 from module.atom.ocr import RuleOcr
-from module.atom.list import RuleList
+
 
 # This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
@@ -50,7 +48,9 @@ class RestartAssets:
 	# 宠物小屋关闭按钮 
 	I_HARVEST_BACK_PET_HOUSE = RuleImage(roi_front=(20,15,70,70), roi_back=(20,15,70,70), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_back_pet_house.png")
 	# 点击庭院阴阳师出现的姿度按钮 
-	I_HARVEST_ZIDU = RuleImage(roi_front=(785,475,135,135), roi_back=(785,475,135,135), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_zidu.png")
+	I_HARVEST_ZIDU = RuleImage(roi_front=(785,475,135,135), roi_back=(785,475,135,135), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_zidu.png")
+	# description 
+	I_HARVEST_MAIL_COPY = RuleImage(roi_front=(257,509,29,21), roi_back=(192,472,790,100), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_mail_copy.png")
 
 
 	# Click Rule Assets
@@ -72,7 +72,7 @@ class RestartAssets:
 	# 登录时候不观看CG视频 
 	I_WATCH_VIDEO_CANCEL = RuleImage(roi_front=(466,396,130,61), roi_back=(466,396,130,61), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_watch_video_cancel.png")
 	# 指定角色进入游戏,默认第一个 
-	I_LOGIN_SPECIFIC_SERVE = RuleImage(roi_front=(24,33,52,47), roi_back=(24,33,52,47), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_login_specific_serve.png")
+	I_LOGIN_SPECIFIC_SERVE = RuleImage(roi_front=(0,0,120,120), roi_back=(0,0,120,120), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_login_specific_serve.png")
 	# 下载插画 
 	I_LOGIN_LOAD_DOWN = RuleImage(roi_front=(711,450,153,58), roi_back=(711,450,153,58), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_login_load_down.png")
 	# 登录界面 弹出框 前往绑定 手机 

BIN
tasks/Restart/harvest/harvest_harvest_mail_copy.png


+ 0 - 0
tasks/Restart/harvest/harvest_zidu.png → tasks/Restart/harvest/harvest_harvest_zidu.png


+ 10 - 1
tasks/Restart/harvest/image.json

@@ -172,11 +172,20 @@
   },
   {
     "itemName": "harvest_zidu",
-    "imageName": "harvest_zidu.png",
+    "imageName": "harvest_harvest_zidu.png",
     "roiFront": "785,475,135,135",
     "roiBack": "785,475,135,135",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "点击庭院阴阳师出现的姿度按钮"
+  },
+  {
+    "itemName": "harvest_mail_copy",
+    "imageName": "harvest_harvest_mail_copy.png",
+    "roiFront": "257,509,29,21",
+    "roiBack": "192,472,790,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
   }
 ]

+ 9 - 5
tasks/Restart/login.py

@@ -98,15 +98,19 @@ class LoginHandler(BaseTask, RestartAssets):
             # 点击屏幕进入游戏
             if self.appear(self.I_LOGIN_SPECIFIC_SERVE, interval=0.6) \
                     and self.ocr_appear_click(self.O_LOGIN_SPECIFIC_SERVE, interval=0.6):
-                self.ui_click(self.C_LOGIN_ENSURE_LOGIN_CHARACTER_IN_SAME_SVR,
-                              stop=self.I_LOGIN_SCROOLL_CLOSE, interval=2)
+                while True:
+                    self.screenshot()
+                    if self.appear(self.I_LOGIN_SPECIFIC_SERVE):
+                        self.click(self.C_LOGIN_ENSURE_LOGIN_CHARACTER_IN_SAME_SVR,interval=2)
+                        continue
+                    break
                 logger.info('login specific user')
                 continue
             # 点击’进入游戏‘
             if not self.appear(self.I_LOGIN_8):
                 continue
             if self.ocr_appear_click(self.O_LOGIN_ENTER_GAME, interval=3):
-                self.wait_until_appear(self.I_LOGIN_SPECIFIC_SERVE, False, wait_time=2)
+                self.wait_until_appear(self.I_LOGIN_SPECIFIC_SERVE, True, wait_time=5)
                 continue
 
         return login_success
@@ -197,8 +201,8 @@ class LoginHandler(BaseTask, RestartAssets):
             # 邮件
             # 判断是否勾选了收取邮件(不收取邮件可以查看每日收获)
             if self.config.restart.harvest_config.enable_mail:
-
-                if self.appear_then_click(self.I_HARVEST_MAIL, interval=3):
+                if self.appear_then_click(self.I_HARVEST_MAIL, interval=3) or\
+                        self.appear_then_click(self.I_HARVEST_MAIL_COPY, interval=3):
                     timer_harvest.reset()
                     self.wait_until_appear(self.I_HARVEST_MAIL_TITLE, wait_time=2)
                     if self.appear(self.I_HARVEST_MAIL_TITLE, interval=2.5):

+ 2 - 2
tasks/Restart/login/image.json

@@ -56,8 +56,8 @@
   {
     "itemName": "login_specific_serve",
     "imageName": "login_login_specific_serve.png",
-    "roiFront": "24,33,52,47",
-    "roiBack": "24,33,52,47",
+    "roiFront": "0,0,120,120",
+    "roiBack": "0,0,120,120",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "指定角色进入游戏,默认第一个"

+ 21 - 6
tasks/Restart/script_task.py

@@ -1,7 +1,7 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
-
+from datetime import datetime
 
 from tasks.Restart.config_scheduler import Scheduler
 from tasks.Restart.login import LoginHandler
@@ -12,8 +12,6 @@ from module.logger import logger
 from module.exception import TaskEnd, RequestHumanTakeover
 
 
-
-
 class ScriptTask(LoginHandler):
 
     def run(self) -> None:
@@ -21,10 +19,10 @@ class ScriptTask(LoginHandler):
         主要就是登录的模块
         :return:
         """
-        self.app_restart()
+        if not self.delay_pending_tasks():
+            self.app_restart()
         raise TaskEnd('ScriptTask end')
 
-
     def app_stop(self):
         logger.hr('App stop')
         self.device.app_stop()
@@ -44,6 +42,22 @@ class ScriptTask(LoginHandler):
         # self.config.task_delay(server_update=True)
         self.set_next_run(task='Restart', success=True, finish=True, server=True)
 
+    def delay_pending_tasks(self) -> bool:
+        """
+        周三更新游戏的时候延迟
+        @return:
+        """
+        datetime_now = datetime.now()
+        if not (datetime_now.weekday() == 2 and 6 <= datetime_now.hour <= 8):
+            return False
+        logger.info("The game server is updating, delay the pending tasks to 9:00")
+        logger.warning('Delay pending tasks')
+        # running 中的必然是 Restart
+        for task in self.config.pending_task:
+            print(task.command)
+            self.set_next_run(task=task.command, target=datetime_now.replace(hour=9, minute=0, second=0, microsecond=0))
+        self.set_next_run(task='Restart', success=True, finish=True, server=True)
+        return True
 
 
 if __name__ == '__main__':
@@ -53,7 +67,8 @@ if __name__ == '__main__':
     config = Config('oas1')
     device = Device(config)
     task = ScriptTask(config, device)
-    task.app_restart()
+    task.config.update_scheduler()
+    task.delay_pending_tasks()
     # task.screenshot()
     # print(task.appear_then_click(task.I_LOGIN_SCROOLL_CLOSE, threshold=0.9))
 

+ 14 - 0
tasks/Secret/script_task.py

@@ -3,6 +3,7 @@
 # github https://github.com/runhey
 import time
 from cached_property import cached_property
+from datetime import datetime
 
 from module.exception import TaskEnd
 from module.logger import logger
@@ -37,6 +38,7 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
         return GeneralBattleConfig()
 
     def run(self):
+        self.check_time()
         secret: Secret = self.config.secret
         con = secret.secret_config
         if secret.switch_soul.enable:
@@ -268,6 +270,18 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
                 self.ui_click_until_disappear(self.I_FALSE)
                 return False
 
+    def check_time(self) -> None:
+        """
+        周一早上不能打
+        @return:
+        """
+        time_now = datetime.now()
+        if time_now.weekday() == 0 and time_now.hour < 8:
+            self.set_next_run(task='Secret',
+                              finish=True,
+                              server=time_now.replace(hour=9, minute=0, second=0, microsecond=0))
+            raise TaskEnd('Secret')
+
 
 if __name__ == '__main__':
     from module.config.config import Config

+ 1 - 1
tasks/SoulsTidy/script_task.py

@@ -74,7 +74,7 @@ class ScriptTask(GameUi, SoulsTidyAssets):
                 continue
             if feed_count >= 3:
                 break
-            if self.appear_then_click(self.I_ST_FEED_NOW, interval=1.9):
+            if self.appear_then_click(self.I_ST_FEED_NOW, interval=3.5):
                 feed_count += 1
                 continue
         logger.info('Feed greed ghost done')

+ 1 - 1
tasks/TrueOrochi/config.py

@@ -22,7 +22,7 @@ class GreenMarkType(str, Enum):
 
 
 class TrueOrochiScheduler(Scheduler):
-    priority = Field(default=10, description='priority_help')
+    priority: int = Field(default=10, description='priority_help')
     success_interval: TimeDelta = Field(default=TimeDelta(days=7), description='success_interval_help')
     failure_interval: TimeDelta = Field(default=TimeDelta(days=1), description='failure_interval_help')
 

+ 16 - 2
tasks/WantedQuests/assets.py

@@ -15,6 +15,8 @@ class WantedQuestsAssets:
 	C_SECRET_CHAT = RuleClick(roi_front=(597,296,59,100), roi_back=(597,296,59,100), name="secret_chat")
 	# 特殊的庭院需要点击,然后才能找到这个悬赏 
 	C_SPECIAL_MAIN = RuleClick(roi_front=(409,572,32,30), roi_back=(404,569,41,35), name="special_main")
+	# 关闭 单个任务追踪界面 所需点击 的  空白区域 
+	C_WQ_TRACE_ONE_CLOSE = RuleClick(roi_front=(170,30,400,100), roi_back=(170,30,400,100), name="wq_trace_one_close")
 
 
 	# Ocr Rule Assets
@@ -83,11 +85,15 @@ class WantedQuestsAssets:
 	# 悬赏封印邀请取消按钮 
 	I_WQ_INVITE_CANCEL = RuleImage(roi_front=(230,540,132,60), roi_back=(230,540,140,65), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_cancel.png")
 	# 邀请好友被选中标记 
-	I_WQ_INVITE_SELECTED = RuleImage(roi_front=(380,170,32,32), roi_back=(380,170,360,375), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_selected.png")
+	I_WQ_INVITE_SELECTED = RuleImage(roi_front=(370,180,32,32), roi_back=(370,180,370,355), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_selected.png")
+	# 邀请好友被选中标记 
+	I_WQ_INVITE_FRIEND_LIST_APPEAR = RuleImage(roi_front=(370,180,32,32), roi_back=(370,180,370,355), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_friend_list_appear.png")
 	# 邀请同服好友,由于选中与未选中亮度有区别,查找图片可能会出错,建议只使用位置信息 
 	I_WQ_INVITE_SAME_SVR = RuleImage(roi_front=(170,90,60,35), roi_back=(170,90,105,65), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_same_svr.png")
 	# 邀请跨服好友,由于选中与未选中亮度有区别,查找图片可能会出错,建议只使用位置信息 
 	I_WQ_INVITE_DIFF_SVR = RuleImage(roi_front=(280,90,60,35), roi_back=(280,90,105,65), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_diff_svr.png")
+	# 邀请跨服好友,已选中状态,高亮状态 
+	I_WQ_INVITE_DIFF_SVR_HIGHLIGHT = RuleImage(roi_front=(260,70,120,90), roi_back=(260,70,120,90), threshold=0.9, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_diff_svr_highlight.png")
 	# 从左到右第一个协作任务的类型 
 	I_WQ_COOPERATION_TYPE_GOLD_1 = RuleImage(roi_front=(195,505,180,90), roi_back=(195,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_gold.png")
 	# 从左到右第一个协作任务的类型 
@@ -135,7 +141,7 @@ class WantedQuestsAssets:
 	# 一键追踪 
 	I_TRACE_ENABLE = RuleImage(roi_front=(1097,588,101,70), roi_back=(1097,588,101,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_enable.png")
 	# 取消追踪 
-	I_TARCE_DISENABLE = RuleImage(roi_front=(1091,586,108,70), roi_back=(1091,586,108,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_tarce_disenable.png")
+	I_TRACE_DISABLE = RuleImage(roi_front=(1091,586,108,70), roi_back=(1091,586,108,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_disable.png")
 	# 奖励宝箱 
 	I_WQ_BOX = RuleImage(roi_front=(48,187,43,38), roi_back=(20,137,100,397), threshold=0.7, method="Template matching", file="./tasks/WantedQuests/wq/wq_wq_box.png")
 	# 小号追踪 
@@ -152,6 +158,14 @@ class WantedQuestsAssets:
 	I_GOTO_4 = RuleImage(roi_front=(979,447,87,42), roi_back=(979,447,87,42), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_4.png")
 	# 判断是否还有任务 
 	I_WQ_CHECK_TASK = RuleImage(roi_front=(110,154,21,125), roi_back=(73,122,69,459), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_wq_check_task.png")
+	# 庭院悬赏任务界面 单个任务点开后 左上角是否追踪 
+	I_WQ_TRACE_ONE_ENABLE = RuleImage(roi_front=(160,175,120,60), roi_back=(160,175,120,60), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_one_enable.png")
+	# 庭院悬赏任务界面 单个任务点开后 左上角是否追踪 
+	I_WQ_TRACE_ONE_DISABLE = RuleImage(roi_front=(160,175,120,60), roi_back=(160,175,120,60), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_one_disable.png")
+	# 庭院悬赏任务界面 单个任务点开后的界面 是否打开的 标志 
+	I_WQ_TRACE_ONE_CHECK_OPENED = RuleImage(roi_front=(510,175,210,60), roi_back=(510,175,210,60), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_one_check_opened.png")
+	# 庭院悬赏任务界面 单个任务点开后的界面 是否为现世任务标志 
+	I_WQ_TRACE_ONE_REALWORLD = RuleImage(roi_front=(850,470,180,180), roi_back=(850,470,180,180), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_one_realworld.png")
 
 
 	# Image Rule Assets

+ 6 - 0
tasks/WantedQuests/click.json

@@ -10,5 +10,11 @@
     "roiFront": "409,572,32,30",
     "roiBack": "404,569,41,35",
     "description": "特殊的庭院需要点击,然后才能找到这个悬赏"
+  },
+  {
+    "itemName": "wq_trace_one_close",
+    "roiFront": "170,30,400,100",
+    "roiBack": "170,30,400,100",
+    "description": "关闭 单个任务追踪界面 所需点击 的  空白区域"
   }
 ]

+ 27 - 20
tasks/WantedQuests/config.py

@@ -1,46 +1,51 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
-from datetime import timedelta, time
 from enum import Enum
-from pydantic import BaseModel, Field, validator
 
-from tasks.Component.config_scheduler import Scheduler
-from tasks.Component.config_base import ConfigBase, Time
-from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from pydantic import BaseModel, Field
+
 from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
+from tasks.Component.config_base import ConfigBase, Time
+from tasks.Component.config_scheduler import Scheduler
 
 
 class CooperationType(int, Enum):
     """
         用于区分悬赏封印协作类型
     """
-    Gold = 1     #金币协作
-    Jade = 2     #勾玉协作
-    Food = 4     #狗/猫粮协作   
-    Sushi = 8    #体力协作
+    Gold = 1  # 金币协作
+    Jade = 2  # 勾玉协作
+    Food = 4  # 狗/猫粮协作
+    Sushi = 8  # 体力协作
+
+    def __hash__(self):
+        return self.value
+
+    def __str__(self):
+        return str(self.value)
 
 
 class CooperationSelectMask(int, Enum):
     """
         掩码,对协作任务进行筛选
     """
-    NoInvite = 0                #不自动邀请
-    GoldOnly = 1                #仅 金币 协作进行邀请
-    JadeOnly = 2                #仅 勾玉 协作进行邀请
+    NoInvite = 0  # 不自动邀请
+    GoldOnly = 1  # 仅 金币 协作进行邀请
+    JadeOnly = 2  # 仅 勾玉 协作进行邀请
     GoldAndJade = 3
-    FoodOnly = 4                #仅 狗/猫粮 协作进行邀请
-    GoldAndFood = 5    
+    FoodOnly = 4  # 仅 狗/猫粮 协作进行邀请
+    GoldAndFood = 5
     JadeAndFood = 6
     GoldAndJadeAndFood = 7
-    SushiOnly = 8               #仅 体力 协作进行邀请
-    GoldAndSushi = 9            
+    SushiOnly = 8  # 仅 体力 协作进行邀请
+    GoldAndSushi = 9
     JadeAndSushi = 10
     GoldAndJadeAndSushi = 11
     FoodAndSushi = 12
     GoldAndFoodAndSushi = 13
     JadeAndFoodAndSushi = 14
-    Any = 15                    #所有协作任务都邀请
+    Any = 15  # 所有协作任务都邀请
 
 
 class CooperationSelectMaskDescription(str, Enum):
@@ -81,13 +86,15 @@ class CooperationSelectMaskDescription(str, Enum):
 class WantedQuestsConfig(BaseModel):
     before_end: Time = Field(default=Time(0, 0, 0), description='before_end_help')
     invite_friend_name: str = Field(default=str(""), description="invite_friend_name_help")
-    cooperation_type: CooperationSelectMaskDescription = Field(default=CooperationSelectMaskDescription.Any, description="cooperation_type_help")
+    cooperation_type: CooperationSelectMaskDescription = Field(default=CooperationSelectMaskDescription.Any,
+                                                               description="cooperation_type_help")
     # 找怪优先级  挑战 > 秘闻 > 探索
     battle_priority: str = Field(default='挑战 > 秘闻 > 探索', description='battle_priority_help')
-
+    # 只完成协作任务
+    cooperation_only: bool = Field(default=False, description="cooperation_only_help")
 
 
 class WantedQuests(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     wanted_quests_config: WantedQuestsConfig = Field(default_factory=WantedQuestsConfig)
-    switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
+    switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)

+ 8 - 3
tasks/WantedQuests/explore.py

@@ -1,10 +1,9 @@
 from cached_property import cached_property
 
-from module.atom.image import RuleImage
 from module.atom.animate import RuleAnimate
+from module.atom.image import RuleImage
 from module.base.timer import Timer
 from module.logger import logger
-
 from tasks.Exploration.base import BaseExploration, Scene
 from tasks.Exploration.version import HighLight
 
@@ -61,7 +60,13 @@ class WQExplore(BaseExploration, HighLight):
             # 探索里面
             elif scene == Scene.MAIN:
                 if not explore_init:
-                    self.ui_click(self.I_E_AUTO_ROTATE_OFF, stop=self.I_E_AUTO_ROTATE_ON)
+                    count=0
+                    while count<5:
+                        if self.appear(self.I_E_AUTO_ROTATE_ON):
+                            break
+                        if self.appear(self.I_E_AUTO_ROTATE_OFF, interval=1.5):
+                            self.click(self.I_E_AUTO_ROTATE_OFF)
+                            count+=1
                     explore_init = True
                     continue
                 # 小纸人

+ 20 - 2
tasks/WantedQuests/invite/image.json

@@ -92,12 +92,21 @@
   {
     "itemName": "wq_invite_selected",
     "imageName": "wq_invite_selected.png",
-    "roiFront": "380,170,32,32",
-    "roiBack": "380,170,360,375",
+    "roiFront": "370,180,32,32",
+    "roiBack": "370,180,370,355",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "邀请好友被选中标记"
   },
+  {
+    "itemName": "wq_invite_friend_list_appear",
+    "imageName": "wq_invite_friend_list_appear.png",
+    "roiFront": "370,180,32,32",
+    "roiBack": "370,180,370,355",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "好友列表已加载标志"
+  },
   {
     "itemName": "wq_invite_same_svr",
     "imageName": "wq_invite_same_svr.png",
@@ -116,6 +125,15 @@
     "threshold": 0.8,
     "description": "邀请跨服好友,由于选中与未选中亮度有区别,查找图片可能会出错,建议只使用位置信息"
   },
+  {
+    "itemName": "wq_invite_diff_svr_highlight",
+    "imageName": "wq_invite_diff_svr_highlight.png",
+    "roiFront": "260,70,120,90",
+    "roiBack": "260,70,120,90",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "邀请跨服好友,已选中状态,高亮状态"
+  },
   {
     "itemName": "wq_cooperation_type_gold_1",
     "imageName": "wq_cooperation_type_gold.png",

BIN
tasks/WantedQuests/invite/wq_invite_cancel.png


BIN
tasks/WantedQuests/invite/wq_invite_diff_svr_highlight.png


BIN
tasks/WantedQuests/invite/wq_invite_friend_list_appear.png


+ 176 - 35
tasks/WantedQuests/script_task.py

@@ -1,31 +1,27 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
-import re
 import copy
-from time import sleep
+import re
 from datetime import timedelta, time, datetime
+from time import sleep
+from typing import List
+
+import cv2
 from cached_property import cached_property
-from enum import Enum
-from module.atom.image import RuleImage
+from markdown_it.rules_inline import image
 
+from module.atom.image import RuleImage
+from module.base.timer import Timer
 from module.exception import TaskEnd
 from module.logger import logger
-from module.base.timer import Timer
-
-from tasks.GameUi.game_ui import GameUi
-from tasks.GameUi.page import page_main, page_exploration, page_shikigami_records
-from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.Component.Costume.config import MainType
 from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
-from tasks.Component.GeneralInvite.general_invite import GeneralInvite
+from tasks.GameUi.page import page_main, page_exploration, page_shikigami_records
 from tasks.Secret.script_task import ScriptTask as SecretScriptTask
-from tasks.WantedQuests.config import WantedQuestsConfig, CooperationType, CooperationSelectMask, \
-    CooperationSelectMaskDescription
 from tasks.WantedQuests.assets import WantedQuestsAssets
+from tasks.WantedQuests.config import CooperationType, CooperationSelectMask
 from tasks.WantedQuests.explore import WQExplore, ExploreWantedBoss
-from tasks.Component.Costume.config import MainType
-from typing import List
-from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 
 
 class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
@@ -43,7 +39,12 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             self.ui_goto(page_shikigami_records)
             self.run_switch_soul_by_name(con.switch_soul_config.group_name, con.switch_soul_config.team_name)
 
-        if not self.pre_work():
+        preSuc = False
+        if (self.get_config()).cooperation_only:
+            preSuc = self.pre_work_cooperation_only()
+        else:
+            preSuc = self.pre_work()
+        if not preSuc:
             # 无法完成预处理 很有可能你已经完成了悬赏任务
             logger.warning('Cannot pre-work')
             logger.warning('You may have completed the reward task')
@@ -113,7 +114,7 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         raise TaskEnd('WantedQuests')
 
     def next_run(self):
-        before_end: time = self.config.wanted_quests.wanted_quests_config.before_end
+        before_end: time = self.get_config().before_end
         if before_end == time(hour=0, minute=0, second=0):
             self.set_next_run(task='WantedQuests', success=True, finish=True)
             return
@@ -144,7 +145,7 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         done_timer = Timer(5)
         while 1:
             self.screenshot()
-            if self.appear(self.I_TARCE_DISENABLE):
+            if self.appear(self.I_TRACE_DISABLE):
                 break
             if self.appear_then_click(self.I_WQ_SEAL, interval=1):
                 continue
@@ -167,14 +168,75 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         # 存在协作任务则邀请
         self.screenshot()
         if self.appear(self.I_WQ_INVITE_1) or self.appear(self.I_WQ_INVITE_2) or self.appear(self.I_WQ_INVITE_3):
-            if self.config.wanted_quests.wanted_quests_config.invite_friend_name:
-                self.all_cooperation_invite(self.config.wanted_quests.wanted_quests_config.invite_friend_name)
+            if self.need_invite_vip():
+                self.all_cooperation_invite()
             else:
                 self.invite_five()
         self.ui_click_until_disappear(self.I_UI_BACK_RED)
         self.ui_goto(page_exploration)
         return True
 
+    def pre_work_cooperation_only(self):
+        #
+        if self.ui_get_current_page() != page_main:
+            self.ui_goto(page_main)
+        # 打开悬赏封印 界面
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_TRACE_ENABLE) or self.appear(self.I_TRACE_DISABLE):
+                break
+            if self.appear_then_click(self.I_WQ_SEAL, interval=1):
+                continue
+            if self.appear_then_click(self.I_WQ_DONE, interval=1):
+                continue
+            if self.special_main and self.click(self.C_SPECIAL_MAIN, interval=3):
+                logger.info('Click special main left to find wanted quests')
+                continue
+        #
+        if not (self.appear(self.I_WQ_INVITE_1) or self.appear(self.I_WQ_INVITE_2) or self.appear(self.I_WQ_INVITE_3)):
+            logger.info("there is no cooperation quest")
+            return False
+
+        # if self.appear(self.I_WQ_INVITE_1):
+        #     self.trace_one(self.I_WQ_INVITE_1)
+        # if self.appear(self.I_WQ_INVITE_2):
+        #     self.trace_one(self.I_WQ_INVITE_2)
+        # if self.appear(self.I_WQ_INVITE_3):
+        #     self.trace_one(self.I_WQ_INVITE_3)
+
+        # 追踪任务 并邀请
+        self.all_cooperation_invite()
+
+        self.ui_click_until_disappear(self.I_UI_BACK_RED)
+        self.ui_goto(page_exploration)
+        return True
+
+    def trace_one(self, btn: RuleImage):
+        """
+            参数必须为邀请按钮(I_WQ_INVITE_n ),特定场景,就不做通用的函数了,怪麻烦的,若还有什么奇葩需求,再扩展吧
+        @param btn: 邀请按钮,
+        @type btn:
+        """
+        self.screenshot()
+        if not self.appear(btn):
+            return
+        while 1:
+            self.screenshot()
+            # 追踪成功  或  是现世任务 不需要追踪
+            if self.appear(self.I_WQ_TRACE_ONE_ENABLE) or self.appear(self.I_WQ_TRACE_ONE_REALWORLD):
+                break
+            if self.appear(self.I_WQ_TRACE_ONE_DISABLE):
+                self.click(self.I_WQ_TRACE_ONE_DISABLE, interval=1.5)
+                continue
+            # 根据邀请按钮位置生成 对应的点击位置 打开追踪界面
+            # NOTE magic Number
+
+            self.device.click(btn.roi_front[0], btn.roi_front[1] - 40, control_name=str(btn) + ' y-40')
+            # 防止点击后界面来不及刷新
+            sleep(1.5)
+        # 关闭单个任务的追踪界面
+        self.ui_click_until_smt_disappear(self.C_WQ_TRACE_ONE_CLOSE, stop=self.I_WQ_TRACE_ONE_CHECK_OPENED, interval=1.5)
+
     def execute_mission(self, ocr, num_want: int, num_challenge: int):
         """
 
@@ -262,8 +324,8 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             logger.warning('The extreme case. The quest only needs to challenge one final boss, so skip it')
             self.want_strategy_excluding.append(info_wq_list[0])
 
-    def challenge(self, goto, num):
-        self.ui_click(goto, self.I_WQC_FIRE)
+    def challenge(self, goto_btn, num):
+        self.ui_click(goto_btn, self.I_WQC_FIRE)
         self.ui_click(self.I_WQC_UNLOCK, self.I_WQC_LOCK)
         self.ui_click_until_disappear(self.I_WQC_FIRE)
         # 锁定阵容进入战斗
@@ -340,10 +402,10 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         self.invite_random(self.I_WQ_INVITE_2)
         self.invite_random(self.I_WQ_INVITE_3)
 
-    def all_cooperation_invite(self, name: str):
+    def all_cooperation_invite(self, name_all: str = None):
         """
             所有的协作任务依次邀请
-        @param name: 被邀请的朋友名
+            如果配置了只完成协作任务 还会将该任务设置为追踪
         @return:
 
         """
@@ -356,7 +418,7 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             logger.info("no Cooperation found")
             return False
         typeMask = 15
-        typeMask = CooperationSelectMask[self.config.wanted_quests.wanted_quests_config.cooperation_type.value]
+        typeMask = CooperationSelectMask[(self.get_config()).cooperation_type.value]
         for item in ret:
             # 该任务是需要邀请的任务类型
             if not (item['type'] & typeMask):
@@ -370,15 +432,28 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
                阴阳师BUG: 好友明明在线 但邀请界面找不到该好友(好友未接受任何协作任务的情况下)
            '''
             index = 0
+            item['inviteResult'] = False
+            if name_all is None:
+                name = self.get_invite_vip_name(item['type'])
+            else:
+                name = name_all
+            logger.warning("find cooperationType %s ,start invite %s", item['type'], name)
             while index < 5:
                 if self.cooperation_invite(item['inviteBtn'], name):
                     item['inviteResult'] = True
                     index = 5
+                    continue
                 logger.info("%s not found,Wait 20s,%d invitations left", name, 5 - index - 1)
                 index += 1
                 sleep(20) if index < 5 else sleep(0)
                 # NOTE 等待过程如果出现协作邀请 将会卡住 为了防止卡住
                 self.screenshot()
+            # 邀请追踪一起吧,只有邀请成功才追踪
+            if item['inviteResult']:
+                self.invite_success_callback(item['type'], name)
+                if (self.get_config()).cooperation_only:
+                    logger.info("start trace_one")
+                    self.trace_one(item['inviteBtn'])
         return ret
 
     def cooperation_invite(self, btn: RuleImage, name: str):
@@ -396,27 +471,34 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
 
         find = False
         for i in range(2):
+            self.wait_until_appear(self.I_WQ_INVITE_FRIEND_LIST_APPEAR, wait_time=4)
             self.screenshot()
             in_col_1 = self.ocr_appear_click(self.O_WQ_INVITE_COLUMN_1)
             in_col_2 = self.ocr_appear_click(self.O_WQ_INVITE_COLUMN_2)
             find = in_col_2 or in_col_1
             if find:
+                self.wait_until_appear(self.I_WQ_INVITE_SELECTED, wait_time=2)
                 self.screenshot()
                 if self.appear(self.I_WQ_INVITE_SELECTED):
                     logger.info("friend found and selected")
                     break
                 # TODO OCR识别到文字 但是没有选中 尝试重新选择  (选择好友时,弹出协作邀请导致选择好友失败)
-            # 在当前服务器没找到,切换服务器
-            self.click(self.I_WQ_INVITE_DIFF_SVR)
-            # NOTE 跨服好友刷新缓慢,切换标签页难以检测,姑且用延时.非常卡的模拟器可能出问题
-            sleep(2)
+            # 检测跨服好友按钮是否高亮
+            while 1:
+                self.screenshot()
+                if not self.appear_highlight(self.I_WQ_INVITE_DIFF_SVR_HIGHLIGHT):
+                    self.click(self.I_WQ_INVITE_DIFF_SVR)
+                    continue
+                break
+            # 等待好友列表加载
+            self.wait_until_appear(self.I_WQ_INVITE_DIFF_SVR_HIGHLIGHT, wait_time=4)
         # 没有找到需要邀请的人,点击取消 返回悬赏封印界面
         if not find:
             self.screenshot()
-            self.click(self.I_WQ_INVITE_CANCEL)
+            self.ui_click_until_disappear(self.I_WQ_INVITE_CANCEL, interval=1.5)
             return False
         #
-        self.ui_click_until_disappear(self.I_WQ_INVITE_ENSURE)
+        self.ui_click_until_disappear(self.I_WQ_INVITE_ENSURE, interval=1)
         return True
 
     def get_cooperation_info(self) -> List:
@@ -447,9 +529,42 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             if self.appear(self.__getattribute__("I_WQ_COOPERATION_TYPE_GOLD_" + str(index + 1))):
                 retList.append({'type': CooperationType.Gold, 'inviteBtn': btn})
                 continue
-
+        logger.info(f"get cooperation size {len(retList)}")
         return retList
 
+    # 使用平均亮度检测是否一致
+    def appear_highlight(self, rule_image: RuleImage):
+        def compute_region_brightness(img, top_left, width, height):
+            """
+            计算目标区域的平均亮度 (灰度图的平均值)
+            :param img: 目标图像
+            :param top_left: 匹配区域的左上角坐标
+            :param width: 模板宽度
+            :param height: 模板高度
+            :return: 区域亮度均值
+            """
+            # 裁剪出匹配区域
+            region = img[top_left[1]:top_left[1] + height, top_left[0]:top_left[0] + width]
+            # 转为灰度图
+            gray_region = cv2.cvtColor(region, cv2.COLOR_BGR2GRAY)
+            # 计算灰度均值
+            return gray_region.mean()
+
+        src = rule_image.corp(self.device.image)
+        template = rule_image.image
+        result = cv2.matchTemplate(src, template, cv2.TM_CCOEFF_NORMED)
+        _, max_val, _, max_loc = cv2.minMaxLoc(result)
+
+        brightness_src = compute_region_brightness(src, max_loc, template.shape[1], template.shape[0])
+        brightness_template = compute_region_brightness(template, (0, 0), template.shape[1], template.shape[0])
+
+        if max_val > rule_image.threshold and (brightness_src >= brightness_template * rule_image.threshold) and (
+                brightness_src <= brightness_template * (2 - rule_image.threshold)):
+            rule_image.roi_front[0] = max_loc[0] + rule_image.roi_back[0]
+            rule_image.roi_front[1] = max_loc[1] + rule_image.roi_back[1]
+            return True
+        return False
+
     @cached_property
     def special_main(self) -> bool:
         # 特殊的庭院需要点一下,左边然后才能找到图标
@@ -458,6 +573,26 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             return True
         return False
 
+    def get_config(self):
+        return self.config.wanted_quests.wanted_quests_config
+
+    def need_invite_vip(self):
+        return bool(self.get_config().invite_friend_name)
+
+    def get_invite_vip_name(self, ctype: CooperationType):
+        return self.get_config().invite_friend_name
+
+    def invite_success_callback(self, ctype: CooperationType, name):
+        """
+           邀请成功回调
+        @param ctype:
+        @type ctype:
+        @param name:
+        @type name:
+        """
+
+        return True
+
 
 if __name__ == '__main__':
     from module.config.config import Config
@@ -466,8 +601,14 @@ if __name__ == '__main__':
     c = Config('oas1')
     d = Device(c)
     t = ScriptTask(c, d)
-    t.screenshot()
-
-    t.run()
+    img = cv2.imread(r"E:\highlight.png")
+    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
+    t.device.image = img
+    appear = t.appear_highlight(t.I_WQ_INVITE_DIFF_SVR_HIGHLIGHT)
 
+    img = cv2.imread(r"E:\normal.png")
+    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
+    t.device.image = img
+    appear_normal = t.appear_highlight(t.I_WQ_INVITE_DIFF_SVR_HIGHLIGHT)
 
+    print(appear)

+ 38 - 2
tasks/WantedQuests/wq/image.json

@@ -27,8 +27,8 @@
     "description": "一键追踪"
   },
   {
-    "itemName": "tarce_disenable",
-    "imageName": "wq_tarce_disenable.png",
+    "itemName": "trace_disable",
+    "imageName": "wq_trace_disable.png",
     "roiFront": "1091,586,108,70",
     "roiBack": "1091,586,108,70",
     "method": "Template matching",
@@ -106,5 +106,41 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "判断是否还有任务"
+  },
+  {
+    "itemName": "wq_trace_one_enable",
+    "imageName": "wq_trace_one_enable.png",
+    "roiFront": "160,175,120,60",
+    "roiBack": "160,175,120,60",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "庭院悬赏任务界面 单个任务点开后 左上角是否追踪"
+  },
+  {
+    "itemName": "wq_trace_one_disable",
+    "imageName": "wq_trace_one_disable.png",
+    "roiFront": "160,175,120,60",
+    "roiBack": "160,175,120,60",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "庭院悬赏任务界面 单个任务点开后 左上角是否追踪"
+  },
+  {
+    "itemName": "wq_trace_one_check_opened",
+    "imageName": "wq_trace_one_check_opened.png",
+    "roiFront": "510,175,210,60",
+    "roiBack": "510,175,210,60",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "庭院悬赏任务界面 单个任务点开后的界面 是否打开的 标志"
+  },
+  {
+    "itemName": "wq_trace_one_realworld",
+    "imageName": "wq_trace_one_realworld.png",
+    "roiFront": "850,470,180,180",
+    "roiBack": "850,470,180,180",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "庭院悬赏任务界面 单个任务点开后的界面 是否为现世任务标志"
   }
 ]

BIN
tasks/WantedQuests/wq/wq_trace_disable.png


BIN
tasks/WantedQuests/wq/wq_trace_one_check_opened.png


BIN
tasks/WantedQuests/wq/wq_trace_one_disable.png


BIN
tasks/WantedQuests/wq/wq_trace_one_enable.png


BIN
tasks/WantedQuests/wq/wq_trace_one_realworld.png


+ 1 - 1
tasks/WeeklyTrifles/assets.py

@@ -74,7 +74,7 @@ class WeeklyTriflesAssets:
 	# 微信 
 	I_WT_SE_WECHAT = RuleImage(roi_front=(1023,630,56,57), roi_back=(1023,630,56,57), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/secret/secret_wt_se_wechat.png")
 	# 勾玉 
-	I_WT_SE_JADE = RuleImage(roi_front=(1129,529,35,39), roi_back=(1129,529,35,39), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/secret/secret_wt_se_jade.png")
+	I_WT_SE_JADE = RuleImage(roi_front=(1123,532,35,39), roi_back=(1105,520,79,73), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/secret/secret_wt_se_jade.png")
 	# 排行 
 	I_WT_SE_RANK = RuleImage(roi_front=(1017,572,45,44), roi_back=(989,556,103,81), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/secret/secret_wt_se_rank.png")
 

+ 7 - 6
tasks/WeeklyTrifles/script_task.py

@@ -171,22 +171,23 @@ class ScriptTask(GameUi, WeeklyTriflesAssets):
         self.ui_get_current_page()
         self.ui_goto(page_secret_zones)
         # 一路进去
+        valid = False
         while 1:
             self.screenshot()
             if self.appear(self.I_WT_SE_WECHAT):
+                self.wait_until_stable(self.I_WT_SE_WECHAT, skip_first_screenshot=True)
                 break
             if self.appear_then_click(self.I_WT_ENTER_SE, interval=1):
                 continue
-            if self.appear_then_click(self.I_WT_SE_SHARE, interval=1):
+            if self.appear_then_click(self.I_WT_SE_SHARE, interval=5):
+                valid = True
                 continue
-            if self.appear(self.I_WT_SE_RANK):
+            if self.appear(self.I_WT_SE_RANK) and (not valid):
                 # 如果出现排名但是没有出现分享,那就是还没打,退出
-                time.sleep(0.5)
-                self.screenshot()
+                self.wait_until_stable(self.I_WT_SE_SHARE, skip_first_screenshot=True)
                 if self.appear(self.I_WT_SE_SHARE):
                     continue
                 logger.warning('This week has not been obtained')
-                # 返回
                 self.ui_click(self.I_UI_BACK_BLUE, self.I_CHECK_MAIN)
                 return
         logger.info('Enter secret')
@@ -273,7 +274,7 @@ if __name__ == '__main__':
     t = ScriptTask(c, d)
     t.screenshot()
 
-    t.run()
+    t._share_secret()
     # t._share_collect()
     # t.click_share(t.I_WT_SE_WECHAT)
 

+ 2 - 2
tasks/WeeklyTrifles/secret/image.json

@@ -29,8 +29,8 @@
   {
     "itemName": "wt_se_jade",
     "imageName": "secret_wt_se_jade.png",
-    "roiFront": "1129,529,35,39",
-    "roiBack": "1129,529,35,39",
+    "roiFront": "1123,532,35,39",
+    "roiBack": "1105,520,79,73",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "勾玉"

+ 23 - 4
tasks/base_task.py

@@ -519,8 +519,11 @@ class BaseTask(GlobalGameAssets, CostumeBase):
         :param time_delta: 下次运行日期为几天后,默认为第二天
         :return:
         """
-        target_time = (datetime.now() + timedelta(days=time_delta)).replace(hour=custom_time.hour, minute=custom_time.minute, second=custom_time.second)
+        target_time = (datetime.now() + timedelta(days=time_delta)).replace(hour=custom_time.hour,
+                                                                            minute=custom_time.minute,
+                                                                            second=custom_time.second)
         self.set_next_run(task, target=target_time)
+
     #  ---------------------------------------------------------------------------------------------------------------
     #
     #  ---------------------------------------------------------------------------------------------------------------
@@ -533,7 +536,7 @@ class BaseTask(GlobalGameAssets, CostumeBase):
             self.screenshot()
         return self.appear_then_click(self.I_UI_REWARD, action=self.C_UI_REWARD, interval=0.4, threshold=0.6)
 
-    def ui_get_reward(self, click_image: RuleImage or RuleOcr or RuleClick, click_interval: float=1):
+    def ui_get_reward(self, click_image: RuleImage or RuleOcr or RuleClick, click_interval: float = 1):
         """
         传进来一个点击图片 或是 一个ocr, 会点击这个图片,然后等待‘获得奖励’,
         最后当获得奖励消失后 退出
@@ -573,7 +576,6 @@ class BaseTask(GlobalGameAssets, CostumeBase):
                 if self.click(click_image, interval=click_interval):
                     continue
 
-
         return True
 
     def ui_click(self, click, stop, interval=1):
@@ -595,7 +597,7 @@ class BaseTask(GlobalGameAssets, CostumeBase):
             elif isinstance(click, RuleOcr) and self.ocr_appear_click(click, interval=interval):
                 continue
 
-    def ui_click_until_disappear(self, click, interval: float =1):
+    def ui_click_until_disappear(self, click, interval: float = 1):
         """
         点击一个按钮直到消失
         :param interval:
@@ -609,4 +611,21 @@ class BaseTask(GlobalGameAssets, CostumeBase):
             elif self.appear_then_click(click, interval=interval):
                 continue
 
+    def ui_click_until_smt_disappear(self, click, stop, interval: float = 1):
+        """
+        点击一个按钮/区域/文字直到stop消失
 
+        """
+        while 1:
+            self.screenshot()
+            if not self.appear(stop):
+                break
+            if isinstance(click, RuleImage) or isinstance(click, RuleGif):
+                self.appear_then_click(click, interval=interval)
+                continue
+            if isinstance(click, RuleClick):
+                self.click(click, interval)
+                continue
+            if isinstance(click, RuleOcr):
+                self.click(click)
+                continue