镜牢入场前切队 + 选队页守卫;补回归结果与问题需求台账
实机回归发现: 镜牢入场时 AALC 直接点「进入」, 根本不走 select_battle_team, 用的是游戏记住的旧队伍; 「星之恩惠」页满屏星星又会让「选队星级」模板误命中。 - aalc_patches: 点「进入」前若在选队页且顶栏不是目标队, 先按体系名切队(充能优先, 没有就震颤); 新增选队页守卫(只有出现「恩惠」字样才忽略星级模板); 选队扫描从每轮 3 次拖动改为 1 次(3 次会整屏跳过, 实测漏掉「充能」) - tests: 44→45 个用例, 覆盖偏好顺序、星之恩惠判定、守卫行为 - docs: REGRESSION-RESULTS.md(勾选结果), ISSUES.md(问题/需求台账), BACKLOG 状态表, HANDOVER 补「拉取后必须重启服务」 单测: 641 passed。实机: 2026-11-15 01:51 入场精确选中「充能」。
This commit is contained in:
+128
-30
@@ -473,6 +473,12 @@ SYSTEM_TEAM_NAMES = {
|
||||
'blunt': ('打击',),
|
||||
}
|
||||
|
||||
# 体系名之外还想按顺序再试的队名(2026-11-14 用户指定: 充能优先, 没有就退到震颤)。
|
||||
# 注意: 体系本身仍按 team_system 算, 商店/饰品的体系判断不会跟着换。
|
||||
TEAM_PREFERENCES = {
|
||||
'charge': ('震颤',),
|
||||
}
|
||||
|
||||
# 左侧编队列表的 OCR 命中范围(客户区像素, 1280x720 实测)
|
||||
TEAM_LIST_X_MAX = 260
|
||||
TEAM_LIST_Y_MIN = 300
|
||||
@@ -512,6 +518,68 @@ def _scroll_team_list(auto, direction, times=6, distance=250):
|
||||
time.sleep(0.35)
|
||||
|
||||
|
||||
# 「星之恩惠」页满屏星星, 会命中「选队星级」模板(2026-11-14 实测: 连喊 6 次"不在编队界面",
|
||||
# AALC 以为在选队页, 实际在星之恩惠页)。只有编队图标在、或者左侧列表真的是队名, 才算选队页。
|
||||
TEAM_SCREEN_STARS = 'mirror/road_to_mir/select_team_stars_assets.png'
|
||||
ENTER_ASSET = 'mirror/road_to_mir/enter_assets.png'
|
||||
TEAM_SCREEN_ICON = 'teams/identify_assets.png'
|
||||
TEAM_SCREEN_KNOWN = frozenset(
|
||||
{'剧情关卡'}
|
||||
| {name for names in SYSTEM_TEAM_NAMES.values() for name in names}
|
||||
| {name for names in TEAM_PREFERENCES.values() for name in names}
|
||||
)
|
||||
|
||||
|
||||
def _looks_like_team_screen(auto):
|
||||
"""左侧列表里至少 3 条像队名(已知队名或 编队#N)才算选队页。"""
|
||||
try:
|
||||
names = _list_names([item for item in _team_ocr(auto) if _in_list(item[1], item[2])])
|
||||
except Exception:
|
||||
return False
|
||||
hits = sum(1 for name in names if name in TEAM_SCREEN_KNOWN or name.startswith('编队#'))
|
||||
return hits >= 3
|
||||
|
||||
|
||||
STARLIGHT_MARKERS = ('恩惠',)
|
||||
|
||||
|
||||
def _is_starlight_screen(auto):
|
||||
"""「星之恩惠」页: 有「恩惠」字样, 满屏星星; 选队页没有。
|
||||
|
||||
守卫只用它做否定条件, 比「必须有编队图标/队名列表」宽松: 选队页刚加载时图标和列表
|
||||
可能还没出来, 严格条件会把真的选队页一起跳过(2026-11-14 21:03 实测)。
|
||||
"""
|
||||
try:
|
||||
return any(marker in text for text, x, y in _team_ocr(auto) for marker in STARLIGHT_MARKERS)
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def install_team_screen_guard(log=print):
|
||||
"""选队页守卫: 星级模板在「星之恩惠」页上的命中不算数。"""
|
||||
try:
|
||||
from module.automation import auto
|
||||
except Exception as e:
|
||||
log('[lc_mcp] 选队页守卫补丁跳过: 无法导入 auto %s' % e)
|
||||
return None
|
||||
original = getattr(auto, 'find_element', None)
|
||||
if original is None:
|
||||
log('[lc_mcp] 选队页守卫补丁跳过: auto 没有 find_element')
|
||||
return None
|
||||
|
||||
def find_element(target, *args, **kwargs):
|
||||
result = original(target, *args, **kwargs)
|
||||
if result and isinstance(target, str) and target == TEAM_SCREEN_STARS:
|
||||
if _is_starlight_screen(auto):
|
||||
log('[lc_mcp] 星级模板在星之恩惠页命中, 不是选队页, 忽略')
|
||||
return False
|
||||
return result
|
||||
|
||||
auto.find_element = find_element
|
||||
log('[lc_mcp] patch: 选队页守卫(星之恩惠页忽略星级模板)')
|
||||
return original
|
||||
|
||||
|
||||
# OCR 实测误读(2026-11-14): 震颤→震颐, 沉沦→沉论, 编队#16→编#16。归一化时按子串改回来。
|
||||
TEAM_OCR_FIXES = (('震颐', '震颤'), ('沉论', '沉沦'), ('编#', '编队#'))
|
||||
TEAM_PREFIX_MIN = 2 # 前缀匹配的队名至少两个字, 免得单字名把一片都吃进来
|
||||
@@ -583,15 +651,22 @@ def _wait_header(auto, names, tries=3, delay=1.2):
|
||||
return False
|
||||
|
||||
|
||||
def _select_team_by_name(auto, names, log=print, rounds=4):
|
||||
def _select_team_by_name(auto, names, log=print, rounds=6):
|
||||
"""在编队列表里按名字点选。成功返回 True, 没找到返回 False。
|
||||
|
||||
名字先归一化(空白/全半角/常见误读); 精确匹配优先, 否则接受唯一的"名字+后缀"。
|
||||
没找到时把每一屏看到的名字打进日志。
|
||||
|
||||
每轮只往下拖 1 次: 实测一次拖动能滚 5~6 行、可见 7 行, 3 次一起拖会直接跳过
|
||||
一整屏(2026-11-14 实测: 从「剧情关卡..震颤」一次跳到「编队#19..25」, 漏掉「充能」)。
|
||||
"""
|
||||
if auto.take_screenshot() is None:
|
||||
return False
|
||||
if not auto.find_element('teams/identify_assets.png'):
|
||||
for _ in range(3):
|
||||
if auto.find_element(TEAM_SCREEN_ICON) or _looks_like_team_screen(auto):
|
||||
break
|
||||
time.sleep(0.8)
|
||||
else:
|
||||
log('[lc_mcp] 不在编队界面, 跳过按名字选队')
|
||||
return False
|
||||
current = [normalize_team_name(t) for t in _header_texts(auto) or ()
|
||||
@@ -603,32 +678,35 @@ def _select_team_by_name(auto, names, log=print, rounds=4):
|
||||
seen = []
|
||||
auto.mouse_click(1, 1)
|
||||
time.sleep(0.3)
|
||||
_scroll_team_list(auto, +1) # 先回到顶部
|
||||
for round_index in range(1, rounds + 1):
|
||||
if auto.take_screenshot() is None:
|
||||
log('[lc_mcp] 第 %d 屏截图失败' % round_index)
|
||||
continue
|
||||
items = [item for item in _team_ocr(auto) if _in_list(item[1], item[2])]
|
||||
seen.append(_list_names(items))
|
||||
hit, reason = pick_team_item(items, names)
|
||||
if hit:
|
||||
text, x, y = hit
|
||||
label = normalize_team_name(text)
|
||||
log('[lc_mcp] 编队列表里找到 %s @(%d,%d), %s' % (label, x, y, reason))
|
||||
auto.mouse_action_with_pos([x, y], offset=False)
|
||||
if _wait_header(auto, (label,)):
|
||||
log('[lc_mcp] patch: 已按体系名选中编队 %s' % label)
|
||||
decisions.record('team', label, team_name_match(label, names), wanted=list(names))
|
||||
return True
|
||||
header = [normalize_team_name(t) for t in _header_texts(auto) or ()]
|
||||
log('[lc_mcp] 点了 %s 但顶栏没变(顶栏读到: %s), 继续往下翻' % (label, '/'.join(header) or '无'))
|
||||
decisions.record('team', label, 'header_unchanged', wanted=list(names), header=header)
|
||||
else:
|
||||
log('[lc_mcp] 第 %d 屏没有 %s%s; 这一屏的名字: %s'
|
||||
% (round_index, '/'.join(names), ', ' + reason if reason else '',
|
||||
'/'.join(_list_names(items)) or '(空)'))
|
||||
_scroll_team_list(auto, -1, times=3)
|
||||
log('[lc_mcp] 编队列表里没找到 %s(共 %d 轮)' % ('/'.join(names), rounds))
|
||||
# 逐个名字找: 每个名字都从列表顶部重新翻, 保证 names 的顺序就是优先级。
|
||||
# (不能只用一屏的命中顺序——名字都可见时随屏幕位置, 靠后的优先项会被漏掉)
|
||||
for name in names:
|
||||
_scroll_team_list(auto, +1) # 回到顶部
|
||||
for round_index in range(1, rounds + 1):
|
||||
if auto.take_screenshot() is None:
|
||||
log('[lc_mcp] 第 %d 屏截图失败' % round_index)
|
||||
continue
|
||||
items = [item for item in _team_ocr(auto) if _in_list(item[1], item[2])]
|
||||
seen.append(_list_names(items))
|
||||
hit, reason = pick_team_item(items, (name,))
|
||||
if hit:
|
||||
text, x, y = hit
|
||||
label = normalize_team_name(text)
|
||||
log('[lc_mcp] 编队列表里找到 %s @(%d,%d), %s' % (label, x, y, reason))
|
||||
auto.mouse_action_with_pos([x, y], offset=False)
|
||||
if _wait_header(auto, (label,)):
|
||||
log('[lc_mcp] patch: 已按体系名选中编队 %s' % label)
|
||||
decisions.record('team', label, team_name_match(label, names), wanted=list(names))
|
||||
return True
|
||||
header = [normalize_team_name(t) for t in _header_texts(auto) or ()]
|
||||
log('[lc_mcp] 点了 %s 但顶栏没变(顶栏读到: %s), 继续往下翻' % (label, '/'.join(header) or '无'))
|
||||
decisions.record('team', label, 'header_unchanged', wanted=list(names), header=header)
|
||||
else:
|
||||
log('[lc_mcp] 第 %d 屏没有 %s%s; 这一屏的名字: %s'
|
||||
% (round_index, name, ', ' + reason if reason else '',
|
||||
'/'.join(_list_names(items)) or '(空)'))
|
||||
_scroll_team_list(auto, -1, times=1)
|
||||
log('[lc_mcp] 编队列表里没找到 %s(共 %d 轮)' % ('/'.join(names), rounds * max(len(names), 1)))
|
||||
decisions.record('team', None, 'not_found', wanted=list(names), seen=seen)
|
||||
return False
|
||||
|
||||
@@ -653,9 +731,11 @@ def install_system_team_selection(log=print):
|
||||
|
||||
def __init__(self, team_setting, team_num):
|
||||
original_init(self, team_setting, team_num)
|
||||
wanted['names'] = SYSTEM_TEAM_NAMES.get(getattr(self, 'system', ''), ())
|
||||
system = getattr(self, 'system', '')
|
||||
wanted['names'] = (SYSTEM_TEAM_NAMES.get(system, ())
|
||||
+ TEAM_PREFERENCES.get(system, ()))
|
||||
log('[lc_mcp] 镜牢体系 %s -> 目标编队 %s'
|
||||
% (getattr(self, 'system', '?'), '/'.join(wanted['names']) or '(无配置)'))
|
||||
% (system or '?', '/'.join(wanted['names']) or '(无配置)'))
|
||||
|
||||
def select_battle_team(num):
|
||||
names = wanted['names']
|
||||
@@ -668,6 +748,24 @@ def install_system_team_selection(log=print):
|
||||
return False
|
||||
return original(num)
|
||||
|
||||
# 2026-11-14 实测: 镜牢入场时 AALC 直接点「进入」, 根本不经过 select_battle_team
|
||||
# (只有它先看到星级模板才会走选队)。所以在点「进入」之前补一次切队。
|
||||
original_click = getattr(auto, 'click_element', None)
|
||||
if original_click is not None:
|
||||
def click_element(target, *args, **kwargs):
|
||||
if isinstance(target, str) and target == ENTER_ASSET:
|
||||
names = wanted['names']
|
||||
try:
|
||||
if names and _looks_like_team_screen(auto) and not _header_is(auto, names):
|
||||
log('[lc_mcp] 入场前切队伍: %s' % '/'.join(names))
|
||||
_select_team_by_name(auto, names, log=log)
|
||||
except Exception as e:
|
||||
log('[lc_mcp] 入场前切队伍出错: %s: %s' % (type(e).__name__, e))
|
||||
return original_click(target, *args, **kwargs)
|
||||
|
||||
auto.click_element = click_element
|
||||
log('[lc_mcp] patch: 入场前按体系切队伍')
|
||||
|
||||
mirror_mod.Mirror.__init__ = __init__
|
||||
mirror_mod.select_battle_team = select_battle_team
|
||||
log('[lc_mcp] patch: 镜牢按体系名选队')
|
||||
|
||||
+3
-1
@@ -14,7 +14,8 @@ from .aalc_engine import bootstrap
|
||||
from .aalc_patches import (WindowGuard, driver_click_tasks, headless_hdr_warning,
|
||||
install_default_battle_team, install_event_choices, install_exact_team_match,
|
||||
install_gift_preference, install_robust_set_foreground, install_shop_audit,
|
||||
install_shop_by_name, install_system_team_selection, install_theme_pack_audit,
|
||||
install_shop_by_name, install_system_team_selection, install_team_screen_guard,
|
||||
install_theme_pack_audit,
|
||||
install_typed_keyboard_road, mirror_progress, stop_driver_click)
|
||||
from .decisions import decisions
|
||||
from .game_lock import GameBusyError, exclusive_game
|
||||
@@ -130,6 +131,7 @@ def _run(task, params):
|
||||
# 镜牢: 编队是自定义名字(体系名), AALC 只会找 "编队#N"; 改成按体系名点选。
|
||||
if task in ('mirror', 'all'):
|
||||
install_system_team_selection(log=log)
|
||||
install_team_screen_guard(log=log)
|
||||
install_typed_keyboard_road(log=log)
|
||||
install_gift_preference(log=log)
|
||||
install_event_choices(log=log)
|
||||
|
||||
Reference in New Issue
Block a user