Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added autowsgr/data/images/common/confirm_5_540p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion autowsgr/image_resources/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions autowsgr/ui/map/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
4 changes: 2 additions & 2 deletions autowsgr/ui/map/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 裁切区域 ──

Expand Down
4 changes: 2 additions & 2 deletions autowsgr/ui/map/panels/expedition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. 确认弹窗
Expand Down
55 changes: 55 additions & 0 deletions examples/expedition.py
Original file line number Diff line number Diff line change
@@ -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)
Loading