From 457b1bc4f27a5256298437bdac420ea6b9957e1d Mon Sep 17 00:00:00 2001 From: "firedcto@gmail.com" Date: Fri, 26 Jul 2024 12:31:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=9F=A5=E5=B0=8F=E6=9C=88=E5=8D=A1,?= =?UTF-8?q?=20=E9=9C=80=E8=A6=81=E6=89=8B=E5=8A=A8=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/en_US/LC_MESSAGES/ok.po | 15 +++++++ i18n/zh_CN/LC_MESSAGES/ok.mo | Bin 2681 -> 3075 bytes i18n/zh_CN/LC_MESSAGES/ok.po | 21 ++++++++-- src/char/BaseChar.py | 2 +- src/combat/CombatCheck.py | 10 ----- src/task/BaseCombatTask.py | 9 +--- src/task/BaseWWTask.py | 75 ++++++++++++++++++++++++++++++++++ src/task/FarmEchoTask.py | 1 + src/task/FarmWorldBossTask.py | 1 + src/task/SkipDialogTask.py | 3 +- 10 files changed, 114 insertions(+), 23 deletions(-) diff --git a/i18n/en_US/LC_MESSAGES/ok.po b/i18n/en_US/LC_MESSAGES/ok.po index 2f34022..3a21e8e 100644 --- a/i18n/en_US/LC_MESSAGES/ok.po +++ b/i18n/en_US/LC_MESSAGES/ok.po @@ -131,3 +131,18 @@ msgstr "" msgid "Use OCR" msgstr "" + +msgid "Check Monthly Card" +msgstr "" + +msgid "Check for monthly card to avoid interruption of tasks" +msgstr "" + +msgid "Monthly Card Config" +msgstr "" + +msgid "Monthly Card Time" +msgstr "" + +msgid "Your computer's local time when the monthly card will popup, hour in (1-24)" +msgstr "" diff --git a/i18n/zh_CN/LC_MESSAGES/ok.mo b/i18n/zh_CN/LC_MESSAGES/ok.mo index a6ef07bcfcbd2a7041653bb23235bd0f97beacad..75aca0cf9bdc1461cd694c250d4cba4739c128fb 100644 GIT binary patch delta 1144 zcmY+>O-NKx6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ok.po +++ b/i18n/zh_CN/LC_MESSAGES/ok.po @@ -1,4 +1,7 @@ # +msgid "" +msgstr "" + msgid "" msgstr "" "Project-Id-Version: 1.0\n" @@ -9,9 +12,6 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -msgid "" -msgstr "" - msgid "(1-6) Important, Choose which level to farm, lower levels might not produce a echo" msgstr "(1-6) 重要, 选择你对应世界等级可以产出声骸的难度, 从上到下为1-6" @@ -134,3 +134,18 @@ msgstr "高配置CPU请打开,增加拾取声骸准确度,如果配置不够导 msgid "Use OCR" msgstr "使用文字识别(中英文客户端适用)" + +msgid "Check Monthly Card" +msgstr "是否检查月卡" + +msgid "Check for monthly card to avoid interruption of tasks" +msgstr "设置避免小月卡弹窗打断任务" + +msgid "Monthly Card Config" +msgstr "小月卡设置" + +msgid "Monthly Card Time" +msgstr "月卡时间" + +msgid "Your computer's local time when the monthly card will popup, hour in (1-24)" +msgstr "几点会弹出月卡提示, 本地计算机时间(1-24)" diff --git a/src/char/BaseChar.py b/src/char/BaseChar.py index ee6fa4a..57ef977 100644 --- a/src/char/BaseChar.py +++ b/src/char/BaseChar.py @@ -167,7 +167,7 @@ def click_resonance(self, post_sleep=0, has_animation=False, send_click=True): if not self.resonance_available(current_resonance): self.logger.debug(f'click_resonance not available break') break - self.logger.debug(f'click_resonance resonance_available click') + self.logger.debug(f'click_resonance resonance_available click {current_resonance}') now = time.time() if now - last_click > 0.1: if ((current_resonance == 0) and send_click) or last_op == 'resonance': diff --git a/src/combat/CombatCheck.py b/src/combat/CombatCheck.py index 7360b72..28d6212 100644 --- a/src/combat/CombatCheck.py +++ b/src/combat/CombatCheck.py @@ -129,16 +129,6 @@ def find_target_enemy(self): logger.debug(f'find_target_enemy {target_enemy} {time.time() - start}') return target_enemy is not None - def handle_monthly_card(self): - monthly_card = self.find_one('monthly_card', threshold=0.8) - if monthly_card is not None: - self.click(monthly_card) - self.sleep(2) - self.click(monthly_card) - self.sleep(1) - logger.debug(f'check_monthly_card {monthly_card}') - return monthly_card is not None - def in_combat(self, rechecked=False): if self.in_liberation or self.recent_liberation(): self.last_combat_check = time.time() diff --git a/src/task/BaseCombatTask.py b/src/task/BaseCombatTask.py index e43f996..77897e6 100644 --- a/src/task/BaseCombatTask.py +++ b/src/task/BaseCombatTask.py @@ -173,13 +173,6 @@ def click(self, x=-1, y=-1, move_back=False, name=None, interval=-1): y = self.height_of_screen(0.5) return super().click(x, y, move_back, name, interval) - def wait_in_team_and_world(self, time_out=10, raise_if_not_found=True): - return self.wait_until(self.in_team_and_world, time_out=time_out, raise_if_not_found=raise_if_not_found) - - def in_team_and_world(self): - return self.in_team()[ - 0] # and self.find_one(f'gray_book_button', threshold=0.7, canny_lower=50, canny_higher=150) - def get_current_char(self): for char in self.chars: if char.is_current_char: @@ -222,7 +215,7 @@ def send_key_and_wait_f(self, direction, raise_if_not_found, time_out, running=F else: logger.warning(f"can't find the f to enter") return False - + remaining = time.time() - start if self.handle_claim_button(): diff --git a/src/task/BaseWWTask.py b/src/task/BaseWWTask.py index 97a959c..4886f30 100644 --- a/src/task/BaseWWTask.py +++ b/src/task/BaseWWTask.py @@ -1,4 +1,6 @@ import re +import time +from datetime import datetime, timedelta from ok.config.ConfigOption import ConfigOption from ok.feature.FindFeature import FindFeature @@ -13,12 +15,29 @@ }, config_description={ 'Use OCR': 'Turn on if your CPU is Powerful for more accuracy'}) +monthly_card_config_option = ConfigOption('Monthly Card Config', { + 'Check Monthly Card': False, + 'Monthly Card Time': 4 +}, config_description={ + 'Check Monthly Card': 'Check for monthly card to avoid interruption of tasks', + 'Monthly Card Time': 'Your computer\'s local time when the monthly card will popup, hour in (1-24)' +}) + class BaseWWTask(BaseTask, FindFeature, OCR): def __init__(self): super().__init__() self.pick_echo_config = self.get_config(pick_echo_config_option) + self.monthly_card_config = self.get_config(monthly_card_config_option) + self.next_monthly_card_start = 0 + + def validate(self, key, value): + message = self.validate_config(key, value) + if message: + return False, message + else: + return True, None @property def absorb_echo_text(self): @@ -38,6 +57,21 @@ def get_feature_by_lang(self, feature): else: return None + def set_check_monthly_card(self): + if self.monthly_card_config.get('Check Monthly Card'): + now = datetime.now() + hour = self.monthly_card_config.get('Monthly Card Time') + # Calculate the next 4 o'clock in the morning + next_four_am = now.replace(hour=hour, minute=0, second=0, microsecond=0) + if now >= next_four_am: + next_four_am += timedelta(days=1) + next_monthly_card_start_date_time = next_four_am - timedelta(seconds=30) + # Subtract 1 minute from the next 4 o'clock in the morning + self.next_monthly_card_start = next_monthly_card_start_date_time.timestamp() + logger.info('set next monthly card start time to {}'.format(next_monthly_card_start_date_time)) + else: + self.next_monthly_card_start = 0 + @property def f_search_box(self): f_search_box = self.get_box_by_name('pick_up_f') @@ -59,6 +93,47 @@ def find_f_with_text(self, target_text=None): return None return f + def check_for_monthly_card(self): + if self.next_monthly_card_start > 0: + if time.time() > self.next_monthly_card_start: + start = time.time() + logger.info(f'start waiting for monthly card') + f4_open = False + if self.in_team_and_world(): + logger.info(f'in team send f4 to wait') + self.send_key('f4') + f4_open = True + monthly_card = self.wait_until(self.handle_monthly_card, time_out=120, raise_if_not_found=False) + logger.info(f'wait monthly card end {monthly_card}') + if f4_open: + self.send_key('esc') + self.sleep(2) + logger.info(f'wait monthly card close f4') + cost = time.time() - start + self.set_check_monthly_card() + return cost + return 0 + + def sleep(self, timeout): + return super().sleep(timeout - self.check_for_monthly_card()) + + def wait_in_team_and_world(self, time_out=10, raise_if_not_found=True): + return self.wait_until(self.in_team_and_world, time_out=time_out, raise_if_not_found=raise_if_not_found) + + def in_team_and_world(self): + return self.in_team()[ + 0] # and self.find_one(f'gray_book_button', threshold=0.7, canny_lower=50, canny_higher=150) + + def handle_monthly_card(self): + monthly_card = self.find_one('monthly_card', threshold=0.8) + if monthly_card is not None: + self.click(monthly_card) + self.sleep(2) + self.click(monthly_card) + self.sleep(1) + logger.debug(f'check_monthly_card {monthly_card}') + return monthly_card is not None + @property def game_lang(self): if '鸣潮' in self.hwnd_title: diff --git a/src/task/FarmEchoTask.py b/src/task/FarmEchoTask.py index a1be803..21da7f5 100644 --- a/src/task/FarmEchoTask.py +++ b/src/task/FarmEchoTask.py @@ -24,6 +24,7 @@ def __init__(self): self.last_drop = False def run(self): + self.set_check_monthly_card() self.handler.post(self.mouse_reset, 0.01) if not self.in_team()[0]: self.log_error('must be in game world and in teams', notify=True) diff --git a/src/task/FarmWorldBossTask.py b/src/task/FarmWorldBossTask.py index 23c8b50..ecf1a20 100644 --- a/src/task/FarmWorldBossTask.py +++ b/src/task/FarmWorldBossTask.py @@ -148,6 +148,7 @@ def teleport_to_heal(self): self.sleep(2) def run(self): + self.set_check_monthly_card() if not self.check_main(): self.log_error('must be in game world and in teams', notify=True) self.handler.post(self.mouse_reset, 0.01) diff --git a/src/task/SkipDialogTask.py b/src/task/SkipDialogTask.py index 3fe2277..20588ba 100644 --- a/src/task/SkipDialogTask.py +++ b/src/task/SkipDialogTask.py @@ -5,11 +5,12 @@ from ok.logging.Logger import get_logger from ok.ocr.OCR import OCR from ok.task.TriggerTask import TriggerTask +from src.task.BaseWWTask import BaseWWTask logger = get_logger(__name__) -class AutoDialogTask(TriggerTask, FindFeature, OCR): +class AutoDialogTask(TriggerTask, BaseWWTask, FindFeature, OCR): def __init__(self): super().__init__()