1888 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
38 lines
5.5 KiB
Python
38 lines
5.5 KiB
Python
"""All source-shape-valid restorative roots; source overrides remain authoritative."""
|
|
from pathlib import Path
|
|
import sys,json,struct,hashlib,copy
|
|
sys.path.insert(0,'ops')
|
|
import spell_restore_compat as restore,spell_item_proc_compat as proc,spell_passive_compat as codec
|
|
from spell_definition_common import REQUIRED_REFERENCE_TABLES,review_proc_override_snapshot
|
|
from content_package_stage import compose_existing_proc_corrections
|
|
from item_sparse_compat import package_pages
|
|
from local_tortoise import db
|
|
W=Path(__file__).resolve().parent;load=lambda p:json.loads(Path(p).read_text());family=load(W/'source-family-review.json');roots=[r for r in family['rows']if r['status']=='source-shape-validated'];ids=sorted({s['entry']for r in roots for s in r['normalized_sources']});N=Path('../servers/trinity-forever/install/bin/dbc/enUS');D=Path('../tools/WoWDBDefs/definitions');base=load('docs/evidence/data/item-sparse-compat/package.json');package=copy.deepcopy(base)
|
|
native={t:load(W/'family-references'/(t+'.json'))for t in(*REQUIRED_REFERENCE_TABLES,'SpellDuration')}
|
|
for row in base['rows']:
|
|
if row['table_name']in native and row['record'].get('SpellID',row['id']if row['table_name']in('Spell','SpellName')else None)in ids:
|
|
a=native[row['table_name']];a[:]=[r for r in a if r['ID']!=row['id']];a.append(dict(row['record'],ID=row['id']))
|
|
tables=('Spell','SpellLevels','SpellEffect','SpellCategories','SpellName','SpellMisc','SpellAuraOptions');schemas={t:codec.fields(D/(t+'.dbd'),t)for t in tables};maxima={};reserved=[]
|
|
for p in ('docs/evidence/data/item-sparse-compat/package.json','runtime/all-class-equipment-variants-20261020/package.json','runtime/all-class-equipment-variants-20261020/native-family-package.json'):reserved.extend(load(p)['rows'])
|
|
for table in tables:
|
|
with (N/(table+'.db2')).open('rb')as f:maximum=struct.unpack_from('<I',f.read(168),164)[0]
|
|
maxima[table]=max([maximum]+[r['id']for r in reserved if r['table_name']==table])
|
|
columns=['entry','SchoolMask','SpellFamilyName','SpellFamilyMask0','SpellFamilyMask1','SpellFamilyMask2','procFlags','procEx','ppmRate','CustomChance','Cooldown'];query='SELECT '+','.join('`'+c+'`'for c in columns)+' FROM tw_world.spell_proc_event WHERE entry IN('+','.join(map(str,ids))+') ORDER BY entry;';a=db(query);b=db(query);assert a==b
|
|
allrows=[{k:float(v)if k=='ppmRate'else int(v)for k,v in zip(columns,line.split('\t'))}for line in a.splitlines()];reports=[];registry=dict(schema_version=1,build=codec.BUILD,SpellEffect={});components=[]
|
|
def apply(component,component_schemas):
|
|
global package
|
|
result=compose_existing_proc_corrections(package,component,component_schemas);package.update(rows=result['rows'],push_id=result['push_id'],pushes=package_pages(result['rows']))
|
|
for row in component['records']:
|
|
table=native[row['table_name']]
|
|
table[:]=[r for r in table if r['ID']!=row['id']];table.append(dict(row['record'],ID=row['id']))
|
|
return result['added_count']
|
|
for root in roots:
|
|
sources=root['normalized_sources'];local_ids=[s['entry']for s in sources];parent=next(s for s in sources if s['entry']==root['spell_id']);children=[s for s in sources if s['entry']!=root['spell_id']];missing=sorted(set(local_ids)-{r['ID']for r in native['SpellName']})
|
|
if missing:reports.append(dict(spell_id=root['spell_id'],status='new-definition-dependency',missing_native_ids=missing,item_users=root['item_users']));continue
|
|
overrides=dict(kind='local-source-proc-override-snapshot',table='tw_world.spell_proc_event',source_spell_ids=sorted(local_ids),columns=columns,two_reads_equal=True,database_modified=False,rows=[r for r in allrows if r['entry']in local_ids]);override_review=review_proc_override_snapshot(overrides,local_ids)
|
|
print('Review root',root['spell_id'],'children',[s['entry']for s in children],'category rows',[(r['ID'],r['SpellID'])for r in native['SpellCategories']],flush=True)
|
|
child_schemas={t:schemas[t]for t in('Spell','SpellLevels','SpellEffect','SpellCategories')};child=restore.component(children,native,child_schemas,maxima,registry);registry=child['child_id_registry'];added_child=apply(child,child_schemas)
|
|
parent_component=proc.existing_restoration_component(sources,native,schemas,proc_proof=parent['proc_context']['proof']if 'proof'in parent.get('proc_context',{})else load(W/'restore-parent-component.json')['inputs']['proc_proof'],proc_overrides=overrides,duration_reference=dict(source_duration_id=21,target_duration_id=21,duration_ms=-1,max_duration_ms=-1,source_duration_per_level=0,target_duration_per_resource=0,permanent=True),presentation_only=not override_review['overrides_absent']);added_parent=apply(parent_component,schemas)
|
|
components.extend([child,parent_component]);reports.append(dict(spell_id=root['spell_id'],status='staged-reviewed-existing-family',child_added=added_child,parent_added=added_parent,source_override_rows=overrides['rows'],item_users=root['item_users']))
|
|
(W/'restorative-family-package.json').write_text(json.dumps(package,sort_keys=True,separators=(',',':'))+'\n');(W/'restorative-family-components.json').write_text(json.dumps(components,indent=2)+'\n');report=dict(kind='all-source-restorative-proc-family-staging',source_spell_count=family['source_spell_count'],source_scope=family['scope_count'],source_shape_validated=family['source_shape_validated'],preserved_rows=len(base['rows']),rows=len(package['rows']),added_rows=len(package['rows'])-len(base['rows']),families=reports,child_registry=registry,allocation_floors=maxima,installed=False,engine_accepted=False,gameplay_verified=False);(W/'restorative-family-stage.json').write_text(json.dumps(report,indent=2)+'\n');print(json.dumps(report,indent=2))
|