"""Extract declarative Orb recipes from explicit, previously decoded reference files.""" import argparse import hashlib import json from pathlib import Path p=argparse.ArgumentParser(description=__doc__) p.add_argument('--excel',type=Path,required=True) p.add_argument('--custom',type=Path,required=True) p.add_argument('--binary-sha256',required=True) p.add_argument('--output',type=Path,required=True) a=p.parse_args() if len(bytes.fromhex(a.binary_sha256))!=32: raise ValueError('Expected SHA256') excel=json.loads(a.excel.read_text(encoding='utf8')) custom=json.loads(a.custom.read_text(encoding='utf8')) orbs=[{'id':int(x['OrbID']),'bonus_id':int(x['BonusID'])} for x in excel['grid_fight_orb']] base=[{'id':int(x['BonusID']),'kind':x.get('BonusType',''),'amount':int(x.get('BonusTypeParam','0'))} for x in excel['grid_fight_basic_bonus']] recipes=[v for k,v in custom['config_files'].items() if k.startswith('Orb/') and v.get('Engine')=='Orb'] equipment=[{'id':int(x['ID']),'category':x.get('EquipCategory','')} for x in excel['grid_fight_equipment']] out={'format_version':1,'source_kind':'reference-server-authored-orb-recipes','binary_sha256':a.binary_sha256,'excel_json_sha256':hashlib.sha256(a.excel.read_bytes()).hexdigest(),'custom_json_sha256':hashlib.sha256(a.custom.read_bytes()).hexdigest(),'limitations':['Reference-authored recipes are not a claim of captured Client reward odds. Unsupported reward kinds are rejected without consuming an Orb.'], 'orbs':orbs,'basic_bonuses':base,'equipment':equipment,'recipes':recipes} a.output.write_text(json.dumps(out,indent=2,ensure_ascii=True)+'\n',encoding='utf8') print(json.dumps({'orbs':len(orbs),'basic_bonuses':len(base),'custom_recipes':len(recipes)}))