40 lines
2.2 KiB
Python
40 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Activate AVA2 biology items and quarantine legacy research events (cores/db must be stopped).
|
|
Original quest sources, role flags and unrelated item rows remain untouched.
|
|
"""
|
|
import json,shutil,sys
|
|
from pathlib import Path
|
|
server,assets,quest_stage,backup=map(Path,sys.argv[1:5])
|
|
if backup.exists():raise SystemExit('use a fresh backup directory')
|
|
backup.mkdir(parents=True)
|
|
conf=server/'share/conf'
|
|
for filename in ('item_proto.txt','item_names.txt'):
|
|
shutil.copy2(conf/filename,backup/filename)
|
|
items={int(line.split(b'\t')[0]):line for line in (assets/'items-server.tsv').read_bytes().splitlines()}
|
|
proto=conf/'item_proto.txt';output=[]
|
|
for line in proto.read_bytes().splitlines():
|
|
key=line.split(b'\t',1)[0]
|
|
if not key.isdigit() or int(key) not in items:output.append(line)
|
|
output.extend(items[k] for k in sorted(items))
|
|
proto.write_bytes(b'\n'.join(output)+b'\n')
|
|
names=conf/'item_names.txt';output=[]
|
|
for line in names.read_bytes().splitlines():
|
|
key=line.split(b'\t',1)[0]
|
|
if not key.isdigit() or int(key) not in items:output.append(line)
|
|
output.extend(str(k).encode()+b'\t'+items[k].split(b'\t')[1] for k in sorted(items))
|
|
names.write_bytes(b'\n'.join(output)+b'\n')
|
|
quest=server/'share/locale/newcibn/quest';manifest=[]
|
|
for file in sorted((quest/'object').rglob('*')):
|
|
if file.is_file() and (file.name.startswith('collect_quest_lv') or file.name.startswith('collect_quest_reset') or file.name.startswith('xxx_collect_quest_lv')):
|
|
relative=file.relative_to(quest);destination=backup/relative;destination.parent.mkdir(parents=True,exist_ok=True)
|
|
shutil.move(str(file),str(destination));manifest.append(str(relative))
|
|
# Reset item delegates to the same new UI, which validates persisted AVA2 bonus selections.
|
|
for file in sorted((quest_stage/'object').rglob('*')):
|
|
if file.is_file():
|
|
destination=quest/file.relative_to(quest_stage);destination.parent.mkdir(parents=True,exist_ok=True)
|
|
if destination.exists():
|
|
prior=backup/'reset-objects'/file.relative_to(quest_stage);prior.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(destination,prior)
|
|
shutil.copy2(file,destination)
|
|
(backup/'legacy-objects.json').write_text(json.dumps(manifest,indent=2)+'\n')
|
|
print('AVA2 items installed:',len(items),'legacy quest events quarantined:',len(manifest))
|