Procházet zdrojové kódy

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

liujx54704 před 1 rokem
rodič
revize
033b9a3051

+ 1 - 0
.gitignore

@@ -26,6 +26,7 @@ test/
 !module/gui/FluentUI/fluentuiplugin.dll
 !module/gui/FluentUI/fluentuiplugin.dll
 build-fluentui-Desktop_*/
 build-fluentui-Desktop_*/
 module/config/argument/setting.json
 module/config/argument/setting.json
+module/config/i18n/*.json
 !fluentui/*
 !fluentui/*
 *.exe
 *.exe
 !dev_tools/*
 !dev_tools/*

+ 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\1734235242044\2024-12-15_12-00-42-005384.png"
+IMAGE_FILE = r"C:\Users\Ryland\Desktop\Weixin Screenshot_20241225220524.png"
 if __name__ == '__main__':
 if __name__ == '__main__':
-    from tasks.Exploration.assets import ExplorationAssets
-    targe = ExplorationAssets.I_BATTLE_REWARD
+    from tasks.KekkaiActivation.assets import KekkaiActivationAssets
+    targe = KekkaiActivationAssets.I_CARDS_KAIKO_3
     print(detect_image(IMAGE_FILE, targe))
     print(detect_image(IMAGE_FILE, targe))
 
 
     # ocr demo
     # ocr demo

+ 14 - 1
module/server/home_router.py

@@ -1,11 +1,15 @@
 # This Python file uses the following encoding: utf-8
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
-from fastapi import APIRouter
+import json
+from fastapi import APIRouter, Body
+from pathlib import Path
 
 
+from module.config.utils import write_file
 from module.logger import logger
 from module.logger import logger
 from module.server.main_manager import MainManager
 from module.server.main_manager import MainManager
 from module.server.updater import Updater
 from module.server.updater import Updater
+from module.server.i18n import I18n
 
 
 home_app = APIRouter(
 home_app = APIRouter(
     prefix="/home",
     prefix="/home",
@@ -61,6 +65,7 @@ async def update_info():
         logger.error(e)
         logger.error(e)
         return None
         return None
 
 
+
 @home_app.get('/execute_update')
 @home_app.get('/execute_update')
 async def execute_update():
 async def execute_update():
     # 下拉仓库 -> 关闭所有脚本进程 -> 最后重启oasx
     # 下拉仓库 -> 关闭所有脚本进程 -> 最后重启oasx
@@ -71,3 +76,11 @@ async def execute_update():
         logger.error(e)
         logger.error(e)
     return '手动更新将会立即结束运行中的脚本服务, 最后你还需重启oasx'
     return '手动更新将会立即结束运行中的脚本服务, 最后你还需重启oasx'
 
 
+
+@home_app.put('/chinese_translate')
+async def chinese_translate(data: dict = Body(...)):
+    try:
+        I18n.save_zh_cn(data)
+    except Exception as e:
+        logger.error(e)
+    return True

+ 28 - 0
module/server/i18n.py

@@ -0,0 +1,28 @@
+import json
+from pathlib import Path
+
+
+class I18n:
+    file_zh_cn = Path.cwd() / 'module' / 'config' / 'i18n' / 'zh-CN.json'
+
+    @classmethod
+    def trans_zh_cn(cls, text) -> str:
+        cn_zh_data = cls.load_zh_cn()
+        return cn_zh_data[text] if text in cn_zh_data else text
+
+    @classmethod
+    def save_zh_cn(cls, data) -> None:
+        I18n.file_zh_cn.parent.mkdir(parents=True, exist_ok=True)
+        with open(str(I18n.file_zh_cn), 'w', encoding='utf-8') as f:
+            s = json.dumps(data, indent=2, ensure_ascii=False, sort_keys=False, default=str)
+            f.write(s)
+
+    @classmethod
+    def load_zh_cn(cls) -> dict:
+        if not I18n.file_zh_cn.exists():
+            return {}
+        with open(str(I18n.file_zh_cn), 'r', encoding='utf-8') as f:
+            return json.load(f)
+
+if __name__ == '__main__':
+    print(I18n.load_zh_cn())

+ 6 - 6
script.py

@@ -31,6 +31,7 @@ from module.base.utils import load_module
 from module.base.decorator import del_cached_property
 from module.base.decorator import del_cached_property
 from module.logger import logger
 from module.logger import logger
 from module.exception import *
 from module.exception import *
+from module.server.i18n import I18n
 
 
 class Script:
 class Script:
     def __init__(self, config_name: str ='oas') -> None:
     def __init__(self, config_name: str ='oas') -> None:
@@ -361,7 +362,7 @@ class Script:
             self.save_error_log()
             self.save_error_log()
             logger.warning(f'Game stuck, {self.device.package} will be restarted in 10 seconds')
             logger.warning(f'Game stuck, {self.device.package} will be restarted in 10 seconds')
             logger.warning('If you are playing by hand, please stop Alas')
             logger.warning('If you are playing by hand, please stop Alas')
-            self.config.notifier.push(title=command, content=f"<{self.config_name}> GameStuckError or GameTooManyClickError")
+            self.config.notifier.push(title=f'{I18n.trans_zh_cn(command)}{command}', content=f"<{self.config_name}> GameStuckError or GameTooManyClickError")
             self.config.task_call('Restart')
             self.config.task_call('Restart')
             self.device.sleep(10)
             self.device.sleep(10)
             return False
             return False
@@ -378,23 +379,22 @@ class Script:
             # 这个还不重要 留着坑填
             # 这个还不重要 留着坑填
             logger.critical('Game page unknown')
             logger.critical('Game page unknown')
             self.save_error_log()
             self.save_error_log()
-            self.config.notifier.push(title=command, content=f"<{self.config_name}> GamePageUnknownError")
-            exit(1)
+            self.config.notifier.push(title=f'{I18n.trans_zh_cn(command)}{command}', content=f"<{self.config_name}> GamePageUnknownError")
             return False
             return False
         except ScriptError as e:
         except ScriptError as e:
             logger.critical(e)
             logger.critical(e)
             logger.critical('This is likely to be a mistake of developers, but sometimes just random issues')
             logger.critical('This is likely to be a mistake of developers, but sometimes just random issues')
-            self.config.notifier.push(title=command, content=f"<{self.config_name}> ScriptError")
+            self.config.notifier.push(title=f'{I18n.trans_zh_cn(command)}{command}', content=f"<{self.config_name}> ScriptError")
             exit(1)
             exit(1)
         except RequestHumanTakeover as e:
         except RequestHumanTakeover as e:
             logger.critical(e)
             logger.critical(e)
             logger.critical('Request human takeover')
             logger.critical('Request human takeover')
-            self.config.notifier.push(title=command, content=f"<{self.config_name}> RequestHumanTakeover")
+            self.config.notifier.push(title=f'{I18n.trans_zh_cn(command)}{command}', content=f"<{self.config_name}> RequestHumanTakeover")
             exit(1)
             exit(1)
         except Exception as e:
         except Exception as e:
             logger.exception(e)
             logger.exception(e)
             self.save_error_log()
             self.save_error_log()
-            self.config.notifier.push(title=command, content=f"<{self.config_name}> Exception occured")
+            self.config.notifier.push(title=f'{I18n.trans_zh_cn(command)}{command}', content=f"<{self.config_name}> Exception occured")
             exit(1)
             exit(1)
 
 
     def loop(self):
     def loop(self):

+ 4 - 4
tasks/Component/SwitchAccount/login_account.py

@@ -167,7 +167,7 @@ class LoginAccount(BaseTask, SwitchAccountAssets):
                 self.screenshot()
                 self.screenshot()
                 if self.appear(self.I_SA_ACCOUNT_DROP_DOWN_CLOSED):
                 if self.appear(self.I_SA_ACCOUNT_DROP_DOWN_CLOSED):
                     if self.ocr_appear(self.O_SA_ACCOUNT_ACCOUNT_SELECTED):
                     if self.ocr_appear(self.O_SA_ACCOUNT_ACCOUNT_SELECTED):
-                        break
+                        return True
                     self.ui_click_until_disappear(self.I_SA_ACCOUNT_DROP_DOWN_CLOSED,
                     self.ui_click_until_disappear(self.I_SA_ACCOUNT_DROP_DOWN_CLOSED,
                                                   interval=1.5)
                                                   interval=1.5)
                     continue
                     continue
@@ -253,7 +253,7 @@ class LoginAccount(BaseTask, SwitchAccountAssets):
 
 
             # 处于选择 苹果安卓界面
             # 处于选择 苹果安卓界面
             if self.appear(self.I_SA_LOGIN_FORM_APPLE):
             if self.appear(self.I_SA_LOGIN_FORM_APPLE):
-                btn = self.I_SA_LOGIN_FORM_ANDROID if accountInfo.appleOrAndroid else self.I_SA_LOGIN_FORM_APPLE
+                btn = self.I_SA_LOGIN_FORM_ANDROID if accountInfo.apple_or_android else self.I_SA_LOGIN_FORM_APPLE
                 self.ui_click_until_disappear(btn)
                 self.ui_click_until_disappear(btn)
                 isAccountLogon = True
                 isAccountLogon = True
                 continue
                 continue
@@ -313,12 +313,12 @@ class LoginAccount(BaseTask, SwitchAccountAssets):
             # self.ui_click_until_disappear(self.C_SA_LOGIN_FORM_ENTER_GAME_BTN, stop=self.I_CHECK_LOGIN_FORM)
             # self.ui_click_until_disappear(self.C_SA_LOGIN_FORM_ENTER_GAME_BTN, stop=self.I_CHECK_LOGIN_FORM)
             logger.info("character %s-%s account:%s %s login Success", accountInfo.character, accountInfo.svr,
             logger.info("character %s-%s account:%s %s login Success", accountInfo.character, accountInfo.svr,
                         accountInfo.account,
                         accountInfo.account,
-                        'Android' if accountInfo.appleOrAndroid else 'Apple')
+                        'Android' if accountInfo.apple_or_android else 'Apple')
             return True
             return True
 
 
         logger.error("character %s-%s account:%s %s login Failed", accountInfo.character, accountInfo.svr,
         logger.error("character %s-%s account:%s %s login Failed", accountInfo.character, accountInfo.svr,
                      accountInfo.account,
                      accountInfo.account,
-                     'Android' if accountInfo.appleOrAndroid else 'Apple')
+                     'Android' if accountInfo.apple_or_android else 'Apple')
         return False
         return False
 
 
     def ui_click_until_disappear(self, click, interval: float = 1, stop: RuleImage | RuleGif = None):
     def ui_click_until_disappear(self, click, interval: float = 1, stop: RuleImage | RuleGif = None):

+ 7 - 7
tasks/Component/SwitchAccount/switch_account.py

@@ -29,11 +29,11 @@ class SwitchAccount(LoginAccount, ExitGame, GameUi, SwitchAccountAssets):
         @type frm:
         @type frm:
         """
         """
         super().__init__(config, device)
         super().__init__(config, device)
-        self.toAccountInfo = to
-        self.fromAccountInfo = frm
+        self.to_account_info = to
+        self.from_account_info = frm
 
 
     def switchAccount(self):
     def switchAccount(self):
-        logger.info("start switchAccount %s-%s", self.toAccountInfo.character, self.toAccountInfo.svr)
+        logger.info("start switchAccount %s-%s", self.to_account_info.character, self.to_account_info.svr)
         # 判断所处界面
         # 判断所处界面
         curPage = self.ui_get_current_page()
         curPage = self.ui_get_current_page()
 
 
@@ -44,12 +44,12 @@ class SwitchAccount(LoginAccount, ExitGame, GameUi, SwitchAccountAssets):
             self.exitGame()
             self.exitGame()
 
 
         # 处于登录界面
         # 处于登录界面
-        if not self.login(self.toAccountInfo):
+        if not self.login(self.to_account_info):
             return False
             return False
-        logger.info("%s login suc", self.toAccountInfo.character)
+        logger.info("%s login suc", self.to_account_info.character)
         # 处理位于登录界面各种奇葩弹窗
         # 处理位于登录界面各种奇葩弹窗
         login_handler = LoginHandler(config=self.config, device=self.device)
         login_handler = LoginHandler(config=self.config, device=self.device)
-        login_handler.set_specific_usr(self.toAccountInfo.svr)
+        login_handler.set_specific_usr(self.to_account_info.svr)
         login_handler.app_handle_login()
         login_handler.app_handle_login()
 
 
         return True
         return True
@@ -58,6 +58,6 @@ class SwitchAccount(LoginAccount, ExitGame, GameUi, SwitchAccountAssets):
 if __name__ == '__main__':
 if __name__ == '__main__':
     config = Config('oas1')
     config = Config('oas1')
     device=Device()
     device=Device()
-    toAccount=AccountInfo(account="email0@163.com",accountAlias="emailO#emailo",appleOrAndroid=True,character="粘贴",svr="立秋夕烛")
+    toAccount=AccountInfo(account="email0@163.com", account_alias="emailO#emailo", apple_or_android=True, character="粘贴", svr="立秋夕烛")
     sa=SwitchAccount(config,device,toAccount)
     sa=SwitchAccount(config,device,toAccount)
     sa.switchAccount()
     sa.switchAccount()

+ 4 - 4
tasks/Component/SwitchAccount/switch_account_config.py

@@ -16,8 +16,8 @@ class AccountInfo(BaseModel):
     svr: str = Field(default="", description="svr_help")
     svr: str = Field(default="", description="svr_help")
     account: str = Field(default="", description="account_help")
     account: str = Field(default="", description="account_help")
     # 为防止ocr出错 暂定格式 字符串以#分割
     # 为防止ocr出错 暂定格式 字符串以#分割
-    accountAlias: str = Field(default="", description="account_alias_help")
-    appleOrAndroid: bool = Field(default=True, description="apple_or_android_help")
+    account_alias: str = Field(default="", description="account_alias_help")
+    apple_or_android: bool = Field(default=True, description="apple_or_android_help")
     # 上一次执行成功的时间 ,防止出错时重复登录浪费时间
     # 上一次执行成功的时间 ,防止出错时重复登录浪费时间
     last_complete_time: DateTime = Field(default=DateTime.fromisoformat("2023-01-01 00:00:00"), description="last_complete_time_help")
     last_complete_time: DateTime = Field(default=DateTime.fromisoformat("2023-01-01 00:00:00"), description="last_complete_time_help")
 
 
@@ -25,9 +25,9 @@ class AccountInfo(BaseModel):
         tmp_account = AccountInfo.preprocessAccount(self.account)
         tmp_account = AccountInfo.preprocessAccount(self.account)
         if ocr_account == self.account or ocr_account.startswith(tmp_account):
         if ocr_account == self.account or ocr_account.startswith(tmp_account):
             return True
             return True
-        if not self.accountAlias:
+        if not self.account_alias:
             return False
             return False
-        _accountAliasList = self.accountAlias.split('#')
+        _accountAliasList = self.account_alias.split('#')
         for alias in _accountAliasList:
         for alias in _accountAliasList:
             if ocr_account.startswith(alias):
             if ocr_account.startswith(alias):
                 return True
                 return True

+ 9 - 0
tasks/DailyTrifles/assets.py

@@ -36,5 +36,14 @@ class DailyTriflesAssets:
 	I_GIFT_RECOMMEND = RuleImage(roi_front=(1186,98,53,64), roi_back=(1172,83,83,306), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_recommend.png")
 	I_GIFT_RECOMMEND = RuleImage(roi_front=(1186,98,53,64), roi_back=(1172,83,83,306), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_recommend.png")
 	# 免费一抽 
 	# 免费一抽 
 	I_GIFT_SIGN = RuleImage(roi_front=(236,129,306,218), roi_back=(236,129,306,218), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_sign.png")
 	I_GIFT_SIGN = RuleImage(roi_front=(236,129,306,218), roi_back=(236,129,306,218), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_sign.png")
+	# 体力 
+	I_SPECIAL_SUSHI = RuleImage(roi_front=(180,130,800,200), roi_back=(180,130,800,200), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_sushi.png")
+	# 购买时货币类型为勾玉 
+	I_STORE_COST_TYPE_JADE = RuleImage(roi_front=(600,490,50,60), roi_back=(600,490,50,60), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_cost_type_jade.png")
+
+
+	# Ocr Rule Assets
+	# 商店Special购买体力所需勾玉数量,roiBack为动态调整,故此设置为0,0,0,0 
+	O_STORE_SUSHI_PRICE = RuleOcr(roi=(0,0,0,0), area=(0,0,0,0), mode="Digit", method="Default", keyword="", name="store_sushi_price")
 
 
 
 

+ 2 - 1
tasks/DailyTrifles/config.py

@@ -14,9 +14,10 @@ class DailyTriflesConfig(BaseModel):
     friend_love: bool = Field(title='Friend Love', default=False)
     friend_love: bool = Field(title='Friend Love', default=False)
     luck_msg: bool = Field(title='Luck Msg', default=False)
     luck_msg: bool = Field(title='Luck Msg', default=False)
     store_sign: bool = Field(title='Store Sign', default=False, description='store_sign_help')
     store_sign: bool = Field(title='Store Sign', default=False, description='store_sign_help')
+    # 每天购买体力数量
+    buy_sushi_count: int = Field(title='Buy Sushi Count', default=-1)
 
 
 
 
 class DailyTrifles(ConfigBase):
 class DailyTrifles(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     scheduler: Scheduler = Field(default_factory=Scheduler)
     trifles_config: DailyTriflesConfig = Field(default_factory=DailyTriflesConfig)
     trifles_config: DailyTriflesConfig = Field(default_factory=DailyTriflesConfig)
-

+ 77 - 13
tasks/DailyTrifles/script_task.py

@@ -1,22 +1,24 @@
 # This Python file uses the following encoding: utf-8
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
+import copy
 from time import sleep
 from time import sleep
 from datetime import time, datetime, timedelta
 from datetime import time, datetime, timedelta
 
 
+from exceptiongroup import catch
+from winerror import NOERROR
+
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.page import page_main, page_summon, page_guild, page_mall, page_friends
 from tasks.GameUi.page import page_main, page_summon, page_guild, page_mall, page_friends
 from tasks.DailyTrifles.config import DailyTriflesConfig
 from tasks.DailyTrifles.config import DailyTriflesConfig
 from tasks.DailyTrifles.assets import DailyTriflesAssets
 from tasks.DailyTrifles.assets import DailyTriflesAssets
 from tasks.Component.Summon.summon import Summon
 from tasks.Component.Summon.summon import Summon
 
 
-
 from module.logger import logger
 from module.logger import logger
 from module.exception import TaskEnd
 from module.exception import TaskEnd
 from module.base.timer import Timer
 from module.base.timer import Timer
 
 
 
 
-
 class ScriptTask(GameUi, Summon, DailyTriflesAssets):
 class ScriptTask(GameUi, Summon, DailyTriflesAssets):
 
 
     def run(self):
     def run(self):
@@ -29,8 +31,8 @@ class ScriptTask(GameUi, Summon, DailyTriflesAssets):
             self.run_friend_love()
             self.run_friend_love()
         if con.luck_msg:
         if con.luck_msg:
             self.run_luck_msg()
             self.run_luck_msg()
-        if con.store_sign:
-            self.run_store_sign()
+        if con.store_sign or con.buy_sushi_count > 0:
+            self.run_store()
         self.set_next_run('DailyTrifles', success=True, finish=False)
         self.set_next_run('DailyTrifles', success=True, finish=False)
         raise TaskEnd('DailyTrifles')
         raise TaskEnd('DailyTrifles')
 
 
@@ -101,10 +103,21 @@ class ScriptTask(GameUi, Summon, DailyTriflesAssets):
 
 
         self.ui_click(self.I_UI_BACK_RED, self.I_CHECK_MAIN)
         self.ui_click(self.I_UI_BACK_RED, self.I_CHECK_MAIN)
 
 
-    def run_store_sign(self):
+    def run_store(self):
         self.ui_get_current_page()
         self.ui_get_current_page()
         self.ui_goto(page_mall, confirm_wait=3)
         self.ui_goto(page_mall, confirm_wait=3)
 
 
+        if self.config.daily_trifles.trifles_config.store_sign:
+            self.run_store_sign()
+        if self.config.daily_trifles.trifles_config.buy_sushi_count > 0:
+            self.run_buy_sushi()
+
+        self.ui_click(self.I_UI_BACK_YELLOW, self.I_CHECK_MALL)
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+
+    def run_store_sign(self):
+
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             if self.appear(self.I_GIFT_RECOMMEND):
             if self.appear(self.I_GIFT_RECOMMEND):
@@ -118,17 +131,69 @@ class ScriptTask(GameUi, Summon, DailyTriflesAssets):
         self.screenshot()
         self.screenshot()
         if not self.appear(self.I_GIFT_SIGN):
         if not self.appear(self.I_GIFT_SIGN):
             logger.warning('There is no gift sign')
             logger.warning('There is no gift sign')
-            self.ui_click(self.I_UI_BACK_YELLOW, self.I_CHECK_MALL)
-            self.ui_get_current_page()
-            self.ui_goto(page_main)
             return
             return
 
 
         if self.ui_get_reward(self.I_GIFT_SIGN, click_interval=2.5):
         if self.ui_get_reward(self.I_GIFT_SIGN, click_interval=2.5):
             logger.info('Get reward of gift sign')
             logger.info('Get reward of gift sign')
 
 
-        self.ui_click(self.I_UI_BACK_YELLOW, self.I_CHECK_MALL)
-        self.ui_get_current_page()
-        self.ui_goto(page_main)
+    def run_buy_sushi(self):
+
+        # 进入Special
+        while 1:
+            from tasks.RichMan.assets import RichManAssets
+            self.screenshot()
+            if self.appear(RichManAssets.I_SIDE_CHECK_SPECIAL):
+                break
+            if self.appear_then_click(RichManAssets.I_MALL_SUNDRY, interval=1):
+                continue
+            if self.appear_then_click(RichManAssets.I_SIDE_SURE_SPECIAL, interval=1):
+                continue
+
+        def detect_buy_count(base_element) -> (int, int):
+            # 返回count,price
+            MAX_PRICE = 9999
+            MAX_COUNT = 9999
+            roi = copy.deepcopy(base_element.roi_front)
+            roi[0] = roi[0] + roi[2]
+            roi[1] = roi[1] + roi[3] - 30
+            roi[2] = 60
+            roi[3] = 30
+            self.O_STORE_SUSHI_PRICE.roi = roi
+            _price = self.O_STORE_SUSHI_PRICE.detect_text(self.device.image)
+            # 保守策略,避免OCR错误购买
+            try:
+                _price = int(_price)
+            except Exception as e:
+                _price = MAX_PRICE
+
+            if _price < 60:
+                return 0, MAX_PRICE
+            _count = (_price - 60) / 20
+            return _count, _price
+
+        roi = None
+        # 购买体力
+        while 1:
+            self.screenshot()
+            # count, price = detect_buy_count(roi)
+            # if count >= self.config.model.daily_trifles.trifles_config.buy_sushi_count:
+            #     break
+            if self.appear(self.I_STORE_COST_TYPE_JADE):
+                count, price = detect_buy_count(self.I_STORE_COST_TYPE_JADE)
+                if count >= self.config.daily_trifles.trifles_config.buy_sushi_count:
+                    break
+                self.ui_click_until_disappear(self.I_STORE_COST_TYPE_JADE, interval=2)
+                logger.info(f"Buy Sushi With {price} Jade")
+                continue
+
+            if self.appear(self.I_SPECIAL_SUSHI):
+                # 此处确定当前购买体力所需勾玉数量的位置,用于后续识别
+                count, price = detect_buy_count(self.I_SPECIAL_SUSHI)
+                if count >= self.config.daily_trifles.trifles_config.buy_sushi_count:
+                    break
+                self.ui_click(self.I_SPECIAL_SUSHI, stop=self.I_STORE_COST_TYPE_JADE, interval=2)
+                continue
+        return
 
 
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
@@ -139,5 +204,4 @@ if __name__ == '__main__':
     d = Device(c)
     d = Device(c)
     t = ScriptTask(c, d)
     t = ScriptTask(c, d)
 
 
-    t.run_store_sign()
-
+    t.run_store()

+ 18 - 0
tasks/DailyTrifles/store/image.json

@@ -25,5 +25,23 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "免费一抽"
     "description": "免费一抽"
+  },
+  {
+    "itemName": "special_sushi",
+    "imageName": "store_sushi.png",
+    "roiFront": "180,130,800,200",
+    "roiBack": "180,130,800,200",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "体力"
+  },
+  {
+    "itemName": "store_cost_type_jade",
+    "imageName": "store_cost_type_jade.png",
+    "roiFront": "600,490,50,60",
+    "roiBack": "600,490,50,60",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "购买时货币类型为勾玉"
   }
   }
 ]
 ]

+ 11 - 0
tasks/DailyTrifles/store/ocr.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "store_sushi_price",
+    "roiFront": "0,0,0,0",
+    "roiBack": "0,0,0,0",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "商店Special购买体力所需勾玉数量,roiBack为动态调整,故此设置为0,0,0,0"
+  }
+]

binární
tasks/DailyTrifles/store/store_cost_type_jade.png


binární
tasks/DailyTrifles/store/store_sushi.png


+ 2 - 2
tasks/KekkaiActivation/assets.py

@@ -89,9 +89,9 @@ class KekkaiActivationAssets:
 	# description 
 	# description 
 	I_CARDS_KAIKO_5 = RuleImage(roi_front=(191,345,88,58), roi_back=(172,162,126,488), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_kaiko_5.png")
 	I_CARDS_KAIKO_5 = RuleImage(roi_front=(191,345,88,58), roi_back=(172,162,126,488), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_kaiko_5.png")
 	# description 
 	# description 
-	I_CARDS_KAIKO_4 = RuleImage(roi_front=(192,354,90,22), roi_back=(179,165,116,482), threshold=0.85, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_kaiko_4.png")
+	I_CARDS_KAIKO_4 = RuleImage(roi_front=(190,255,90,22), roi_back=(179,165,116,482), threshold=0.85, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_kaiko_4.png")
 	# description 
 	# description 
-	I_CARDS_KAIKO_3 = RuleImage(roi_front=(192,187,89,66), roi_back=(183,169,109,474), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_kaiko_3.png")
+	I_CARDS_KAIKO_3 = RuleImage(roi_front=(191,351,89,66), roi_back=(183,169,109,474), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_kaiko_3.png")
 	# description 
 	# description 
 	I_CARDS_FISH_6 = RuleImage(roi_front=(193,183,87,91), roi_back=(178,169,110,474), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_fish_6.png")
 	I_CARDS_FISH_6 = RuleImage(roi_front=(193,183,87,91), roi_back=(178,169,110,474), threshold=0.8, method="Template matching", file="./tasks/KekkaiActivation/cards/cards_cards_fish_6.png")
 	# description 
 	# description 

binární
tasks/KekkaiActivation/cards/cards_cards_kaiko_3.png


binární
tasks/KekkaiActivation/cards/cards_cards_kaiko_4.png


+ 2 - 2
tasks/KekkaiActivation/cards/image.json

@@ -20,7 +20,7 @@
   {
   {
     "itemName": "cards_kaiko_4",
     "itemName": "cards_kaiko_4",
     "imageName": "cards_cards_kaiko_4.png",
     "imageName": "cards_cards_kaiko_4.png",
-    "roiFront": "192,354,90,22",
+    "roiFront": "190,255,90,22",
     "roiBack": "179,165,116,482",
     "roiBack": "179,165,116,482",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.85,
     "threshold": 0.85,
@@ -29,7 +29,7 @@
   {
   {
     "itemName": "cards_kaiko_3",
     "itemName": "cards_kaiko_3",
     "imageName": "cards_cards_kaiko_3.png",
     "imageName": "cards_cards_kaiko_3.png",
-    "roiFront": "192,187,89,66",
+    "roiFront": "191,351,89,66",
     "roiBack": "183,169,109,474",
     "roiBack": "183,169,109,474",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,

+ 14 - 1
tasks/Restart/script_task.py

@@ -6,7 +6,8 @@ from datetime import datetime
 from tasks.Restart.config_scheduler import Scheduler
 from tasks.Restart.config_scheduler import Scheduler
 from tasks.Restart.login import LoginHandler
 from tasks.Restart.login import LoginHandler
 from tasks.Restart.assets import RestartAssets
 from tasks.Restart.assets import RestartAssets
-from tasks.base_task import BaseTask
+from tasks.base_task import BaseTask, Time
+from datetime import datetime, time
 
 
 from module.logger import logger
 from module.logger import logger
 from module.exception import TaskEnd, RequestHumanTakeover
 from module.exception import TaskEnd, RequestHumanTakeover
@@ -41,6 +42,18 @@ class ScriptTask(LoginHandler):
 
 
         # self.config.task_delay(server_update=True)
         # self.config.task_delay(server_update=True)
         self.set_next_run(task='Restart', success=True, finish=True, server=True)
         self.set_next_run(task='Restart', success=True, finish=True, server=True)
+        # 如果启用了定时领体力(每天 12-14、20-22 时内各有 20 体力)
+        if self.config.restart.harvest_config.enable_ap:
+            now = datetime.now()
+            # 如果时间在00:00-12:00之间则设定时间为当日 12 时
+            if now.time() < time(12, 0):
+                self.custom_next_run(task='Restart', custom_time=Time(12, 0), time_delta=0)
+            # 如果时间在12:00-20:00之间则设定时间为当日 20 时
+            elif now.time() >= time(12, 0) and now.time() < time(20, 0):
+                self.custom_next_run(task='Restart', custom_time=Time(20, 0), time_delta=0)
+            # 如果时间在20:00-23:59之间则设定时间为次日 12 时
+            else:
+                self.custom_next_run(task='Restart', custom_time=Time(12, 0), time_delta=1)
 
 
     def delay_pending_tasks(self) -> bool:
     def delay_pending_tasks(self) -> bool:
         """
         """