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
8 changes: 6 additions & 2 deletions app/task/MAA/AutoProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,15 @@ def _parse_annihilation_weekly_progress(log: str) -> tuple[int, int] | None:


def _has_completed_annihilation_week(log: str) -> bool:
"""判断剿灭日志是否表明本周额度已完成。"""
"""判断剿灭日志是否表明本周额度已完成。

MAA 理智不足无法开战时同样打印「完成任务: 剿灭作战」且无进度行,
与已达上限在日志上不可区分,故无进度行一律视为未达标,宁可下次重试。
"""

progress = _parse_annihilation_weekly_progress(log)
return "完成任务: 剿灭作战" in log and (
progress is None or progress[0] >= progress[1]
progress is not None and progress[0] >= progress[1]
)


Expand Down
18 changes: 18 additions & 0 deletions tests/task/test_maa_annihilation_week.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# v5.4.0 结构下需先初始化 app.core:直接先导 app.task 会经
# MAA.__init__ -> manager -> app.core.__init__ -> task_manager 触发循环导入
# (dev 侧已重构消除,此处为 release 局部守卫,不影响生产入口)。
import app.core # noqa: F401

from app.task.MAA.AutoProxy import _has_completed_annihilation_week


def test_week_completed_requires_progress_line_at_cap() -> None:
log = "完成任务: 剿灭作战\n剿灭模式 : 1800 / 1800"
assert _has_completed_annihilation_week(log) is True
assert _has_completed_annihilation_week("剿灭模式 : 1850 / 1800\n完成任务: 剿灭作战") is True


def test_week_not_completed_without_cap_progress() -> None:
assert _has_completed_annihilation_week("完成任务: 剿灭作战\n剿灭模式 : 1480 / 1800") is False
assert _has_completed_annihilation_week("开始任务: 剿灭作战\n完成任务: 剿灭作战") is False
assert _has_completed_annihilation_week("剿灭模式 : 1480 / 1800") is False
Loading