367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
40 lines
2.8 KiB
Python
40 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Prepare bounded existing SpellShapeshift mask corrections, preserving full rows."""
|
|
from copy import deepcopy
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import struct
|
|
from spell_passive_compat import BUILD,SCHEMA,db2_header,encode
|
|
TABLE=0xbc91ea17
|
|
LAYOUT=0xe9111399
|
|
FIELDS=[('SpellID','int',32,False,1),('StanceBarOrder','int',8,False,1),('ShapeshiftExclude','int',32,False,2),('ShapeshiftMask','int',32,False,2)]
|
|
def prepare(component,native_rows):
|
|
if component.get('component')!='warrior-autostance-v1':raise ValueError('Pinned warrior component required')
|
|
ids={r['ability_spell']for r in component['abilities']}
|
|
if len(ids)!=component['count'] or len(ids)!=78:raise ValueError('Complete warrior ability catalogue required')
|
|
selected={};keys=set()
|
|
for row in native_rows:
|
|
# Validate the whole positive row before changing exactly two fields.
|
|
encode(row,FIELDS)
|
|
if row['ID'] in keys:raise ValueError('Duplicate native row identity')
|
|
keys.add(row['ID'])
|
|
if row['SpellID'] not in ids:raise ValueError('Bounded native ability export required')
|
|
if row['SpellID'] in selected:raise ValueError('Ambiguous native ability relationship')
|
|
selected[row['SpellID']]=row
|
|
records=[]
|
|
for spell,row in sorted(selected.items()):
|
|
original=deepcopy(row);updated=deepcopy(row)
|
|
updated['ShapeshiftMask']=[0,0];updated['ShapeshiftExclude']=[0,0]
|
|
body=encode(updated,FIELDS)
|
|
assert len(body)==21 and struct.unpack_from('<i',body)[0]==spell
|
|
records.append(dict(table_name='SpellShapeshift',table_hash=hex(TABLE),layout_hash=hex(LAYOUT),id=row['ID'],record=updated,original=original,wire_hex=body.hex(),sha256=hashlib.sha256(body).hexdigest()))
|
|
return dict(kind='source-warrior-native-stance-mask-clear-v1',build=BUILD,schema=SCHEMA,ability_count=len(ids),positive_native_rows=len(records),records=records,native_mask_rows_absent=sorted(ids-set(selected)),backend_required=True,installed=False,native_cast_emission_verified=False,policy='Clear only positive same-spell native masks; retain ID/SpellID/StanceBarOrder. Absent child rows are reported without inventing a row or treating absence as runtime acceptance.')
|
|
if __name__=='__main__':
|
|
p=argparse.ArgumentParser();p.add_argument('--component',type=Path,required=True);p.add_argument('--native',type=Path,required=True);p.add_argument('--db2',type=Path,required=True);p.add_argument('--output',type=Path,required=True);a=p.parse_args()
|
|
db2_header(a.db2,TABLE,LAYOUT)
|
|
out=prepare(json.loads(a.component.read_text()),json.loads(a.native.read_text()))
|
|
out['pins']={str(q):hashlib.sha256(q.read_bytes()).hexdigest()for q in (a.component,a.native,a.db2)}
|
|
a.output.write_text(json.dumps(out,indent=2)+'\n')
|