33 lines
1.6 KiB
Python
33 lines
1.6 KiB
Python
"""Import bounded, identity-checked current Client monster row captures."""
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
|
|
p = argparse.ArgumentParser(description=__doc__)
|
|
for name in ('capture', 'catalog', 'output'):
|
|
p.add_argument('--' + name, type=Path, required=True)
|
|
a = p.parse_args()
|
|
capture = json.loads(a.capture.read_text(encoding='utf-8-sig'))
|
|
catalog = json.loads(a.catalog.read_text(encoding='utf-8-sig'))
|
|
rows = {}
|
|
for item in capture['rows']:
|
|
row = item['row']
|
|
key = item['requested_id']
|
|
if key != row['MonsterID'] or key in rows or not key:
|
|
raise ValueError('Monster row identity differs/duplicated')
|
|
for star in range(1, 5):
|
|
if row['Star' + str(star) + 'EliteGroup3'] <= 0:
|
|
raise ValueError('Monster star group missing')
|
|
rows[key] = row
|
|
if len(set(capture['plan'])) != len(capture['plan']) or set(rows) != set(capture['plan']):
|
|
raise ValueError('Incomplete monster capture plan')
|
|
result = dict(format_version=1, target_client_version=catalog['client_version'],
|
|
target_assembly_sha256=catalog['provenance']['game_assembly_sha256'],
|
|
source_capture_sha256=hashlib.sha256(a.capture.read_bytes()).hexdigest(),
|
|
scope='Current saved run camps and its reference encounter camp only; not all monster rows.',
|
|
encounter_camp_policy='uniform_compatible_active_camp_same_tier',
|
|
entries=[rows[k] for k in sorted(rows)])
|
|
a.output.write_text(json.dumps(result, indent=2) + '\n', encoding='utf-8')
|
|
print('Exported', len(rows), 'current monster rows')
|