This website requires JavaScript.
0
Issues
Pull Requests
Milestones
Explore
0
Create…
New Repository
New Migration
New Organization
public
Signed in as
public
Profile
Starred
Subscriptions
Settings
Help
Sign Out
yws
/
lc-mcp
Watch
1
Star
0
Fork
0
Code
Issues
Pull Requests
Actions
Packages
Projects
Releases
Wiki
Activity
Files
lc-mcp
/
scripts
/
or
Cancel
Edit File
Preview
Preview Changes
Spaces
Tabs
2
4
8
Wrap
No wrap
# -*- coding: utf-8 -*- """生成 lc_mcp/data/theme_pack_systems.json: 镜牢卡包 → 体系(BACKLOG R-01)。 用法: python scripts/build_theme_pack_systems.py <LLC_zh-CN 目录> <LLC EN 目录> [-o 输出文件] 两个目录分别是零协汉化的中文包(游戏里的 LimbusCompany_Data/Lang/LLC_zh-CN, 或 release 解压出来的同名目录) 和 LocalizeLimbusCompany 仓库里的 EN 目录, 只用其中的 MirrorDungeonTheme*.json(卡包 id → 名字)。 卡包数据来自 Limbus Company Wiki(https://limbuscompany.wiki.gg, CC BY-SA 4.0), 运行时在线读取: - 各卡包条目的 {{ThemePackInfo}}: 出现楼层(normal/hard)、专属饰品(unique); - 条目里「Featured Gifts」用的饰品分类: 是体系名(Burn/Charge/...)的就是体系包; - Module:EgoGift/data: 每件饰品的体系(category)。 边狱巴士 BWIKI(wiki.biligame.com/limbuscompany)2026-11-15 查过: 699 个页面里没有卡包条目, 所以不用它。 """ import argparse import glob import json import os import re import sys import time import urllib.parse import urllib.request API = 'https://limbuscompany.wiki.gg/api.php' RAW = 'https://limbuscompany.wiki.gg/index.php' USER_AGENT = 'research-script/1.0 (python-urllib)' CATEGORY = 'Category:Floor Theme Pack Pages' SYSTEMS = {'Burn': 'burn', 'Bleed': 'bleed', 'Tremor': 'tremor', 'Rupture': 'rupture', 'Sinking': 'sinking', 'Poise': 'poise', 'Charge': 'charge', 'Slash': 'slash', 'Pierce': 'pierce', 'Blunt': 'blunt'} # 零协 EN 文件里还没有英文名、或者写法和 wiki 条目名不一样的卡包 EN_OVERRIDES = { 1028: 'Storefront Campout', 1029: 'An Anarchy of Colors', 1030: 'Creed of Preservation', 1031: 'Readvent of Gluttony', 1111: 'Line 4 - Section 3', 1112: 'Line 4 - Section 4', 1129: 'The Wedge in the Wake of Dawnbreak', } def fetch(url, params): request = urllib.request.Request(url + '?' + urllib.parse.urlencode(params), headers={'User-Agent': USER_AGENT}) with urllib.request.urlopen(request, timeout=60) as response: return response.read().decode('utf-8') def theme_pack_pages(): titles, cont = [], {} while True: data = json.loads(fetch(API, {'action': 'query', 'list': 'categorymembers', 'cmtitle': CATEGORY, 'cmlimit': '500', 'format': 'json', **cont})) titles += [m['title'] for m in data['query']['categorymembers'] if m['title'].endswith(' Theme Pack')] if 'continue' not in data: break cont = {'cmcontinue': data['continue']['cmcontinue']} pages = {} for i in range(0, len(titles), 40): data = json.loads(fetch(API, {'action': 'query', 'prop': 'revisions', 'rvprop': 'content', 'rvslots': 'main', 'titles': '|'.join(titles[i:i + 40]), 'format': 'json', 'formatversion': '2'})) for page in data['query']['pages']: if 'revisions' in page: pages[page['title'][:-len(' Theme Pack')]] = page['revisions'][0]['slots']['main']['content'] time.sleep(1) return pages def gift_categories(): lua = fetch(RAW, {'title': 'Module:EgoGift/data', 'action': 'raw'}) gifts = {} for match in re.finditer(r'^\s*\["([^"]+)"\]\s*=\s*\{(.*)\},?\s*$', lua, re.M): category = re.search(r'category\s*=\s*"([^"]*)"', match.group(2)) gifts[match.group(1)] = category.group(1) if category else None return gifts def parse_pack(text, gifts): info = re.search(r'\{\{ThemePackInfo(.*?)\n\}\}', text, re.S) fields = dict(re.findall(r'\|\s*(\w+)\s*=\s*([^\n|]*)', info.group(1))) if info else {} unique = {} for gift in (g.strip() for g in fields.get('unique', '').split(';')): category = gifts.get(gift, gifts.get(gift.replace("'", '’'))) if gift else None if category in SYSTEMS: unique[SYSTEMS[category]] = unique.get(SYSTEMS[category], 0) + 1 featured = sorted({SYSTEMS[c] for c in re.findall(r'\{\{#invoke:GiftList\|Category\|([^}|]+)\}\}', text) if c in SYSTEMS}) return {'normal': fields.get('normal', '').replace(' ', ''), 'hard': fields.get('hard', '').replace(' ', ''), 'featured': featured, 'unique': dict(sorted(unique.items()))} def theme_names(directory): names = {} for path in glob.glob(os.path.join(directory, 'MirrorDungeonTheme*.json')): with open(path, encoding='utf-8-sig') as fh: for entry in json.load(fh).get('dataList', []): names[entry['id']] = entry.get('name', '') return names def key(name): return re.sub(r'[^0-9a-z]', '', name.lower()) def build(zh_dir, en_dir): zh, en = theme_names(zh_dir), theme_names(en_dir) en.update(EN_OVERRIDES) gifts = gift_categories() wiki = {key(title): (title, parse_pack(text, gifts)) for title, text in theme_pack_pages().items()} packs, unmatched = [], [] for pack_id in sorted(zh): title, data = wiki.get(key(en.get(pack_id, '')), (None, None)) if data is None: unmatched.append('%d %s' % (pack_id, zh[pack_id])) continue packs.append({'id': pack_id, 'zh': zh[pack_id], 'en': title, **data}) return packs, unmatched def _rows(items, indent): return ['%s%s%s' % (indent, json.dumps(item, ensure_ascii=False), ',' if i < len(items) - 1 else '') for i, item in enumerate(items)] def dump_table(table): """写回 JSON: 卡包和社区条目每条一行, 好看 diff。""" notes = json.dumps(table['_说明'], ensure_ascii=False, indent=1).replace('\n', '\n ') lines = ['{', ' "_说明": %s,' % notes, ' "bonus": %s,' % json.dumps(table['bonus'], ensure_ascii=False)] community = table.get('community') if community: lines += [' "community": {', ' "_说明": %s,' % json.dumps(community['_说明'], ensure_ascii=False, indent=1).replace('\n', '\n '), ' "recommend": ['] + _rows(community['recommend'], ' ') + \ [' ],', ' "avoid": ['] + _rows(community['avoid'], ' ') + [' ]', ' },'] lines += [' "packs": ['] + _rows(table['packs'], ' ') + [' ]', '}'] return '\n'.join(lines) + '\n' def main(argv): parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('zh_dir') parser.add_argument('en_dir') parser.add_argument('-o', '--output', default=os.path.join(os.path.dirname(__file__), '..', 'lc_mcp', 'data', 'theme_pack_systems.json')) args = parser.parse_args(argv) packs, unmatched = build(args.zh_dir, args.en_dir) with open(args.output, encoding='utf-8') as fh: table = json.load(fh) # 保留手写的 _说明、bonus、community, 只换 packs table['packs'] = packs with open(args.output, 'w', encoding='utf-8') as fh: fh.write(dump_table(table)) print('卡包 %d 个写入 %s' % (len(packs), args.output)) if unmatched: print('wiki 上没对上的: %s' % ', '.join(unmatched)) return 0 if __name__ == '__main__': sys.exit(main(sys.argv[1:]))
Commit Changes
Add a Signed-off-by trailer by the committer at the end of the commit log message.
Commit directly to the
codex/feedback-unattended-setup-20261004
branch.
Create a
new branch
for this commit and start a pull request.
Commit Changes
Cancel