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])