按 docs/ISSUES.md 处理本机回归后待修/待数据的条目:
- I-06/R-04 开局「获得E.G.O饰品」弹窗死循环: 确认模板连续第 3 次命中起改点
按钮中心(勾号 +76/1440), 连续 20 次还在就记 [ERROR]、抛 TaskAbort 结束任务
(上游 continue 跳过了循环计数)。单测执行上游真实 select_init_ego_gift。
- I-05/R-03 键盘寻路 0 成功: 前台按键改发带扫描码和扩展键标志的 keybd_event,
各模式按住 0.12 秒(上游注释: Unity 6 校验扫描码/扩展键); 连续 3 个节点进不去
就本次任务停用键盘寻路(方案 B)。MCP key 工具前台同样处理。LCP_KEY_HOLD=0 关。
- I-07/R-02 事件表 6 -> 9 条: 蜘蛛巢、归乡路途两段(拿「归途」), 按 wiki.gg 核对结果;
全表按本机装的零协 release 2026111301 重新核对唯一性。
- I-13 复查 5992827: 「进入」先模板确认再 OCR(原来每轮都跑一次整屏 OCR);
选队页重试重新截图; 入场切队失败记 [ERROR] 且本局不再重翻列表。
- R-01/I-08 卡包按体系加分: wiki.gg 122 个卡包(楼层/专属饰品/Featured 分类) +
零协中文名生成 lc_mcp/data/theme_pack_systems.json(scripts/build_theme_pack_systems.py);
灰机 wiki 对云端 403、BWIKI 无卡包条目, 中文社区攻略用 codex CLI 联网检索,
推荐/避开并入表的 community。选卡包时临时加到 AALC 权重上, 按当前难度只看会出现
的卡包; 审计记 system_bonus。LCP_THEME_PACK_SYSTEMS=0 关。
- 文档: ISSUES/BACKLOG/README 更新, 新增 docs/feedback/2026-11-15/REGRESSION.md
(本轮回归清单)和 theme-pack-research.md(检索记录)。
单测 703 个全过(Linux)。实机未验。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
242 lines
9.6 KiB
Python
242 lines
9.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""「获得E.G.O饰品」确认弹窗兜底(ISSUES I-06 / R-04)。
|
|
|
|
2026-11-14 18:45: AALC 一直点确认模板的匹配点(勾号), 弹窗不关, 连点 5 分钟; 手动点按钮中心一次就过。
|
|
上游 select_init_ego_gift 点到确认就 continue, 循环底部的 loop_count 退出判断永远走不到。
|
|
端到端用例执行上游真实的 select_init_ego_gift。
|
|
"""
|
|
import ast
|
|
import sys
|
|
import types
|
|
import unittest
|
|
from pathlib import Path
|
|
from types import SimpleNamespace
|
|
from unittest import mock
|
|
|
|
REPO = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(REPO))
|
|
from lc_mcp import aalc_patches as ap # noqa: E402
|
|
|
|
MIRROR = REPO / 'vendor' / 'aalc' / 'tasks' / 'mirror' / 'mirror.py'
|
|
CONFIRM = ap.GIFT_CONFIRM
|
|
TICK = (602.0, 531.75) # 1280x720 下确认模板(勾号)的中心
|
|
BUTTON = (640, 532) # 按钮中心: 勾号 + 76 * 720/1440
|
|
|
|
|
|
class Popup:
|
|
"""只有确认弹窗的假 auto: 点按钮中心才关(closes_on_button), 点勾号永远不关。"""
|
|
|
|
def __init__(self, closes_on_button=True):
|
|
self.open = True
|
|
self.closes_on_button = closes_on_button
|
|
self.template_clicks = 0
|
|
self.button_clicks = []
|
|
self.other_ok = False
|
|
|
|
def click_element(self, target, *args, click=True, **kwargs):
|
|
if target == CONFIRM and self.open:
|
|
if not click:
|
|
return TICK
|
|
self.template_clicks += 1
|
|
return True
|
|
if target == 'other' and self.other_ok:
|
|
return True if click else (1, 1)
|
|
return False
|
|
|
|
def mouse_click(self, x, y, *args, **kwargs):
|
|
self.button_clicks.append((x, y))
|
|
if self.closes_on_button and abs(x - BUTTON[0]) <= 15 and abs(y - BUTTON[1]) <= 15:
|
|
self.open = False
|
|
return True
|
|
|
|
|
|
class GuardTest(unittest.TestCase):
|
|
|
|
def install(self, auto, clock=None):
|
|
self.lines = []
|
|
self.now = [0.0]
|
|
modules = {'module': types.ModuleType('module'),
|
|
'module.automation': SimpleNamespace(auto=auto),
|
|
'module.config': SimpleNamespace(cfg=SimpleNamespace(set_win_size=720))}
|
|
with mock.patch.dict(sys.modules, modules):
|
|
self.assertIsNotNone(ap.install_gift_confirm_guard(
|
|
log=self.lines.append, clock=clock or (lambda: self.now[0])))
|
|
return auto
|
|
|
|
def hit(self, auto, times=1, step=1.5):
|
|
results = []
|
|
for _ in range(times):
|
|
self.now[0] += step
|
|
results.append(auto.click_element(CONFIRM))
|
|
return results
|
|
|
|
def test_first_two_hits_are_upstream_clicks(self):
|
|
auto = self.install(Popup())
|
|
self.assertEqual(self.hit(auto, 2), [True, True])
|
|
self.assertEqual(auto.template_clicks, 2)
|
|
self.assertEqual(auto.button_clicks, [])
|
|
|
|
def test_third_hit_clicks_the_button_center_and_closes_it(self):
|
|
auto = self.install(Popup())
|
|
with mock.patch.object(ap.decisions, 'record') as record:
|
|
self.assertEqual(self.hit(auto, 3), [True, True, True])
|
|
self.assertEqual(auto.button_clicks, [BUTTON])
|
|
self.assertFalse(auto.open)
|
|
self.assertIn('确认点了 2 次还在, 改点按钮中心 (640,532)', '\n'.join(self.lines))
|
|
record.assert_called_once_with('gift_confirm', 'button_center', 'repeated', clicks=2)
|
|
self.assertEqual(auto.click_element(CONFIRM), False) # 关了就找不到
|
|
|
|
def test_stuck_popup_ends_the_task(self):
|
|
auto = self.install(Popup(closes_on_button=False))
|
|
with mock.patch.object(ap.decisions, 'record'), self.assertRaises(ap.TaskAbort):
|
|
self.hit(auto, ap.GIFT_CONFIRM_LIMIT)
|
|
self.assertEqual(len(auto.button_clicks), ap.GIFT_CONFIRM_LIMIT - ap.GIFT_CONFIRM_SHIFT_AT)
|
|
self.assertIn('[ERROR] [lc_mcp] 「获得E.G.O饰品」确认连点 20 次弹窗还在, 结束任务', '\n'.join(self.lines))
|
|
# 不是 Exception: AALC 的 onetime_mir_process 吞不掉它
|
|
self.assertFalse(issubclass(ap.TaskAbort, Exception))
|
|
|
|
def test_other_successful_click_resets_the_streak(self):
|
|
auto = self.install(Popup(closes_on_button=False))
|
|
self.hit(auto, 2)
|
|
auto.other_ok = True
|
|
self.assertTrue(auto.click_element('other'))
|
|
self.hit(auto, 2)
|
|
self.assertEqual(auto.button_clicks, [])
|
|
self.assertEqual(auto.template_clicks, 4)
|
|
|
|
def test_other_lookup_or_failed_click_does_not_reset(self):
|
|
auto = self.install(Popup())
|
|
self.hit(auto, 2)
|
|
auto.click_element('missing')
|
|
auto.other_ok = True
|
|
auto.click_element('other', click=False) # 只查不点
|
|
self.hit(auto, 1)
|
|
self.assertEqual(auto.button_clicks, [BUTTON])
|
|
|
|
def test_missing_popup_resets_the_streak(self):
|
|
auto = self.install(Popup())
|
|
self.hit(auto, 2)
|
|
auto.open = False
|
|
self.assertEqual(self.hit(auto, 1), [False])
|
|
auto.open = True
|
|
self.hit(auto, 2)
|
|
self.assertEqual(auto.button_clicks, [])
|
|
|
|
def test_hits_far_apart_are_not_a_streak(self):
|
|
auto = self.install(Popup())
|
|
self.hit(auto, 2)
|
|
self.hit(auto, 1, step=ap.GIFT_CONFIRM_GAP + 1)
|
|
self.assertEqual(auto.button_clicks, [])
|
|
self.assertEqual(auto.template_clicks, 3)
|
|
|
|
def test_confirm_lookup_without_click_is_untouched(self):
|
|
auto = self.install(Popup())
|
|
for _ in range(5):
|
|
self.assertEqual(auto.click_element(CONFIRM, click=False), TICK)
|
|
self.assertEqual(auto.template_clicks, 0)
|
|
self.assertEqual(self.hit(auto, 2), [True, True])
|
|
self.assertEqual(auto.button_clicks, [])
|
|
|
|
|
|
class Spinning(Exception):
|
|
pass
|
|
|
|
|
|
class InitGiftScreen:
|
|
"""开局选饰品后的「获得E.G.O饰品」弹窗。点勾号不关, 点按钮中心才关, 关了就是卡包页。"""
|
|
|
|
def __init__(self, closes_on_button=True, max_shots=200):
|
|
self.state = 'popup'
|
|
self.closes_on_button = closes_on_button
|
|
self.max_shots = max_shots
|
|
self.shots = 0
|
|
self.model = 'clam'
|
|
self.template_clicks = 0
|
|
|
|
def take_screenshot(self, *args, **kwargs):
|
|
self.shots += 1
|
|
if self.shots > self.max_shots:
|
|
raise Spinning(self.shots)
|
|
return object()
|
|
|
|
def find_element(self, target, *args, **kwargs):
|
|
if target == 'mirror/theme_pack/feature_theme_pack_assets.png':
|
|
return (640, 100) if self.state == 'theme' else None
|
|
if target == CONFIRM and self.state == 'popup':
|
|
return TICK
|
|
return None
|
|
|
|
def click_element(self, target, *args, click=True, **kwargs):
|
|
pos = self.find_element(target)
|
|
if not pos:
|
|
return False
|
|
if not click:
|
|
return pos
|
|
self.template_clicks += 1 # 上游点的是匹配点(勾号) ±10 像素, 点不到按钮
|
|
return True
|
|
|
|
def mouse_click(self, x, y, *args, **kwargs):
|
|
if self.closes_on_button and abs(x - BUTTON[0]) <= 15 and abs(y - BUTTON[1]) <= 15:
|
|
self.state = 'theme'
|
|
return True
|
|
|
|
def mouse_to_blank(self, *args, **kwargs):
|
|
pass
|
|
|
|
def mouse_drag(self, *args, **kwargs):
|
|
pass
|
|
|
|
|
|
@unittest.skipUnless(MIRROR.is_file(), 'vendor/aalc 子模块未检出')
|
|
class UpstreamInitGiftTest(unittest.TestCase):
|
|
"""执行上游真实的 Mirror.select_init_ego_gift。"""
|
|
|
|
def setUp(self):
|
|
tree = ast.parse(MIRROR.read_text(encoding='utf-8'))
|
|
cls = next(n for n in tree.body if isinstance(n, ast.ClassDef) and n.name == 'Mirror')
|
|
self.fn_node = next(n for n in cls.body
|
|
if isinstance(n, ast.FunctionDef) and n.name == 'select_init_ego_gift')
|
|
self.lines = []
|
|
|
|
def play(self, screen, patched=True):
|
|
cfg = SimpleNamespace(set_win_size=720)
|
|
ns = dict(auto=screen, cfg=cfg, log=mock.Mock(), sleep=lambda *a: None, retry=lambda: True,
|
|
back_init_menu=mock.Mock(), all_systems={}, start_gift={})
|
|
exec(compile(ast.Module(body=[self.fn_node], type_ignores=[]), str(MIRROR), 'exec'), ns)
|
|
mirror = SimpleNamespace(system='bleed', opening_items=False, observe_ego_gift=False,
|
|
observe_ego_gift_selected=[], observe_bbox=None,
|
|
_click_init_gift_row=lambda gift_id: False)
|
|
if patched:
|
|
modules = {'module': types.ModuleType('module'),
|
|
'module.automation': SimpleNamespace(auto=screen),
|
|
'module.config': SimpleNamespace(cfg=cfg)}
|
|
with mock.patch.dict(sys.modules, modules):
|
|
ap.install_gift_confirm_guard(log=self.lines.append)
|
|
with mock.patch.object(ap.decisions, 'record'):
|
|
return ns['select_init_ego_gift'](mirror)
|
|
|
|
def test_upstream_spins_on_a_popup_its_click_cannot_close(self):
|
|
screen = InitGiftScreen()
|
|
with self.assertRaises(Spinning):
|
|
self.play(screen, patched=False)
|
|
self.assertEqual(screen.state, 'popup')
|
|
self.assertGreater(screen.template_clicks, 100) # 计数早就负了, 照点不误
|
|
|
|
def test_guard_clicks_the_button_and_the_loop_moves_on(self):
|
|
screen = InitGiftScreen()
|
|
self.play(screen)
|
|
self.assertEqual(screen.state, 'theme')
|
|
self.assertEqual(screen.template_clicks, ap.GIFT_CONFIRM_SHIFT_AT - 1)
|
|
self.assertLess(screen.shots, 10)
|
|
|
|
def test_guard_ends_the_task_when_nothing_closes_it(self):
|
|
screen = InitGiftScreen(closes_on_button=False)
|
|
with self.assertRaises(ap.TaskAbort):
|
|
self.play(screen)
|
|
self.assertLessEqual(screen.shots, ap.GIFT_CONFIRM_LIMIT + 1)
|
|
self.assertIn('[ERROR]', '\n'.join(self.lines))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|