From 348de32807e905d7684b2152d32ef2f74c3449bd Mon Sep 17 00:00:00 2001 From: ywsabc2 Date: Sun, 15 Nov 2026 01:50:12 +0000 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E6=9F=A5=E4=BF=AE=E6=AD=A3:=20?= =?UTF-8?q?=E5=8D=A1=E5=8C=85=E5=AE=A1=E8=AE=A1=E6=8A=8A=E5=B8=A6=E7=A9=BA?= =?UTF-8?q?=E6=A0=BC=E7=9A=84=E9=94=AE=E6=88=AA=E5=9C=A8=E7=A9=BA=E6=A0=BC?= =?UTF-8?q?=E5=89=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 卡包按体系加分会加带空格的全名键(如「WARP快车谋杀案 复刻」), 审计从 AALC 日志取 「此次选择卡包关键词:X」时用 \S+, 截成「WARP快车谋杀案」, system_bonus 也对不上。 改成取到行尾; 补端到端用例(困难模式流血队选中复刻 WARP), 旧正则下该用例失败。 单测 704 个全过。 Co-Authored-By: Claude Opus 5.5 --- lc_mcp/aalc_patches.py | 3 ++- tests/test_theme_pack_systems.py | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lc_mcp/aalc_patches.py b/lc_mcp/aalc_patches.py index a3235b3..0f7d96a 100644 --- a/lc_mcp/aalc_patches.py +++ b/lc_mcp/aalc_patches.py @@ -1516,7 +1516,8 @@ def install_shop_by_name(log=print, env=None): return original -THEME_PACK_PICK = re.compile(r'此次选择卡包关键词[::]\s*(\S+)') +# 取到行尾: 卡包按体系加分会加带空格的全名键(如「WARP快车谋杀案 复刻」), \S+ 会截在空格前 +THEME_PACK_PICK = re.compile(r'此次选择卡包关键词[::]\s*(.+?)\s*$', re.M) THEME_PACK_WEIGHTS = '当前主题包权重列表' THEME_PACK_SOURCE = 'select_theme_pack.py' diff --git a/tests/test_theme_pack_systems.py b/tests/test_theme_pack_systems.py index 5893000..47fcc06 100644 --- a/tests/test_theme_pack_systems.py +++ b/tests/test_theme_pack_systems.py @@ -232,9 +232,9 @@ class UpstreamSelectThemePackTest(unittest.TestCase): self.node = next(n for n in tree.body if isinstance(n, ast.FunctionDef) and n.name == 'select_theme_pack') self.node.decorator_list = [] - def play(self, cards, system, patched=True, audit=False, env=None): + def play(self, cards, system, patched=True, audit=False, env=None, hard=False): positions = [(300 + 300 * i, 300) for i in range(len(cards))] - weights = example_weights('theme_pack_list_cn') + weights = example_weights('theme_pack_list_cn', *(('theme_pack_list_hard_cn',) if hard else ())) lookups = [] def find_language_text(zh, en, crop): @@ -276,7 +276,7 @@ class UpstreamSelectThemePackTest(unittest.TestCase): if audit: ap.install_theme_pack_audit(log=self.lines.append) mirror_mod.Mirror(system) - mirror_mod.select_theme_pack(False, 4, 1, False) + mirror_mod.select_theme_pack(hard, 4, 1, False) self.assertEqual(theme_list.get_effective_theme_pack_list(), weights, '权重表的原方法必须还原') drag = auto.mouse_drag_down.call_args[0] picked = cards[positions.index(drag)] @@ -316,6 +316,14 @@ class UpstreamSelectThemePackTest(unittest.TestCase): # 普通模式: 复刻只在困难出现, 不算进「谋杀」这个键 self.assertEqual(kwargs['system_bonus'], {'packs': ['WARP快车谋杀案'], 'system': 'charge', 'from': -5, 'to': 1}) + def test_audit_keeps_a_key_with_a_space(self): + # 困难模式流血队: 复刻 WARP 专属流血 3 件, 用全名键「WARP快车谋杀案 复刻」; 审计不能截在空格前 + picked, record, _ = self.play(['钉与锤', 'WARP快车谋杀案 复刻'], 'bleed', audit=True, hard=True) + self.assertEqual(picked, 'WARP快车谋杀案 复刻') + args, kwargs = record.call_args + self.assertEqual(args, ('theme_pack', 'WARP快车谋杀案 复刻', 'preferred')) + self.assertEqual(kwargs['system_bonus']['to'], 1) + def test_audit_without_bonus_has_no_system_field(self): _, record, _ = self.play(self.FLOOR4, 'bleed', audit=True) self.assertNotIn('system_bonus', record.call_args[1])