AALC 升级到 V1.6.1 并按零协汉化核对镜牢补丁

Browse Source
- vendor/aalc: e1d1749 -> 2fcb1b4(V1.6.1)。上游 8196e72 修好了商店三个清单的
  路径, 删掉本地 install_shop_lists, test_shop_lists 改成守着上游 5/19/31。
- 上游 18deb77 把事件里找 "???" 改成 find_element 后自己点, 原事件表补丁挂在
  click_element 上会悄悄失效。改挂 find_element, 上游拿返回位置再点的那下吞掉;
  小指良单通模式再找 "???" 时返回没有, 不会改点别的选项。
- 事件表改成按同一屏其它选项的原文认事件(零协汉化的事件数据没有标题), 选项原文
  照抄 LLC_zh-CN/ActionEvents_*.json 并带事件 id; 去掉 index 规则。核对后保留
  6 条, 删掉汉化里对不上或说法矛盾的 4 条(两个睡袋、浸染棉花、终末日历); 失明巨人
  是判定, 标 check。选项比较前去标点。
- 饰品关键词按零协汉化体系名核对, 删掉汉化里从未出现的 出血。
- 事件表、饰品排序安装时检查上游源码里还有被拦截的调用, 没有就记 [ERROR] 跳过;
  包装函数带 __wrapped__, 叠装时也能查到上游源码。
