367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
55 lines
4.7 KiB
Python
55 lines
4.7 KiB
Python
"""All-six-magic-school source crit71 maps to existing native global spell crit57.
|
|
|
|
Single-school source masks retain their explicit hold; no rating conversion.
|
|
"""
|
|
from copy import deepcopy
|
|
from pathlib import Path
|
|
import hashlib,re
|
|
from octo_client_data import canonical_sha256
|
|
import spell_item_static_compat as static
|
|
POLICY='positive-all-magic-school-spell-crit-v1'
|
|
PINS={'source_aura': 'ed7f67babe916cbbf91f7a1f1a9a9af694a2469d2e07eb10e94f0ae883678cb8', 'target_aura': '1784b495ea9704bbe12223c2ad42d9d5fea7d320f0dc6c0055cd090cb7e5498b', 'source_schools': 'fd1c65c0266b77a310c066bc3ccce86fe39f73a6cd10f67192d419009f95ead1', 'target_schools': '9b0e2ad90eea77c961b00f1fc482e9d9e521aa85c58b63863a35d3a338a31799', 'source_stats': 'b6eb7f28ac53c1b1d9b2e2328562110fd3a684af334268ccec0b1b5fa7271ba2', 'target_stats': '291a06e8fc5e285e3b7311e46f276472f19d7447167c149424b5f2051af7360a'}
|
|
def contract():
|
|
return dict(policy=POLICY,input_sha256=PINS,source_aura=71,source_name='SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL',source_school_mask=126,target_aura=57,target_name='SPELL_AURA_MOD_SPELL_CRIT_CHANCE',target_misc_value=0,units='percentage-points',rating_conversion=False,all_six_magic_schools=True,single_school_conversion=False)
|
|
|
|
def namespace(paths):
|
|
if set(paths)!=set(PINS):raise ValueError('Complete named all-magic crit contract required')
|
|
texts={}
|
|
for role,path in paths.items():
|
|
raw=Path(path).read_bytes()
|
|
if hashlib.sha256(raw).hexdigest()!=PINS[role]:raise ValueError('Named all-magic crit input changed: '+role)
|
|
texts[role]=raw.decode()
|
|
for role,name,value in [('source_aura','SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL',71),('source_aura','SPELL_AURA_MOD_SPELL_CRIT_CHANCE',57),('target_aura','SPELL_AURA_MOD_SPELL_CRIT_CHANCE',57)]:
|
|
if not re.search(r'\b'+name+r'\s*=\s*'+str(value)+r'\s*,',texts[role]):raise ValueError('Named spell crit aura differs')
|
|
for role in ('source_schools','target_schools'):
|
|
for school,value in [('NORMAL',0),('HOLY',1),('FIRE',2),('NATURE',3),('FROST',4),('SHADOW',5),('ARCANE',6)]:
|
|
if not re.search(r'\bSPELL_SCHOOL_'+school+r'\s*=\s*'+str(value)+r'\s*(?:,|})',texts[role]):raise ValueError('Named magic school bit differs: '+role+'/'+school)
|
|
for role,fragment in [('source_stats','if (school == SPELL_SCHOOL_NORMAL)'),('source_stats','GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE)'),('source_stats','GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, 1 << school)'),('target_stats','GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE)'),('target_stats','&UF::ActivePlayerData::SpellCritPercentage')]:
|
|
if fragment not in texts[role]:raise ValueError('Named spell crit consumer differs: '+role)
|
|
return contract()
|
|
|
|
def normalized_source(source,semantics):
|
|
if not isinstance(semantics,dict)or canonical_sha256(semantics)!=canonical_sha256(contract()):raise ValueError('Named all-magic crit semantics required')
|
|
result=deepcopy(source);effects=result.get('effects')
|
|
if not isinstance(effects,list)or len(effects)!=3:raise ValueError('Exact all-magic crit source effects required')
|
|
indices=[]
|
|
for index,e in enumerate(effects):
|
|
if not isinstance(e,list)or len(e)!=12:raise ValueError('Exact all-magic crit effect shape required')
|
|
if not e[0]:continue
|
|
if type(e[0])is not int or type(e[1])is not int or type(e[7])is not int or (e[0],e[1],e[7])!=(6,71,126):raise ValueError('Only exact all-six-magic-school crit percentage is reviewed')
|
|
e[1]=57;e[7]=0;indices.append(index)
|
|
if len(indices)!=1:raise ValueError('One all-magic crit effect required')
|
|
if static.validate_source(result,percent_stat='spell-crit')!=indices:raise ValueError('All-magic crit source slot differs')
|
|
return result
|
|
|
|
def component(sources,native,schemas,maxima,registry,*,semantics,duration_reference=None):
|
|
normalized=[normalized_source(src,semantics)for src in sources]
|
|
result=static.component(normalized,native,schemas,maxima,registry,percent_stat='spell-crit',duration_reference=duration_reference)
|
|
actual={src['entry']:src for src in sources}
|
|
for row in result['spells']:
|
|
src=actual[row['spell_id']];row['source_record_sha256']=canonical_sha256(src);row['source_definition']=deepcopy(src);row['normalized_source_sha256']=canonical_sha256(normalized_source(src,semantics))
|
|
for effect in row['effects']:effect.update(source_aura=71,target_aura=57,source_school_mask=126,target_misc_value=0)
|
|
result['definition_policy']=POLICY;result['semantic_contract']=deepcopy(semantics)
|
|
result['limitations'].append('Only source school mask126 covering all six magic schools is equivalent to existing global spell crit; specific schools remain held.')
|
|
return result
|