复查 V1.6.2 与 11-16~11-22 补丁: 返回按钮 TypeError、事件兜底连点、截图熔断线程
- 返回按钮(I-15): V1.6.2 在首次引导页拿 click_element 的返回值当坐标再点, 它返回 True → TypeError, 镜牢任务退出。install_back_button_result 只在 `x := auto.click_element(返回)` 这种调用时只找不点, 由上游点一次; 只看真假的调用照常点; 上游源码里没有这种写法就不装 - 事件兜底(I-16): LCP_EVENT_FALLBACK=1 时每轮都抢先点第 1 项, 上游走不到判定/继续/开始战斗; runs 里 1014 条 fallback_first, 73 段同屏连点 10~11 次, 最长 110 次。改成每屏只点一次、与按表共用 5 次上限 - 事件点击点只在这一项自己那行 OCR 字里取(原来整屏找子串, 叙述或别的选项是它的子串时会点错) - 截图熔断(I-17): 只在任务主线程计数和中止(retry_monitor 线程里抛只会打死那条线程, 两次熔断都记了两条); 要求连续出错满 30 秒、至少 20 次, 一闪而过的坏帧不再停掉任务 - 卡包: 优选阈值默认 1 与注释/提交说明/实机一致(LCP_THEME_PACK_THRESHOLD=0 不动上游); 「刷新」OCR 范围按 set_win_size/1440 缩放 - .gitignore 放行 docs/feedback/runs/**/logs/*.log(INDEX 说的过滤日志此前被 *.log 挡掉, 没进仓库) - README 补 LCP_EVENT_FALLBACK / LCP_THEME_PACK_THRESHOLD; BACKLOG 记 V1.6.2 影响; ISSUES 加 I-15~I-17 单测: 769 passed(新增上游真实 select_battle_team 端到端: 不装补丁 TypeError, 装了点一次)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -73,6 +73,17 @@ class EventOptionsTest(unittest.TestCase):
|
||||
options = ap.event_options(markers(1), [('继续', 900, 200 + 31)], SCALE)
|
||||
self.assertEqual(options[0][1], '')
|
||||
|
||||
def test_click_point_is_the_longest_line_of_that_option(self):
|
||||
lines = [('离开', 900, 200), ('不听故事', 900, 255), ('就这样离开', 1000, 265)]
|
||||
rows = ap.option_rows(markers(2), lines, SCALE)
|
||||
# 第 2 项「不听故事就这样离开」: 不会因为「离开」是它的子串去点第 1 项
|
||||
self.assertEqual(ap.option_click_pos(*rows[1]), (1000.0, 265.0))
|
||||
self.assertEqual(ap.option_click_pos(*rows[0]), (900.0, 200.0))
|
||||
|
||||
def test_click_point_falls_back_to_the_marker(self):
|
||||
rows = ap.option_rows(markers(1), [], SCALE)
|
||||
self.assertEqual(ap.option_click_pos(*rows[0]), (float(MARKER_X), 200.0))
|
||||
|
||||
|
||||
class ChooseEventOptionTest(unittest.TestCase):
|
||||
|
||||
@@ -197,7 +208,7 @@ class EventScreen:
|
||||
|
||||
def run(self, image):
|
||||
self.ocr_runs += 1
|
||||
lines = [('事件叙述文字', 200, 60)]
|
||||
lines = [('事件叙述文字', 200, 60)] + list(getattr(self, 'narration', ()))
|
||||
for (x, y), text in zip(markers(len(self.options or ())), self.options or ()):
|
||||
lines.append((text, x + 200, y))
|
||||
return SimpleNamespace(txts=tuple(t for t, _, _ in lines),
|
||||
@@ -205,6 +216,36 @@ class EventScreen:
|
||||
for _, x, y in lines])
|
||||
|
||||
|
||||
class StickyEventScreen(EventScreen):
|
||||
"""点了选项后选项框还留在画面上, 要上游点「继续」才进下一屏(实机表外事件就是这样)。"""
|
||||
|
||||
def __init__(self, screens):
|
||||
super().__init__(screens)
|
||||
self.picked = False
|
||||
self.continues = 0
|
||||
self.clicks = 0
|
||||
|
||||
def mouse_click(self, x, y, *args, **kwargs):
|
||||
if not self.options:
|
||||
return
|
||||
self.clicks += 1
|
||||
if self.clicks > 50:
|
||||
raise RuntimeError('同一屏点了 50 次还没走完事件')
|
||||
if not self.picked:
|
||||
rows = markers(len(self.options))
|
||||
above = [i for i, (_, my) in enumerate(rows) if my <= y]
|
||||
self.chosen.append(max(above) if above else 0)
|
||||
self.picked = True
|
||||
|
||||
def click_element(self, target, **kwargs):
|
||||
if target == 'event/continue_assets.png' and self.options and self.picked:
|
||||
self.continues += 1
|
||||
self.picked = False
|
||||
self.stage += 1
|
||||
return True
|
||||
return super().click_element(target, **kwargs)
|
||||
|
||||
|
||||
@unittest.skipUnless(MIRROR.is_file() and EVENT.is_file(), 'vendor/aalc 子模块未检出')
|
||||
class UpstreamEventHandlingTest(unittest.TestCase):
|
||||
"""执行上游真实的 Mirror.event_handling, 看每屏点了第几项。"""
|
||||
@@ -214,8 +255,9 @@ class UpstreamEventHandlingTest(unittest.TestCase):
|
||||
self.fn_node = upstream_function(MIRROR, 'event_handling', cls='Mirror')
|
||||
self.avoid_node = upstream_function(EVENT, 'click_option_avoiding_unknown', cls='EventHandling')
|
||||
|
||||
def play(self, screens, patched=True, env=None, unknown=None, solo=False, ignore_clicks=0):
|
||||
screen = EventScreen(screens, unknown=unknown, ignore_clicks=ignore_clicks)
|
||||
def play(self, screens, patched=True, env=None, unknown=None, solo=False, ignore_clicks=0, screen=None):
|
||||
if screen is None:
|
||||
screen = EventScreen(screens, unknown=unknown, ignore_clicks=ignore_clicks)
|
||||
cfg = SimpleNamespace(set_win_size=720)
|
||||
avoid_ns = dict(auto=screen, log=mock.Mock())
|
||||
exec(compile(ast.Module(body=[self.avoid_node], type_ignores=[]), str(EVENT), 'exec'), avoid_ns)
|
||||
@@ -309,6 +351,35 @@ class UpstreamEventHandlingTest(unittest.TestCase):
|
||||
def test_env_zero_keeps_upstream(self):
|
||||
self.assertIsNone(ap.install_event_choices(log=self.lines.append, env={ap.EVENT_CHOICES_ENV: '0'}))
|
||||
|
||||
# ---- LCP_EVENT_FALLBACK=1: 表外事件先点第 1 项 ----
|
||||
FALLBACK = {ap.EVENT_FALLBACK_ENV: '1'}
|
||||
|
||||
def test_fallback_clicks_first_option_once_then_lets_upstream_continue(self):
|
||||
# 11-18~11-21 实机: 点完第 1 项选项框还在, 补丁每轮抢先再点, 上游走不到「继续」(同屏连点 10~110 次)
|
||||
screen = StickyEventScreen([['战斗', '离开']])
|
||||
with mock.patch.object(ap.decisions, 'record') as record:
|
||||
self.assertEqual(self.play(None, env=self.FALLBACK, screen=screen), [0])
|
||||
self.assertEqual(screen.continues, 1)
|
||||
self.assertEqual(record.call_args_list, [mock.call('event', 1, 'fallback_first', options=['战斗', '离开'])])
|
||||
self.assertEqual(self.log.count('兜底点第 1 项'), 1)
|
||||
|
||||
def test_fallback_handles_each_new_screen_once(self):
|
||||
screen = StickyEventScreen([['战斗', '离开'], ['好', '不好']])
|
||||
self.assertEqual(self.play(None, env=self.FALLBACK, screen=screen), [0, 0])
|
||||
self.assertEqual(screen.continues, 2)
|
||||
|
||||
def test_fallback_still_upstream_without_env(self):
|
||||
screen = StickyEventScreen([['战斗', '离开']])
|
||||
self.play(None, screen=screen)
|
||||
self.assertNotIn('兜底点第 1 项', self.log)
|
||||
self.assertIn('表里没有这个事件, 交给 AALC', self.log)
|
||||
|
||||
def test_click_lands_on_the_option_row_not_on_matching_narration(self):
|
||||
# 叙述里正好有「特别的」: 原来整屏找子串, 会点到叙述那一行(第 1 项上方)
|
||||
screen = EventScreen([SHEEP])
|
||||
screen.narration = [('特别的', 200, 60)]
|
||||
self.assertEqual(self.play(None, screen=screen), [1])
|
||||
|
||||
|
||||
class InstallEventChoicesTest(unittest.TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user