diff --git a/autowsgr/data/images/common/confirm_5_540p.png b/autowsgr/data/images/common/confirm_5_540p.png new file mode 100644 index 00000000..ef5f1266 Binary files /dev/null and b/autowsgr/data/images/common/confirm_5_540p.png differ diff --git a/autowsgr/image_resources/ops.py b/autowsgr/image_resources/ops.py index 24ea5d55..67d1112b 100644 --- a/autowsgr/image_resources/ops.py +++ b/autowsgr/image_resources/ops.py @@ -43,11 +43,12 @@ class Confirm: CONFIRM_2 = LazyTemplate('common/confirm_2_540p.png', 'confirm_2') CONFIRM_3 = LazyTemplate('common/confirm_3_540p.png', 'confirm_3') CONFIRM_4 = LazyTemplate('common/confirm_4_540p.png', 'confirm_4') + CONFIRM_5 = LazyTemplate('common/confirm_5_540p.png', 'confirm_5') @classmethod def all(cls) -> list[ImageTemplate]: """所有确认弹窗模板列表。""" - return [cls.CONFIRM_1, cls.CONFIRM_2, cls.CONFIRM_3, cls.CONFIRM_4] + return [cls.CONFIRM_1, cls.CONFIRM_2, cls.CONFIRM_3, cls.CONFIRM_4, cls.CONFIRM_5] class Build: diff --git a/autowsgr/ui/map/base.py b/autowsgr/ui/map/base.py index 1e0a19be..3d106d97 100644 --- a/autowsgr/ui/map/base.py +++ b/autowsgr/ui/map/base.py @@ -13,8 +13,8 @@ from autowsgr.types import PageName from autowsgr.ui.map.data import ( CLICK_BACK, + CLICK_EXPEDITION_SKIP, CLICK_PANEL, - CLICK_SCREEN_CENTER, EXPEDITION_NOTIF_COLOR, EXPEDITION_NOTIF_PROBE, EXPEDITION_TOLERANCE, @@ -236,6 +236,6 @@ def ensure_panel(self, panel: MapPanel) -> None: if self.get_active_panel(screen) != panel: self.switch_panel(panel) - def click_screen_center(self) -> None: - """点击屏幕中央 — 用于跳过动画/确认弹窗。""" - self._ctrl.click(*CLICK_SCREEN_CENTER) + def click_expedition_skip(self) -> None: + """点击屏幕右侧 — 用于跳过远征动画。""" + self._ctrl.click(*CLICK_EXPEDITION_SKIP) diff --git a/autowsgr/ui/map/data.py b/autowsgr/ui/map/data.py index 69c9ba9d..bd4d0956 100644 --- a/autowsgr/ui/map/data.py +++ b/autowsgr/ui/map/data.py @@ -414,8 +414,8 @@ def parse_map_title(text: str) -> MapIdentity | None: # ── 远征 ── -CLICK_SCREEN_CENTER: tuple[float, float] = (0.5, 0.5) -"""屏幕中央 — 用于闪过动画/确认弹窗。""" +CLICK_EXPEDITION_SKIP: tuple[float, float] = (0.76, 0.5) +"""屏幕右侧 — 用于跳过远征动画。""" # ── 战利品/舰船获取数量 OCR 裁切区域 ── diff --git a/autowsgr/ui/map/panels/expedition.py b/autowsgr/ui/map/panels/expedition.py index 4828503d..baa4b151 100644 --- a/autowsgr/ui/map/panels/expedition.py +++ b/autowsgr/ui/map/panels/expedition.py @@ -119,8 +119,8 @@ def collect_expedition(self) -> int: break time.sleep(0.25) - # 3. 点击屏幕中央跳过动画 - self.click_screen_center() + # 3. 点击屏幕右侧跳过动画 + self.click_expedition_skip() time.sleep(1.0) # 4. 确认弹窗 diff --git a/examples/expedition.py b/examples/expedition.py new file mode 100644 index 00000000..a5a8ae9f --- /dev/null +++ b/examples/expedition.py @@ -0,0 +1,55 @@ +"""最小示例 — 定时收取远征和奖励。 + +每 5 分钟自动收取一次已完成的远征和任务奖励。 +""" + +import time + +from autowsgr.infra.logger import get_logger +from autowsgr.ops import collect_expedition, collect_rewards +from autowsgr.scheduler import launch + + +_log = get_logger('expedition_example') + +# 1. 启动并连接模拟器 (自动检测 usersettings.yaml) +ctx = launch('usersettings.yaml') + +# 每 5 分钟运行一次 +check_time = 5 + +_log.info(f'定时任务已启动,每 {check_time} 分钟执行一次收取操作') + +while True: + try: + # 记录开始时间 + start_time = time.time() + + _log.info('--- 开始例行检查 ---') + + # 收取远征 (自动重新派遣) + if collect_expedition(ctx): + _log.info('成功收取远征并重新派遣') + else: + _log.info('当前无远征可收取') + + # 收取任务奖励 + if collect_rewards(ctx): + _log.info('成功收取任务奖励') + else: + _log.info('当前无任务奖励可收取') + + # 计算剩余等待时间 + elapsed = time.time() - start_time + wait_time = max(1, check_time * 60 - elapsed) + + _log.info(f'检查完毕,等待 {wait_time / 60:.0f} 分钟后进行下一次检查...') + time.sleep(wait_time) + + except KeyboardInterrupt: + _log.info('用户手动停止脚本') + break + except Exception as e: + _log.error(f'执行过程中出现异常: {e}') + _log.info('等待 1 分钟后重试...') + time.sleep(60)