Files
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

94 lines
6.5 KiB
Python

#!/usr/bin/env python3
"""Compare Source Warrior point spells with pinned native trait records.
Trait identities require unique identical base spells and maximum point ranks.
The successor profile separately uses Source trained actions as point-rank proof;
it never changes spell identity, known spells, talent limits, or server state.
"""
import hashlib
import json
from pathlib import Path
import struct
import argparse
from turtle_data import spell_layout,DBC as SourceDBC,read_spell_chain,validated_talent_rank_successors
ROOT=Path(__file__).resolve().parents[1]
DBC=Path.home()/'Servers/tortoise-docker/data/dbc'
inputs={}
def dbc(name,fields=None):
path=DBC/(name+'.dbc');b=path.read_bytes();inputs[str(path)]=hashlib.sha256(b).hexdigest()
m,n,f,s,z=struct.unpack_from('<4s4I',b)
if m!=b'WDBC' or s!=f*4 or (fields and f!=fields) or len(b)!=20+n*s+z:raise ValueError('Unexpected '+name+' schema')
strings=b[20+n*s:]
return [struct.unpack_from('<'+str(f)+'I',b,20+i*s) for i in range(n)],strings
def modern(name):
path=ROOT/'runtime'/('forever-'+name+'.json');b=path.read_bytes();inputs[str(path.relative_to(ROOT))]=hashlib.sha256(b).hexdigest()
return {r['ID']:r for r in json.loads(b)}
def write_successor_profile(source_dir,chain_path,header_path,report_path,*,talent_tab_path=None):
"""Emit Source action-upgrade aliases for all eligible talent point spells."""
source_dir=Path(source_dir)
paths={name:source_dir/(name+'.dbc') for name in ['Talent','TalentTab','SkillLineAbility','Spell']}
if talent_tab_path:paths['TalentTab']=Path(talent_tab_path)
tables={name:SourceDBC(paths[name],fields) for name,fields in
[('Talent',21),('TalentTab',15),('SkillLineAbility',15),('Spell',173)]}
chains=read_spell_chain(chain_path,include_previous=True) if chain_path else ()
resolved,held=validated_talent_rank_successors(tables['Talent'],tables['SkillLineAbility'],tables['Spell'],chains,talent_tabs=tables['TalentTab'])
pairs=[(root,learned) for root,values in resolved.items() for learned in values]
text='// Generated by ops/export_talent_map.py; Source trained actions prove talent point spells.\n'
text+='// Point rank comes from Talent.dbc rank position, never trained action rank/count.\n'
text+='struct TalentRankSuccessor { uint32_t rank_spell, learned_spell; };\n'
text+='inline constexpr TalentRankSuccessor TalentRankSuccessors[] = {\n'
text+=''.join('{'+str(root)+','+str(learned)+'},\n' for root,learned in pairs)+'};\n'
Path(header_path).write_text(text)
sources=list(paths.values())
if chain_path:sources.append(Path(chain_path))
report=dict(policy='Source forward/server chains; same SkillLine and class; exact Talent point rank, no grants',
talent_count=len(tables['Talent'].rows),point_spell_roots=len(resolved),successor_pairs=len(pairs),
inputs={str(p):hashlib.sha256(p.read_bytes()).hexdigest() for p in sources},
resolved=resolved,held=held,header=str(header_path))
Path(report_path).write_text(json.dumps(report,indent=2)+'\n')
return report
def main():
global DBC
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--source-dbc-dir',type=Path,default=DBC)
parser.add_argument('--spell-chain-tsv',type=Path)
parser.add_argument('--talent-tab-dbc',type=Path,help='Explicit cached Source TalentTab when stored separately from the spell DBC cohort')
parser.add_argument('--successors-only',action='store_true',help='Generate only the shared Source trained-action profile; no modern trait exports required')
parser.add_argument('--successor-header',type=Path,default=ROOT/'include/gateway/talent_rank_successors.hpp')
parser.add_argument('--successor-report',type=Path,default=ROOT/'runtime/talent-rank-successors.json')
args=parser.parse_args();DBC=args.source_dbc_dir
report=write_successor_profile(DBC,args.spell_chain_tsv,args.successor_header,args.successor_report,talent_tab_path=args.talent_tab_dbc)
if args.successors_only:
print('Resolved',report['successor_pairs'],'Source trained-action aliases;',len(report['held']),'explicit holds.')
return
rows,strings=dbc('TalentTab',15);tabs={r[0]:r for r in rows}
rows,_=dbc('Talent',21);spells,spell_strings=dbc('Spell');spells={r[0]:r for r in spells}
nodes,entries,definitions,joins=(modern(t) for t in ('TraitNode','TraitNodeEntry','TraitDefinition','TraitNodeXTraitNodeEntry'))
by_spell={}
for join in joins.values():
node=nodes[join['TraitNodeID']];entry=entries[join['TraitNodeEntryID']]
if node['TraitTreeID']!=1117:continue # Audited actual Warrior tree, not retail Arms71.
spell=definitions[entry['TraitDefinitionID']]['SpellID']
by_spell.setdefault(spell,[]).append((node['ID'],entry['ID'],entry['MaxRanks']))
out=[]
for r in rows:
tab=tabs[r[1]]
if tab[12]!=1:continue
ranks=list(r[4:9]);rank_count=sum(bool(s) for s in ranks)
matches=by_spell.get(ranks[0],[])
match=matches[0] if len(matches)==1 and matches[0][2]==rank_count else None
spell=spells[ranks[0]]
name=spell_strings[spell[spell_layout()['Name_lang']]:].split(b'\0')[0].decode()
out.append({'id':r[0],'tab':r[1],'tree':strings[tab[1]:].split(b'\0')[0].decode(),'row':r[2],'column':r[3],'name':name,'spells':ranks,'prerequisite':r[13],'prerequisite_rank':r[16],'required_spell':r[20],'node':match[0] if match else 0,'entry':match[1] if match else 0,'native_position':{'x':nodes[match[0]]['PosX'],'y':nodes[match[0]]['PosY']} if match else None,'candidates':matches})
out.sort(key=lambda r:r['id'])
document={'class':1,'specialization':1491,'trait_tree':1117,'identity_policy':'unique equal base spell ID and equal maximum rank count; semantics/tooltips require separate comparison','inputs_sha256':inputs,'talents':out}
(ROOT/'docs/evidence/gameplay/turtle-warrior-talents.json').write_text(json.dumps(document,indent=2)+'\n')
header='// Generated by ops/export_talent_map.py from local DBC/DB2; no numeric-ID passthrough.\n'
header+='inline constexpr TalentMapping WarriorTalentMappings[] = {\n'
for r in out:
header+='{'+','.join(str(r[k]) for k in ('id','tab','row','column','prerequisite','prerequisite_rank','required_spell','node','entry'))+', {'+','.join(map(str,r['spells']))+'}},\n'
header+='};\n'
(ROOT/'include/gateway/talent_profile.hpp').write_text(header)
print('Exported',len(out),'real Turtle Warrior talents;',sum(bool(r['node']) for r in out),'share a unique Forever node and rank limit.')
if __name__=='__main__':main()