- 返回按钮(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>
76 lines
3.1 KiB
Python
76 lines
3.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""卡包刷新按钮改成按 OCR 文字点。
|
|
|
|
2026-11-18 用户反馈: 卡包页按「刷新」没按上(模板 0.90 命中、点下去卡包不变)。
|
|
"""
|
|
import sys
|
|
import types
|
|
import unittest
|
|
from pathlib import Path
|
|
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
|
|
|
|
|
|
class RefreshTextPosTest(unittest.TestCase):
|
|
|
|
def test_finds_refresh_in_top_right(self):
|
|
auto = mock.Mock()
|
|
with mock.patch.object(ap, '_ocr_lines', return_value=[
|
|
('商店', 600, 30), ('刷新', 1000, 45), ('关键词刷新', 300, 40)]):
|
|
self.assertEqual(ap._refresh_text_pos(auto, 720 / 1440), (1000, 45))
|
|
|
|
def test_ignores_shop_refresh_on_the_left(self):
|
|
auto = mock.Mock()
|
|
with mock.patch.object(ap, '_ocr_lines', return_value=[('关键词刷新', 300, 40)]):
|
|
self.assertIsNone(ap._refresh_text_pos(auto, 720 / 1440))
|
|
|
|
def test_ignores_text_below_the_header(self):
|
|
auto = mock.Mock()
|
|
with mock.patch.object(ap, '_ocr_lines', return_value=[('刷新', 1000, 400)]):
|
|
self.assertIsNone(ap._refresh_text_pos(auto, 720 / 1440))
|
|
|
|
def test_box_scales_with_window_size(self):
|
|
# 1080 窗口: 右上角范围按 set_win_size / 1440 放大, 同一个按钮在 (1500, 70)
|
|
auto = mock.Mock()
|
|
with mock.patch.object(ap, '_ocr_lines', return_value=[('刷新', 1500, 70)]):
|
|
self.assertIsNone(ap._refresh_text_pos(auto, 720 / 1440))
|
|
self.assertEqual(ap._refresh_text_pos(auto, 1080 / 1440), (1500, 70))
|
|
|
|
|
|
class RefreshClickTest(unittest.TestCase):
|
|
|
|
def install(self, auto):
|
|
module = types.ModuleType('module.automation')
|
|
module.auto = auto
|
|
config = types.ModuleType('module.config')
|
|
config.cfg = types.SimpleNamespace(set_win_size=720)
|
|
with mock.patch.dict(sys.modules, {'module': types.ModuleType('module'),
|
|
'module.automation': module, 'module.config': config}):
|
|
return ap.install_theme_pack_refresh_click(log=lambda *_: None)
|
|
|
|
def test_clicks_ocr_position_instead_of_template(self):
|
|
auto = mock.Mock()
|
|
auto.click_element.return_value = True
|
|
self.install(auto)
|
|
with mock.patch.object(ap, '_refresh_text_pos', return_value=(1000, 45)):
|
|
self.assertTrue(auto.click_element(ap.THEME_PACK_REFRESH))
|
|
auto.mouse_click.assert_called_once_with(1000, 45)
|
|
|
|
def test_falls_back_to_template_when_text_missing(self):
|
|
auto = mock.Mock()
|
|
auto.click_element.return_value = True
|
|
original = self.install(auto)
|
|
with mock.patch.object(ap, '_refresh_text_pos', return_value=None):
|
|
auto.click_element(ap.THEME_PACK_REFRESH)
|
|
auto.mouse_click.assert_not_called()
|
|
|
|
def test_other_targets_untouched(self):
|
|
auto = mock.Mock()
|
|
auto.click_element.return_value = True
|
|
self.install(auto)
|
|
auto.click_element('other/thing.png')
|
|
auto.mouse_click.assert_not_called()
|