- BACKLOG 记录这次升级对各补丁的影响和核对结果。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yws
2026-11-14 08:43:27 +00:00
co-authored by Claude Opus 5.5
parent 51525722cd
commit 72d2ca1a5b
10 changed files with 410 additions and 345 deletions
+20 -77
View File
@@ -1,24 +1,21 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""镜牢商店"必买 / 必卖 / 公式合成"清单。 """镜牢商店"必买 / 必卖 / 公式合成"清单(BACKLOG P0-1)。
2026-11-14 实测: 上游 tasks/mirror/__init__.py 仍按 ./assets/images/share/... 列目录, 2026-11-14 实测: 上游 tasks/mirror/__init__.py 按旧路径 ./assets/images/share/... 列目录, 三个清单恒为空,
图片早已挪到 assets/images/<主题>/<语言>/ 下, 三个清单恒为空, 进店 51 秒一件没买。 进店 51 秒一件没买。上游 8196e72(V1.6.1) 改成按 assets/images/default/share/... 列, 本地补丁随之删掉;
这里守着上游别再退回空清单。
""" """
import os import os
import sys
import tempfile
import types import types
import unittest import unittest
from contextlib import contextmanager from contextlib import contextmanager
from pathlib import Path from pathlib import Path
from unittest import mock
REPO = Path(__file__).resolve().parents[1] REPO = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO))
from lc_mcp import aalc_patches # noqa: E402
AALC = REPO / 'vendor' / 'aalc' AALC = REPO / 'vendor' / 'aalc'
IMAGES = AALC / 'assets' / 'images' INIT = AALC / 'tasks' / 'mirror' / '__init__.py'
SHOP_LISTS = ('must_purchase', 'must_be_abandoned', 'fusion_result')
IMAGE_ROOTS = ('dark/zh_cn', 'dark/en', 'dark/share', 'default/zh_cn', 'default/en', 'default/share')
@contextmanager @contextmanager
@@ -31,89 +28,35 @@ def chdir(path):
os.chdir(old) os.chdir(old)
def as_tasks_mirror(package):
"""让 import tasks.mirror 拿到给定模块(父包也要在 sys.modules 里)。"""
parent = types.ModuleType('tasks')
parent.mirror = package
return mock.patch.dict(sys.modules, {'tasks': parent, 'tasks.mirror': package})
def upstream_mirror_package(): def upstream_mirror_package():
"""在 AALC 目录下执行上游 tasks/mirror/__init__.py, 得到它真实生成的三个列表。""" """在 AALC 目录下执行上游 tasks/mirror/__init__.py(任务进程的工作目录也是这里)。"""
module = types.ModuleType('tasks.mirror') module = types.ModuleType('tasks.mirror')
source = (AALC / 'tasks' / 'mirror' / '__init__.py').read_text(encoding='utf-8')
with chdir(AALC): with chdir(AALC):
exec(compile(source, str(AALC / 'tasks' / 'mirror' / '__init__.py'), 'exec'), module.__dict__) exec(compile(INIT.read_text(encoding='utf-8'), str(INIT), 'exec'), module.__dict__)
return module return module
@unittest.skipUnless(IMAGES.is_dir(), 'vendor/aalc 子模块未检出') @unittest.skipUnless(INIT.is_file(), 'vendor/aalc 子模块未检出')
class UpstreamShopListTest(unittest.TestCase): class UpstreamShopListTest(unittest.TestCase):
def test_upstream_lists_are_empty_and_patch_fills_them(self): def test_upstream_lists_are_filled(self):
package = upstream_mirror_package() package = upstream_mirror_package()
self.assertEqual([len(getattr(package, k)) for k in aalc_patches.SHOP_LISTS], [0, 0, 0], self.assertEqual([len(getattr(package, k)) for k in SHOP_LISTS], [5, 19, 31])
'上游已修好时可以删掉这个补丁') self.assertIn('mirror/shop/must_purchase/carmilla.png', package.must_purchase)
# in_shop 在导入时绑定的就是这几个列表对象
in_shop = types.SimpleNamespace(**{k: getattr(package, k) for k in aalc_patches.SHOP_LISTS})
lines = []
with as_tasks_mirror(package), chdir(AALC):
filled = aalc_patches.install_shop_lists(log=lines.append)
self.assertEqual(filled, {'must_purchase': 5, 'must_be_abandoned': 19, 'fusion_result': 31})
self.assertEqual([len(getattr(in_shop, k)) for k in aalc_patches.SHOP_LISTS], [5, 19, 31])
self.assertIn('mirror/shop/must_purchase/carmilla.png', in_shop.must_purchase)
self.assertIn('must_purchase=5', '\n'.join(lines))
def test_every_listed_name_resolves_under_some_image_root(self): def test_every_listed_name_resolves_under_some_image_root(self):
for kind in aalc_patches.SHOP_LISTS: package = upstream_mirror_package()
for name in aalc_patches.shop_list_images(kind, str(IMAGES)): images = AALC / 'assets' / 'images'
for kind in SHOP_LISTS:
for name in getattr(package, kind):
with self.subTest(name=name): with self.subTest(name=name):
self.assertTrue(any((IMAGES / root / name).is_file() for root in aalc_patches.IMAGE_ROOTS)) self.assertTrue(any((images / root / name).is_file() for root in IMAGE_ROOTS))
def test_local_roots_match_aalc_path_manager(self): def test_roots_match_aalc_path_manager(self):
source = (AALC / 'utils' / 'path_manager.py').read_text(encoding='utf-8') source = (AALC / 'utils' / 'path_manager.py').read_text(encoding='utf-8')
for root in aalc_patches.IMAGE_ROOTS: for root in IMAGE_ROOTS:
self.assertIn('"%s"' % root, source) self.assertIn('"%s"' % root, source)
class ShopListImagesTest(unittest.TestCase):
def setUp(self):
tmp = tempfile.TemporaryDirectory()
self.addCleanup(tmp.cleanup)
self.images = tmp.name
def put(self, root, kind, name):
folder = os.path.join(self.images, *root.split('/'), 'mirror', 'shop', kind)
os.makedirs(folder, exist_ok=True)
open(os.path.join(folder, name), 'wb').close()
def test_merges_themes_and_languages_without_duplicates(self):
self.put('default/share', 'must_purchase', 'b.png')
self.put('dark/share', 'must_purchase', 'b.png')
self.put('default/zh_cn', 'must_purchase', 'a.png')
self.put('default/share', 'must_purchase', 'notes.txt')
os.makedirs(os.path.join(self.images, 'default', 'share', 'mirror', 'shop', 'must_purchase', 'x.png'))
self.assertEqual(aalc_patches.shop_list_images('must_purchase', self.images),
['mirror/shop/must_purchase/a.png', 'mirror/shop/must_purchase/b.png'])
def test_missing_folders_give_an_empty_list(self):
self.assertEqual(aalc_patches.shop_list_images('fusion_result', self.images), [])
def test_non_empty_upstream_list_is_left_alone(self):
self.put('default/share', 'must_purchase', 'a.png')
package = types.SimpleNamespace(must_purchase=['upstream.png'], must_be_abandoned=[], fusion_result=[])
with as_tasks_mirror(package):
filled = aalc_patches.install_shop_lists(log=lambda m: None, images_dir=self.images)
self.assertEqual(package.must_purchase, ['upstream.png'])
self.assertEqual(filled, {'must_be_abandoned': 0, 'fusion_result': 0})
def test_import_failure_is_reported_not_raised(self):
lines = []
with mock.patch.dict(sys.modules, {'tasks': types.ModuleType('tasks'), 'tasks.mirror': None}):
self.assertEqual(aalc_patches.install_shop_lists(log=lines.append), {})
self.assertIn('商店清单补丁跳过', '\n'.join(lines))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()