883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
103 lines
7.1 KiB
Python
103 lines
7.1 KiB
Python
"""Actual five source item avoidance definitions; synthetic icon I/O only."""
|
|
import copy,json,sys,unittest
|
|
from pathlib import Path
|
|
from types import SimpleNamespace
|
|
ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT/'ops'))
|
|
import spell_item_avoidance_compat as m
|
|
import spell_passive_compat as codec
|
|
import spell_item_skill_compat_test as fixtures
|
|
import content_package_stage as stage
|
|
from octo_client_data import canonical_sha256
|
|
from spell_family_compat import namespace
|
|
from turtle_data import spell_layout
|
|
|
|
class Avoidance(unittest.TestCase):
|
|
def fixture(self):
|
|
values=list(fixtures.ItemSkillDefinitionTest().fixture())
|
|
f=json.loads((ROOT/'tests/fixtures/item-aoe-avoidance-source.json').read_text())
|
|
dbc=SimpleNamespace(by_id={int(k):r for k,r in f['disk_rows'].items()},string={int(k):v for k,v in f['strings'].items()}.__getitem__)
|
|
family=namespace(ROOT.parent.parent.parent/'Servers/tortoise-wow/src/game/Database/DBCEnums.h',ROOT.parent/'servers/trinity-forever/src/server/game/Miscellaneous/SharedDefines.h')
|
|
values[2]=[m.source_spell(dbc,r,spell_layout(),family_namespace=family,semantics=m.contract())for r in f['server_rows']]
|
|
values[4]['SpellLevels']=codec.fields(ROOT.parent/'tools/WoWDBDefs/definitions/SpellLevels.dbd','SpellLevels');values[5]['SpellLevels']=1500000
|
|
del values[7]['source_tables']['SkillLine']
|
|
values[7].update(semantics=m.contract(),new_icon_ids={str(s['entry']):136235 for s in values[2]})
|
|
return values
|
|
def convert(self,v):return m.component(*v[2:7],**v[7])
|
|
def test_all_five_source_ids_use_signed_229_and_literal_reductions(self):
|
|
v=self.fixture();before=copy.deepcopy(v[2:7]);r=self.convert(v);self.assertEqual(v[2:7],before)
|
|
effects=[x['record']for x in r['records']if x['table_name']=='SpellEffect']
|
|
self.assertEqual([x['SpellID']for x in effects],[52778,52779,52780,52781,52782])
|
|
self.assertEqual([x['EffectBasePointsF']for x in effects],[-5,-10,-15,-20,-25])
|
|
self.assertTrue(all(x['EffectAura']==229 and x['EffectMiscValue']==[127,0]for x in effects))
|
|
texts=[x for x in r['records']if x['table_name']=='Spell']
|
|
self.assertTrue(all('$'not in x['record']['Description_lang']and x['constant_description_policy']==m.POLICY for x in texts))
|
|
self.assertFalse(r['installable']);self.assertFalse(r['gameplay_verified'])
|
|
self.assertFalse(any(x['table_name']=='SkillLineAbility'for x in r['records']))
|
|
for row in r['records']:self.assertEqual(bytes.fromhex(row['wire_hex']),codec.encode(row['record'],v[4][row['table_name']]))
|
|
def test_repeated_allocator_and_reordered_batch_are_identical(self):
|
|
v=self.fixture();r=self.convert(v);v[6].update(r['child_id_registry']);v[2].reverse();self.assertEqual(self.convert(v),r)
|
|
def test_partial_school_masks_positive_damage_and_type_confusion_rejected(self):
|
|
for label,value in [('mask',126),('mask',0),('aura',229),('aura',194.0),('amount',0),('amount',-102),('amount',True),('proc',1),('scaling',0.5),('proof',None)]:
|
|
v=self.fixture();s=v[2][0]
|
|
if label=='mask':s['effects'][0][7]=value
|
|
elif label=='aura':s['effects'][0][1]=value
|
|
elif label=='amount':s['effects'][0][2]=value
|
|
elif label=='proc':s['conditions']['procFlags']=value
|
|
elif label=='scaling':s['effects'][0][6]=value
|
|
else:v[7]['semantics']=value
|
|
with self.assertRaises(ValueError,msg=str((label,value))):self.convert(v)
|
|
def test_positive_context_missing_references_and_icon_drift_are_not_overwritten(self):
|
|
for label in ['positive','missing','icon','timing','learned']:
|
|
v=self.fixture()
|
|
if label=='positive':v[3]['SpellName'].append(dict(ID=52779,Name_lang='Existing'))
|
|
elif label=='missing':del v[3]['SpellPower']
|
|
elif label=='icon':v[7]['read_icon']=lambda _:b'BLP2wrong'
|
|
elif label=='timing':v[3]['SpellDuration'][0]['Duration']=1000
|
|
else:v[6]['SkillLineAbility']={'52779':1500001}
|
|
with self.assertRaises(ValueError,msg=label):self.convert(v)
|
|
def test_registered_icon_identity_is_checked_and_retained(self):
|
|
v=self.fixture();v[7]['icon_assets'][0]['file_data_id']=136235
|
|
self.assertTrue(all(r['icon_asset']['file_data_id']==136235 for r in self.convert(v)['spells']))
|
|
v[7]['icon_assets'][0]['file_data_id']=136236
|
|
with self.assertRaisesRegex(ValueError,'FileDataID'):self.convert(v)
|
|
def test_arbitrary_source_identity_is_preserved_without_item_allowlist(self):
|
|
v=self.fixture();v[2]=v[2][:1];v[2][0]['entry']=600127;v[7]['new_icon_ids']={'600127':136235};r=self.convert(v)
|
|
self.assertTrue(all(x['source_spell_id']==600127 for x in r['records']))
|
|
def staged_fixture(self):
|
|
v=self.fixture();v[2]=[r for r in v[2]if r['entry']==52779];v[7]['new_icon_ids']={'52779':136235}
|
|
candidate=self.convert(v);metadata=codec.TABLES|codec.SUPPLEMENTAL_TABLES
|
|
candidate['native_tables']={t:dict(table_hash=hex(metadata[t][0]),layout_hash=hex(metadata[t][1]),
|
|
serialized_field_sha256=metadata[t][2],native_max_id=1500000,allocation_bound=1500000)
|
|
for t in {r['table_name']for r in candidate['records']}}
|
|
v[4]={t:s for t,s in v[4].items()if t in candidate['native_tables']}
|
|
base=json.loads((ROOT/'docs/evidence/data/item-sparse-compat/package.json').read_bytes())
|
|
base['rows']=base['rows'][:2];base['push_id']=stage.package_payloads(base['rows'])[0]
|
|
before={'52779':dict(infoStatus='nil',nameStatus='nil',descriptionStatus='nil')}
|
|
return v,candidate,base,before
|
|
def test_generic_composer_accepts_reviewed_avoidance_without_changing_existing_rows(self):
|
|
v,c,base,before=self.staged_fixture();original=copy.deepcopy(base)
|
|
result=stage.compose_definition_candidates(base,[c],v[4],before)
|
|
self.assertEqual(base,original);self.assertEqual(result['rows'][:2],base['rows'])
|
|
self.assertEqual(result['added_count'],5);self.assertEqual(result['source_spell_ids'],[52779])
|
|
self.assertFalse(result['installable']);self.assertFalse(result['engine_accepted'])
|
|
self.assertEqual(len([r for r in result['rows']if r.get('source_spell_id')==52779]),5)
|
|
def test_generic_composer_revalidates_contract_source_and_exact_encoded_semantics(self):
|
|
v,c,base,before=self.staged_fixture()
|
|
for change in ('contract','source-mask','source-amount','aura','amount','mask','text','native-positive'):
|
|
candidate=copy.deepcopy(c);api=copy.deepcopy(before)
|
|
if change=='contract':candidate['semantic_contract']['source_aura']=229
|
|
elif change in('source-mask','source-amount'):
|
|
src=candidate['spells'][0]['source_definition'];src['effects'][0][7 if change=='source-mask'else 2]=126 if change=='source-mask'else -16
|
|
candidate['spells'][0]['source_record_sha256']=canonical_sha256(src)
|
|
elif change=='native-positive':api['52779']['nameStatus']='ok'
|
|
else:
|
|
row=next(r for r in candidate['records']if r['table_name']==('Spell'if change=='text'else'SpellEffect'))
|
|
if change=='text':row['record']['Description_lang']='Reduces damage by 194%.'
|
|
elif change=='aura':row['record']['EffectAura']=194
|
|
elif change=='amount':row['record']['EffectBasePointsF']=10
|
|
else:row['record']['EffectMiscValue']=[126,0]
|
|
wire=codec.encode(row['record'],v[4][row['table_name']]);row.update(wire_hex=wire.hex(),sha256=stage.sha(wire))
|
|
with self.assertRaises(ValueError,msg=change):stage.compose_definition_candidates(base,[candidate],v[4],api)
|
|
|
|
if __name__=='__main__':unittest.main()
|