883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
81 lines
5.5 KiB
Python
81 lines
5.5 KiB
Python
"""Real three-set casting regeneration family; source/definition boundaries 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_static_compat as policy
|
|
import spell_item_skill_compat_test as fixtures
|
|
from spell_family_compat import namespace
|
|
from turtle_data import spell_layout
|
|
|
|
class CastingManaRegenerationTest(unittest.TestCase):
|
|
def fixture(self):
|
|
v=fixtures.ItemStaticDefinitionTest().fixture('swim-speed')
|
|
raw=json.loads((ROOT/'tests/fixtures/item-casting-mana-regen-source.json').read_text())
|
|
strings={int(k):s for k,s in raw['strings'].items()}
|
|
dbc=SimpleNamespace(by_id={int(k):r for k,r in raw['disk_rows'].items()},string=strings.__getitem__)
|
|
proof=namespace(ROOT.parent.parent.parent/'Servers/tortoise-wow/src/game/Database/DBCEnums.h',ROOT.parent/'servers/trinity-forever/src/server/game/Miscellaneous/SharedDefines.h')
|
|
v[2]=[policy.source_spell(dbc,r,spell_layout(),family_namespace=proof,percent_stat='casting-mana-regen')for r in raw['server_rows']]
|
|
icon=raw['source_icon'];icon_strings={int(k):s for k,s in icon['strings'].items()}
|
|
v[7]['source_tables']['SpellIcon']=SimpleNamespace(by_id={44:icon['row']},string=icon_strings.__getitem__)
|
|
path='interface/icons/spell_nature_sleep.blp'
|
|
v[7]['target_icon_names']={136090:[path]}
|
|
v[7]['new_icon_ids']={str(s['entry']):136090 for s in v[2]}
|
|
v[7]['icon_assets'][0]['path']=path
|
|
v[7]['percent_stat']='casting-mana-regen'
|
|
return v
|
|
def component(self,v):return policy.new_static_component(*v[2:7],**v[7])
|
|
def test_complete_three_set_family_keeps_source_values_flags_and_no_learned_links(self):
|
|
v=self.fixture();before=copy.deepcopy(v[2:7]);result=self.component(v)
|
|
self.assertEqual(v[2:7],before)
|
|
self.assertEqual({r['source_spell_id']for r in result['records']},{14776,57159,57161})
|
|
effects={r['record']['SpellID']:r['record']for r in result['records']if r['table_name']=='SpellEffect'}
|
|
self.assertEqual({k:(r['EffectAura'],r['EffectBasePointsF'],r['EffectMiscValue'])for k,r in effects.items()},
|
|
{14776:(134,10,[0,0]),57159:(134,10,[0,0]),57161:(134,15,[0,0])})
|
|
for row in result['records']:
|
|
self.assertNotEqual(row['table_name'],'SkillLineAbility')
|
|
self.assertEqual(bytes.fromhex(row['wire_hex']),fixtures.codec.encode(row['record'],v[4][row['table_name']]))
|
|
if row['table_name']=='SpellMisc':self.assertEqual(row['record']['Attributes'][:5],[464,0,0,0,0])
|
|
if row['table_name']=='Spell':self.assertNotIn('$s',row['record']['Description_lang'])
|
|
self.assertTrue(all(not s['known_spells_modified']for s in result['spells']))
|
|
self.assertFalse(result['engine_accepted']);self.assertFalse(result['gameplay_verified'])
|
|
def test_other_mechanics_scaling_flags_and_mixed_policy_stay_rejected(self):
|
|
for mutation in ('flags','proc','duration','scaling','trigger','amount','misc','other-aura'):
|
|
v=self.fixture();s=v[2][0]
|
|
if mutation=='flags':s['attributes'][0]|=0x200
|
|
elif mutation=='proc':s['conditions']['procFlags']=4
|
|
elif mutation=='duration':s['durationIndex']=18
|
|
elif mutation=='scaling':s['effects'][0][6]=.5
|
|
elif mutation=='trigger':s['effects'][0][10]=52861
|
|
elif mutation=='amount':s['effects'][0][2]=100
|
|
elif mutation=='misc':s['effects'][0][7]=1
|
|
else:s['effects'][0][1]=85
|
|
with self.assertRaises(ValueError,msg=mutation):self.component(v)
|
|
v=self.fixture();v[7]['school_damage']=True
|
|
with self.assertRaises(ValueError):self.component(v)
|
|
def test_composer_accepts_shared_family_and_refuses_reencoded_wrong_aura(self):
|
|
import content_package_stage as stage
|
|
import content_definition_stage_test as composition_fixture
|
|
import hashlib
|
|
v=self.fixture();component=self.component(v)
|
|
metadata=fixtures.codec.TABLES|fixtures.codec.SUPPLEMENTAL_TABLES
|
|
component['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=v[5][t])for t in {r['table_name']for r in component['records']}}
|
|
base=composition_fixture.DefinitionStageTest().inputs()[0]
|
|
schemas={t:s for t,s in v[4].items()if t!='SkillLineAbility'}
|
|
absence={str(s['entry']):dict(infoStatus='nil',nameStatus='nil',descriptionStatus='nil')for s in v[2]}
|
|
result=stage.compose_definition_candidates(base,[component],schemas,absence)
|
|
self.assertEqual(result['added_count'],len(component['records']))
|
|
self.assertFalse(result['gameplay_verified'])
|
|
changed=copy.deepcopy(component)
|
|
row=next(r for r in changed['records']if r['table_name']=='SpellEffect')
|
|
row['record']['EffectAura']=85
|
|
wire=fixtures.codec.encode(row['record'],schemas['SpellEffect'])
|
|
row.update(wire_hex=wire.hex(),sha256=hashlib.sha256(wire).hexdigest())
|
|
with self.assertRaises(ValueError):stage.compose_definition_candidates(base,[changed],schemas,absence)
|
|
def test_existing_positive_parent_blocks_duplicate_new_definition(self):
|
|
v=self.fixture();v[3]['SpellName'].append(dict(ID=57159,Name_lang='Casting Regen 10%'))
|
|
with self.assertRaisesRegex(ValueError,'positive native reference'):self.component(v)
|
|
|
|
if __name__=='__main__':unittest.main()
|