367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
86 lines
8.9 KiB
Python
86 lines
8.9 KiB
Python
"""Separate missing-parent item caster percentage policy; no rating conversion.
|
|
|
|
The existing new_static_component swim/school policy remains separate.
|
|
"""
|
|
from copy import deepcopy
|
|
from pathlib import Path
|
|
import hashlib,re
|
|
from octo_client_data import canonical_sha256
|
|
from item_batch_stage import available_index
|
|
from spell_definition_common import REQUIRED_REFERENCE_TABLES,NEW_DEFINITION_CHILD_TABLES,review_new_timing,new_definition_records
|
|
from spell_passive_compat import BUILD,SCHEMA,NEW_EFFECT_NEUTRAL,NEW_MISC_NEUTRAL,new_registry_values,verified_spell_icon
|
|
import spell_item_static_compat as static
|
|
POLICY='new-item-caster-percent-definition-candidate-v1'
|
|
KIND='source-item-caster-percent-definition-candidates'
|
|
PINS={'source_header':'ed7f67babe916cbbf91f7a1f1a9a9af694a2469d2e07eb10e94f0ae883678cb8','target_header':'1784b495ea9704bbe12223c2ad42d9d5fea7d320f0dc6c0055cd090cb7e5498b','source_consumer':'b16e4b33bf8c732aacade833a057290daf37c1823aacab7cda159925ef0f156b','target_consumer':'482a7e2ed7091ae34ac660aba5a0a0bcd614b88b1311ead7859aeeb841df8fc3','source_stats':'b6eb7f28ac53c1b1d9b2e2328562110fd3a684af334268ccec0b1b5fa7271ba2','target_stats':'291a06e8fc5e285e3b7311e46f276472f19d7447167c149424b5f2051af7360a'}
|
|
AURAS={'spell-hit':('SPELL_AURA_MOD_SPELL_HIT_CHANCE',55),'spell-crit':('SPELL_AURA_MOD_SPELL_CRIT_CHANCE',57)}
|
|
def contract():return dict(policy='named-flat-caster-percentage-points-v1',sha256=dict(PINS),auras={k:dict(source_name=n,target_name=n,source_value=v,target_value=v)for k,(n,v)in AURAS.items()},units='percentage-points',rating_conversion=False,source_base_point_adjustment=1,server_gameplay_equivalence_claimed=False)
|
|
def namespace(paths):
|
|
if set(paths)!=set(PINS):raise ValueError('Complete named caster percentage proof required')
|
|
texts={}
|
|
for key,p in paths.items():
|
|
raw=Path(p).read_bytes()
|
|
if hashlib.sha256(raw).hexdigest()!=PINS[key]:raise ValueError('Pinned caster percentage input changed: '+key)
|
|
texts[key]=raw.decode()
|
|
for name,value in AURAS.values():
|
|
for role in('source_header','target_header'):
|
|
if not re.search(r'\b'+name+r'\s*=\s*'+str(value)+r'\s*,',texts[role]):raise ValueError('Named caster aura differs')
|
|
for role,fragment in [('source_consumer','GetTarget()->m_modSpellHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount);'),('target_consumer','target->m_modSpellHitChance += (apply) ? GetAmount() : (-GetAmount());'),('source_stats','crit += GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE);'),('target_stats','crit += GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE);'),('target_stats','m_modSpellHitChance = GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE);')]:
|
|
if fragment not in texts[role]:raise ValueError('Named caster percentage consumer differs: '+role)
|
|
return contract()
|
|
def validate_source(src,percent_stat,semantics):
|
|
if not isinstance(semantics,dict)or canonical_sha256(semantics)!=canonical_sha256(contract())or percent_stat not in AURAS:raise ValueError('Separate named caster percent policy required')
|
|
if not isinstance(src,dict)or set(src)!={'entry','name','nameSubtext','description','auraDescription','school','castingTimeIndex','durationIndex','rangeIndex','speed','spellIconId','attributes','equippedItem','conditions','timing','power','visuals','effects','levels','class_family'}:raise ValueError('Exact neutral caster source shape required')
|
|
indices=static.validate_source(src,percent_stat=percent_stat)
|
|
if any(src['levels'].values())or src['conditions']['procChance']not in(0,101):raise ValueError('New caster percent requires zero source levels and no-proc chance0/101')
|
|
return indices
|
|
|
|
def description_fields(src,percent_stat,semantics):
|
|
validate_source(src,percent_stat,semantics)
|
|
return {k:re.sub(r'\$s([123])(?![0-9])',lambda m:str(src['effects'][int(m[1])-1][2]+1),src[k])for k in('description','auraDescription')}
|
|
|
|
def review(component,spell):
|
|
stat=component.get('percent_stat');proof=component.get('semantic_contract');src=spell.get('source_definition')
|
|
if not isinstance(src,dict)or src.get('entry')!=spell.get('spell_id')or canonical_sha256(src)!=spell.get('source_record_sha256'):raise ValueError('Pinned caster percentage source required')
|
|
indices=validate_source(src,stat,proof)
|
|
if spell.get('effect_indices')!=indices or any(spell.get(k)!=src[k]for k in('class_family','levels'))or spell.get('percent_stat')!=stat:raise ValueError('Caster percentage source metadata differs')
|
|
return indices
|
|
|
|
def review_record(src,spell,row,percent_stat,semantics):
|
|
indices=validate_source(src,percent_stat,semantics);table=row['table_name'];record=row['record'];i=row['id'];ident=src['entry'];expected=None
|
|
if table=='SpellName':expected=dict(ID=i,Name_lang=src['name'])
|
|
elif table=='Spell':
|
|
text=description_fields(src,percent_stat,semantics);expected=dict(ID=i,NameSubtext_lang=src['nameSubtext'],Description_lang=text['description'],AuraDescription_lang=text['auraDescription'])
|
|
if row.get('constant_description_policy')!=POLICY:raise ValueError('Caster percentage presentation policy differs')
|
|
elif table=='SpellMisc':expected=dict(NEW_MISC_NEUTRAL,ID=i,SpellID=ident,Attributes=src['attributes']+[0]*12,SpellIconFileDataID=spell['icon_asset']['file_data_id'],DurationIndex=21,SchoolMask=1)
|
|
elif table=='SpellEquippedItems':expected=dict(ID=i,SpellID=ident,EquippedItemClass=src['equippedItem'][0],EquippedItemSubclass=src['equippedItem'][1],EquippedItemInvTypes=src['equippedItem'][2])
|
|
elif table=='SpellEffect':
|
|
index=record.get('EffectIndex')
|
|
if type(index)is not int or index not in indices:raise ValueError('Caster percentage effect slot differs')
|
|
e=src['effects'][index];expected=dict(NEW_EFFECT_NEUTRAL,ID=i,SpellID=ident,EffectIndex=index,EffectAura=e[1],EffectBasePointsF=e[2]+1,EffectMiscValue=[0,0])
|
|
else:raise ValueError('Unreviewed caster percentage child table')
|
|
if record!=expected:raise ValueError('Caster percentage source/native row differs: '+table)
|
|
return True
|
|
|
|
def component(sources,native,schemas,maxima,registry,*,percent_stat,semantics,source_tables,target_icon_names,new_icon_ids,icon_assets,read_icon):
|
|
if not isinstance(sources,list)or not 1<=len(sources)<=4096 or len({s['entry']for s in sources})!=len(sources):raise ValueError('Distinct bounded caster percentage sources required')
|
|
if any(t not in native for t in(*REQUIRED_REFERENCE_TABLES,'SpellCastTimes','SpellDuration','SpellRange')):raise ValueError('Complete caster percentage native references required')
|
|
if any(t not in schemas or t not in maxima for t in('Spell','SpellName',*NEW_DEFINITION_CHILD_TABLES)):raise ValueError('Complete caster percentage schema/allocation context required')
|
|
if set(source_tables)!={'SpellIcon','SpellCastTimes','SpellDuration','SpellRange'}or set(new_icon_ids)!={str(s['entry'])for s in sources}or not callable(read_icon):raise ValueError('Explicit caster percentage dependencies/icons required')
|
|
review_new_timing(source_tables,native,21);available=available_index(icon_assets);registry=deepcopy(registry)
|
|
if registry.get('SkillLineAbility'):raise ValueError('No learned-spell links for caster percentage definitions')
|
|
occupied={t:{r['ID']for r in native[t]}for t in NEW_DEFINITION_CHILD_TABLES};new_registry_values(registry,maxima,occupied,tables=NEW_DEFINITION_CHILD_TABLES);rows=[];spells=[]
|
|
for src in sorted(sources,key=lambda s:s['entry']):
|
|
indices=validate_source(src,percent_stat,semantics);ident=src['entry']
|
|
for t in REQUIRED_REFERENCE_TABLES:
|
|
if any((r.get('ID')if t in('Spell','SpellName')else r.get('SpellID'))==ident for r in native[t]):raise ValueError('Caster percentage has a positive native reference: '+t)
|
|
fid,asset=verified_spell_icon(src,new_icon_ids,source_tables['SpellIcon'],target_icon_names,available,read_icon)
|
|
effects={i:dict(deepcopy(NEW_EFFECT_NEUTRAL),EffectAura=src['effects'][i][1],EffectBasePointsF=src['effects'][i][2]+1,EffectMiscValue=[0,0])for i in indices}
|
|
shown=dict(deepcopy(src),**description_fields(src,percent_stat,semantics));created=new_definition_records(shown,effects,fid,schemas,maxima,registry,occupied,allocation_prefix='new-item-caster-percent-definition')
|
|
for r in created:
|
|
if r['table_name']=='Spell':r['constant_description_policy']=POLICY
|
|
metadata=dict(spell_id=ident,source_definition=deepcopy(src),source_record_sha256=canonical_sha256(src),effect_indices=indices,icon_asset=dict(asset,file_data_id=fid),class_family=deepcopy(src['class_family']),levels=deepcopy(src['levels']),percent_stat=percent_stat,filtered_reference_absence_only=True,installed_definition_absence_verified=False,known_spells_modified=False,engine_accepted=False,gameplay_verified=False)
|
|
for row in created:review_record(src,metadata,row,percent_stat,semantics)
|
|
rows+=created;spells.append(metadata)
|
|
return dict(kind=KIND,build=BUILD,schema=SCHEMA,definition_policy=POLICY,percent_stat=percent_stat,semantic_contract=semantics,records=rows,spells=spells,child_id_registry=registry,id_remapping=False,dependency_complete=False,installable=False,installed=False,engine_accepted=False,gameplay_verified=False)
|