镜牢选队改为按体系名点选;补交接文档、待开发计划与单测
本机账号的编队按体系命名(流血/斩击/突刺/…),AALC 只认 编队#N,导致镜牢永远 报「无法寻得队伍」。新增 install_system_team_selection:按 team_system 映射的 中文队名在列表里精确匹配并点选,点完用顶栏队名确认;失败显式返回 False, 不静默回退到编号(该账号没有 编队#1~#12)。 - lc_mcp/aalc_patches.py: 新增选队补丁与区域/OCR 辅助 - lc_mcp/aalc_task.py: mirror/all 任务挂载该补丁 - tests/test_system_team_selection.py: 15 个用例,不依赖 AALC/Windows - docs/feedback/2026-11-14/: 实测记录 + 云端开发交接文件(含体系队名表) - docs/BACKLOG.md: 待开发计划(商店清单路径 bug、走位降级、三选一按体系等) 单测:460 passed。
This commit is contained in:
@@ -356,3 +356,190 @@ def install_robust_set_foreground(screen, log=print):
|
|||||||
handle.setForeground = setForeground
|
handle.setForeground = setForeground
|
||||||
log('[lc_mcp] patch: SetForegroundWindow 加 AttachThreadInput 兜底')
|
log('[lc_mcp] patch: SetForegroundWindow 加 AttachThreadInput 兜底')
|
||||||
return handle
|
return handle
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 日常本用默认队伍
|
||||||
|
|
||||||
|
|
||||||
|
def install_default_battle_team(scheme, log=print):
|
||||||
|
"""日常本不再翻队伍列表, 直接用界面上已经选中的默认队伍。
|
||||||
|
|
||||||
|
背景(2026-11-06): 这账号的队伍是自定义名字(不是 "编队#N"), 而
|
||||||
|
select_battle_team 按名字找队伍, 找不到就来回滑动 10 次(实测 61 秒), 滑完还把
|
||||||
|
队伍页留在滚动后的位置; 紧接着 battle.to_battle() 在 15 次循环里都找不到
|
||||||
|
"进入战斗" 按钮, 报 "超出最大尝试次数, 未能进入战斗", 整个日常就这样空转。
|
||||||
|
|
||||||
|
经验本/纽本本来就是用界面默认队伍打的, 跳过选队伍这一步即可。
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
from tasks.teams import team_formation as tf
|
||||||
|
except Exception as e:
|
||||||
|
log('[lc_mcp] 默认队伍补丁跳过: 无法导入 team_formation: %s' % e)
|
||||||
|
return None
|
||||||
|
original = getattr(tf, 'select_battle_team', None)
|
||||||
|
if original is None:
|
||||||
|
log('[lc_mcp] 默认队伍补丁跳过: 找不到 select_battle_team')
|
||||||
|
return None
|
||||||
|
|
||||||
|
def select_battle_team(*args, **kwargs):
|
||||||
|
log('[lc_mcp] patch: 日常本跳过选队伍, 直接用默认队伍')
|
||||||
|
return True
|
||||||
|
|
||||||
|
tf.select_battle_team = select_battle_team
|
||||||
|
scheme.select_battle_team = select_battle_team
|
||||||
|
log('[lc_mcp] patch: 日常本使用默认队伍')
|
||||||
|
return original
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 镜牢按体系名选队
|
||||||
|
|
||||||
|
# 这账号把编队按体系命名(流血的队就叫 "流血"), AALC 却只会找 "编队#N" / "TEAMS #N"。
|
||||||
|
# 2026-11-14 实测: 列表里是 剧情关卡/斩击/突刺/打击/烧伤/流血/震颤/破裂/沉沦/呼吸法/充能
|
||||||
|
# 再接 编队#13..#38, 根本没有 "编队#1" —— AALC 翻满 10 页也找不到, 报 "无法寻得队伍"。
|
||||||
|
SYSTEM_TEAM_NAMES = {
|
||||||
|
'burn': ('烧伤',),
|
||||||
|
'bleed': ('流血',),
|
||||||
|
'tremor': ('震颤',),
|
||||||
|
'rupture': ('破裂',),
|
||||||
|
'poise': ('呼吸法', '呼吸'),
|
||||||
|
'sinking': ('沉沦',),
|
||||||
|
'charge': ('充能',),
|
||||||
|
'slash': ('斩击',),
|
||||||
|
'pierce': ('突刺',),
|
||||||
|
'blunt': ('打击',),
|
||||||
|
}
|
||||||
|
|
||||||
|
# 左侧编队列表的 OCR 命中范围(客户区像素, 1280x720 实测)
|
||||||
|
TEAM_LIST_X_MAX = 260
|
||||||
|
TEAM_LIST_Y_MIN = 300
|
||||||
|
TEAM_LIST_Y_MAX = 640
|
||||||
|
# 顶栏 "编队名" 的位置, 用来确认真的选中了
|
||||||
|
TEAM_HEADER = (170, 520, 90, 150)
|
||||||
|
|
||||||
|
|
||||||
|
def _team_ocr(auto):
|
||||||
|
"""整屏 OCR, 返回 [(文本, x, y), ...]。用列表而不是 dict: 同名条目(列表里的队名和顶栏队名)
|
||||||
|
落在不同位置, dict 会把它们覆盖成一条。不用 my_crop: 裁剪区的坐标系不可靠。"""
|
||||||
|
ocr = auto._run_ocr_for_text(my_crop=None)
|
||||||
|
result = []
|
||||||
|
for text, pos in (ocr or {}).items():
|
||||||
|
clean = str(text).replace(' ', '').strip()
|
||||||
|
if not clean:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
x, y = float(pos[0]), float(pos[1])
|
||||||
|
except (TypeError, IndexError, ValueError):
|
||||||
|
continue
|
||||||
|
result.append((clean, x, y))
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def _in_list(x, y):
|
||||||
|
return x < TEAM_LIST_X_MAX and TEAM_LIST_Y_MIN < y < TEAM_LIST_Y_MAX
|
||||||
|
|
||||||
|
|
||||||
|
def _in_header(x, y):
|
||||||
|
x1, x2, y1, y2 = TEAM_HEADER
|
||||||
|
return x1 < x < x2 and y1 < y < y2
|
||||||
|
|
||||||
|
|
||||||
|
def _scroll_team_list(auto, direction, times=6, distance=250):
|
||||||
|
"""direction=+1 向下拖(回到列表顶部), -1 向上拖(往下翻)。"""
|
||||||
|
for _ in range(times):
|
||||||
|
auto.mouse_swipe_for_team_scroll(130, 430, dy=direction * distance, duration=0.3)
|
||||||
|
time.sleep(0.35)
|
||||||
|
|
||||||
|
|
||||||
|
def _header_is(auto, name):
|
||||||
|
"""顶栏当前队伍名就是 name。"""
|
||||||
|
if auto.take_screenshot() is None:
|
||||||
|
return False
|
||||||
|
return any(text == name and _in_header(x, y) for text, x, y in _team_ocr(auto))
|
||||||
|
|
||||||
|
|
||||||
|
def _wait_header(auto, name, tries=3, delay=1.2):
|
||||||
|
"""点完之后顶栏要过一两帧才刷新, 多等几次。"""
|
||||||
|
for _ in range(tries):
|
||||||
|
time.sleep(delay)
|
||||||
|
if _header_is(auto, name):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _select_team_by_name(auto, names, log=print, rounds=4):
|
||||||
|
"""在编队列表里按名字点选。成功返回 True, 没找到返回 False。"""
|
||||||
|
if auto.take_screenshot() is None:
|
||||||
|
return False
|
||||||
|
if not auto.find_element('teams/identify_assets.png'):
|
||||||
|
log('[lc_mcp] 不在编队界面, 跳过按名字选队')
|
||||||
|
return False
|
||||||
|
for name in names: # 已经是这支队就不用动列表
|
||||||
|
if _header_is(auto, name):
|
||||||
|
log('[lc_mcp] patch: 当前已经是编队 %s, 无需切换' % name)
|
||||||
|
return True
|
||||||
|
auto.mouse_click(1, 1)
|
||||||
|
time.sleep(0.3)
|
||||||
|
_scroll_team_list(auto, +1) # 先回到顶部
|
||||||
|
for round_index in range(rounds):
|
||||||
|
if auto.take_screenshot() is None:
|
||||||
|
continue
|
||||||
|
items = _team_ocr(auto)
|
||||||
|
hit = None
|
||||||
|
for name in names:
|
||||||
|
for text, x, y in items:
|
||||||
|
if text == name and _in_list(x, y):
|
||||||
|
hit = (name, x, y)
|
||||||
|
break
|
||||||
|
if hit:
|
||||||
|
break
|
||||||
|
if hit:
|
||||||
|
name, x, y = hit
|
||||||
|
log('[lc_mcp] 编队列表里找到 %s @(%d,%d)' % (name, x, y))
|
||||||
|
auto.mouse_action_with_pos([x, y], offset=False)
|
||||||
|
if _wait_header(auto, name):
|
||||||
|
log('[lc_mcp] patch: 已按体系名选中编队 %s' % name)
|
||||||
|
return True
|
||||||
|
log('[lc_mcp] 点了 %s 但顶栏没变, 继续往下翻' % name)
|
||||||
|
_scroll_team_list(auto, -1, times=3)
|
||||||
|
log('[lc_mcp] 编队列表里没找到 %s(共 %d 轮)' % ('/'.join(names), rounds))
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def install_system_team_selection(log=print):
|
||||||
|
"""镜牢选队改成"按队伍体系对应的中文名"在列表里点。
|
||||||
|
|
||||||
|
AALC 原生只认 编队#N; 本账号的编队是自定义名字(流血/斩击/...), 原生逻辑永远选不上。
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
from tasks.mirror import mirror as mirror_mod
|
||||||
|
from module.automation import auto
|
||||||
|
except Exception as e:
|
||||||
|
log('[lc_mcp] 体系选队补丁跳过: 无法导入 %s' % e)
|
||||||
|
return None
|
||||||
|
original = getattr(mirror_mod, 'select_battle_team', None)
|
||||||
|
if original is None:
|
||||||
|
log('[lc_mcp] 体系选队补丁跳过: mirror 模块没有 select_battle_team')
|
||||||
|
return None
|
||||||
|
wanted = {'names': ()}
|
||||||
|
original_init = mirror_mod.Mirror.__init__
|
||||||
|
|
||||||
|
def __init__(self, team_setting, team_num):
|
||||||
|
original_init(self, team_setting, team_num)
|
||||||
|
wanted['names'] = SYSTEM_TEAM_NAMES.get(getattr(self, 'system', ''), ())
|
||||||
|
log('[lc_mcp] 镜牢体系 %s -> 目标编队 %s'
|
||||||
|
% (getattr(self, 'system', '?'), '/'.join(wanted['names']) or '(无配置)'))
|
||||||
|
|
||||||
|
def select_battle_team(num):
|
||||||
|
names = wanted['names']
|
||||||
|
if names:
|
||||||
|
try:
|
||||||
|
if _select_team_by_name(auto, names, log=log):
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
log('[lc_mcp] 按名字选队出错: %s: %s' % (type(e).__name__, e))
|
||||||
|
return False
|
||||||
|
return original(num)
|
||||||
|
|
||||||
|
mirror_mod.Mirror.__init__ = __init__
|
||||||
|
mirror_mod.select_battle_team = select_battle_team
|
||||||
|
log('[lc_mcp] patch: 镜牢按体系名选队')
|
||||||
|
return original
|
||||||
|
|||||||
+10
-2
@@ -12,8 +12,9 @@ import sys
|
|||||||
from . import preflight
|
from . import preflight
|
||||||
from .aalc_engine import bootstrap
|
from .aalc_engine import bootstrap
|
||||||
from . import killswitch
|
from . import killswitch
|
||||||
from .aalc_patches import (WindowGuard, driver_click_tasks, install_exact_team_match,
|
from .aalc_patches import (WindowGuard, driver_click_tasks, install_default_battle_team,
|
||||||
install_robust_set_foreground)
|
install_exact_team_match, install_robust_set_foreground,
|
||||||
|
install_system_team_selection)
|
||||||
|
|
||||||
# 任务 -> {参数名: AALC 配置项}; 参数只在本次运行内生效
|
# 任务 -> {参数名: AALC 配置项}; 参数只在本次运行内生效
|
||||||
TASKS = {
|
TASKS = {
|
||||||
@@ -89,6 +90,13 @@ def run(task, params):
|
|||||||
|
|
||||||
install_exact_team_match(auto, log)
|
install_exact_team_match(auto, log)
|
||||||
install_robust_set_foreground(screen, log=log)
|
install_robust_set_foreground(screen, log=log)
|
||||||
|
# 日常本(经验/纽本)不翻队伍列表: 队伍是自定义名字时按名字找必然失败,
|
||||||
|
# 白等 60 秒还会把界面滚乱, 后面 to_battle 就找不到 "进入战斗" 了。
|
||||||
|
if task in ('daily', 'all'):
|
||||||
|
install_default_battle_team(scheme, log=log)
|
||||||
|
# 镜牢: 编队是自定义名字(体系名), AALC 只会找 "编队#N"; 改成按体系名点选。
|
||||||
|
if task in ('mirror', 'all'):
|
||||||
|
install_system_team_selection(log=log)
|
||||||
guard = WindowGuard(screen, cfg, log=log)
|
guard = WindowGuard(screen, cfg, log=log)
|
||||||
guard.start()
|
guard.start()
|
||||||
restore_path = os.environ.get(RESTORE_ENV)
|
restore_path = os.environ.get(RESTORE_ENV)
|
||||||
|
|||||||
Reference in New Issue
Block a user