- I-19 用户「老是选择 p 不过去的包」: AALC 表里负分 = Boss 难打/拖时间(绝望骑士、时间杀人魔、卡塞蒂 -5),
体系分 +6 直接加上去 -5 变 +1, 震颤队每局 3/4 层去打憎恶与绝望/时间杀人时间(3 层 16.7 分钟 vs 同层 8~11)。
现在卡包在 AALC 的原权重 < THEME_PACK_LIFT_MIN(0) 时体系分只折成 ±0.9 小数, 同档排先后、不跨档;
0 分及以上照旧加满; 兔子洞路线分不变。权重可能是小数(绝望 -5→-4.4)。
回放 11-15~11-21 的 61 次选包: 15 次改选(全是 3/4/5 层的憎恶与绝望/时间杀人时间)。
- I-20 fb7a0ec 的拖拽兜底挂在加分补丁里: 加分关掉/没体系时不生效, 且拖完马上截图会把转场中的成功也当失败。
改成 install_theme_pack_drag_retry 单独装: 3 秒内每 0.5 秒看「刷新」, 消失即确认, 一直在才下移 160(1440 标定)再拖。
- theme_pack_systems.json 说明同步; ISSUES 记 I-19/I-20。
单测: 795 passed(新增 test_theme_pack_drag_retry 9 例, test_theme_pack_systems +3)。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
118 lines
5.0 KiB
Python
118 lines
5.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""卡包拖拽没确认时下移再拖一次。
|
|
|
|
2026-11-22 用户反馈: 5 层选卡包卡了 40 分钟。上游从模板匹配点往下拖, 匹配点常落在卡面放大镜上, 拖不动。
|
|
"""
|
|
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
|
|
|
|
|
|
class LeftThemePackPageTest(unittest.TestCase):
|
|
|
|
def test_refresh_gone_means_confirmed(self):
|
|
auto = mock.Mock()
|
|
auto.find_element.side_effect = [(1000, 45), (1000, 45), None] # 转场时「刷新」还在一会儿
|
|
with mock.patch.object(ap.time, 'sleep') as sleep:
|
|
self.assertTrue(ap._left_theme_pack_page(auto, wait=10, poll=0.5))
|
|
self.assertEqual(sleep.call_count, 2)
|
|
|
|
def test_refresh_still_there_after_wait_means_not_confirmed(self):
|
|
auto = mock.Mock()
|
|
auto.find_element.return_value = (1000, 45)
|
|
clock = iter(range(100))
|
|
with mock.patch.object(ap.time, 'sleep'), mock.patch.object(ap.time, 'monotonic', lambda: next(clock)):
|
|
self.assertFalse(ap._left_theme_pack_page(auto, wait=3, poll=0.5))
|
|
auto.find_element.assert_called_with(ap.THEME_PACK_REFRESH, take_screenshot=True)
|
|
|
|
def test_recognition_error_counts_as_confirmed(self):
|
|
auto = mock.Mock()
|
|
auto.find_element.side_effect = RuntimeError('截图失败')
|
|
self.assertTrue(ap._left_theme_pack_page(auto))
|
|
|
|
|
|
class DragRetryTest(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
self.lines = []
|
|
self.drags = []
|
|
self.auto = SimpleNamespace(mouse_drag_down=lambda x, y, *a, **k: self.drags.append((x, y)))
|
|
self.mirror = types.ModuleType('tasks.mirror.mirror')
|
|
self.calls = []
|
|
|
|
def select_theme_pack(*args, **kwargs):
|
|
self.calls.append(args)
|
|
self.auto.mouse_drag_down(300, 200) # 上游: 从模板匹配点往下拖
|
|
self.mirror.select_theme_pack = select_theme_pack
|
|
|
|
def install(self, win=720):
|
|
automation = types.ModuleType('module.automation')
|
|
automation.auto = self.auto
|
|
config = types.ModuleType('module.config')
|
|
config.cfg = SimpleNamespace(set_win_size=win)
|
|
package = types.ModuleType('tasks.mirror')
|
|
package.mirror = self.mirror
|
|
modules = {'module': types.ModuleType('module'), 'module.automation': automation, 'module.config': config,
|
|
'tasks': types.ModuleType('tasks'), 'tasks.mirror': package, 'tasks.mirror.mirror': self.mirror}
|
|
with mock.patch.dict(sys.modules, modules):
|
|
return ap.install_theme_pack_drag_retry(log=self.lines.append)
|
|
|
|
def run_select(self, confirmed):
|
|
real = self.auto.mouse_drag_down
|
|
with mock.patch.object(ap, '_left_theme_pack_page', return_value=confirmed), \
|
|
mock.patch.object(ap.decisions, 'record') as record:
|
|
self.mirror.select_theme_pack(False, 5, 1, False)
|
|
self.assertIs(self.auto.mouse_drag_down, real, 'select_theme_pack 结束要还原 mouse_drag_down')
|
|
return record
|
|
|
|
def test_confirmed_drag_is_not_repeated(self):
|
|
self.assertIsNotNone(self.install())
|
|
record = self.run_select(confirmed=True)
|
|
self.assertEqual(self.drags, [(300, 200)])
|
|
record.assert_not_called()
|
|
|
|
def test_unconfirmed_drag_retries_lower_on_the_card(self):
|
|
self.install()
|
|
record = self.run_select(confirmed=False)
|
|
self.assertEqual(self.drags, [(300, 200), (300, 280)]) # 720 下 80px
|
|
record.assert_called_once_with('theme_pack', None, 'drag_retry', pos=[300, 200], dy=80)
|
|
self.assertIn('卡包拖拽没确认(300,200), 下移 80px 再拖一次', '\n'.join(self.lines))
|
|
|
|
def test_offset_scales_with_window_size(self):
|
|
self.install(win=1080)
|
|
self.run_select(confirmed=False)
|
|
self.assertEqual(self.drags[1], (300, 320))
|
|
|
|
def test_uses_the_drag_bound_at_call_time(self):
|
|
# 驱动代理、别的补丁可能在安装之后才换 mouse_drag_down
|
|
self.install()
|
|
later = []
|
|
self.auto.mouse_drag_down = lambda x, y, *a, **k: later.append((x, y))
|
|
self.run_select(confirmed=False)
|
|
self.assertEqual(later, [(300, 200), (300, 280)])
|
|
self.assertEqual(self.drags, [])
|
|
|
|
def test_wraps_the_existing_select_and_logs_install(self):
|
|
inner = self.mirror.select_theme_pack
|
|
self.assertIs(self.install(), inner)
|
|
self.assertIs(self.mirror.select_theme_pack.__wrapped__, inner)
|
|
self.run_select(confirmed=True)
|
|
self.assertEqual(self.calls, [(False, 5, 1, False)])
|
|
self.assertIn('patch: 卡包拖拽没确认时下移 80px 再拖一次', '\n'.join(self.lines))
|
|
|
|
def test_skips_without_aalc(self):
|
|
with mock.patch.dict(sys.modules, {'tasks': None}):
|
|
self.assertIsNone(ap.install_theme_pack_drag_retry(log=self.lines.append))
|
|
self.assertIn('卡包拖拽兜底跳过', '\n'.join(self.lines))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|