883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
56 lines
4.0 KiB
Python
56 lines
4.0 KiB
Python
"""Finite defensive-family boundaries; synthetic serialization is not gameplay."""
|
|
import copy,json,sys,unittest
|
|
from pathlib import Path
|
|
ROOT=Path(__file__).resolve().parents[1];sys.path[:0]=[str(ROOT/'ops'),str(ROOT/'tests')]
|
|
import spell_timed_buff_compat as m,spell_passive_compat as codec
|
|
import spell_timed_buff_compat_test as timed
|
|
import spell_category_context_test as category
|
|
from spell_definition_common import spell_category_namespace
|
|
|
|
class DefensiveBuffTest(unittest.TestCase):
|
|
def proof(self):
|
|
s=Path.home()/'Servers/tortoise-wow/src/game';t=ROOT.parent/'servers/trinity-forever/src/server/game'
|
|
return m.defensive_namespace(s/'Spells/SpellDefines.h',s/'Spells/SpellAuraDefines.h',s/'SharedDefines.h',t/'Miscellaneous/SharedDefines.h',t/'Spells/Auras/SpellAuraDefines.h')
|
|
def fixture(self):
|
|
# Synthetic neutral-visual variant used only for serializer boundaries.
|
|
v=timed.TimedBuffCompatibilityTest().fixture();src=v[0][0]
|
|
src.update(defensive_context=self.proof(),spell_category_context=spell_category_namespace(*category.SpellCategoryContextTest().paths()),defense_type=1,prevention_type=0)
|
|
src['effects']=[[6,87,-4,1,1,0,0,1,1,0,0,-1],[6,30,9,1,1,0,0,95,1,0,0,-1],[0,0,0,0,0,0,0,0,0,0,0,-1]]
|
|
v[2]['SpellCategories']=codec.fields(ROOT.parent/'tools/WoWDBDefs/definitions/SpellCategories.dbd','SpellCategories');v[3]['SpellCategories']=1500000
|
|
return v
|
|
def convert(self,v):return m.new_component(*v[:5],**v[5],defensive=True)
|
|
def test_actual_captured_earthen_shield_visual_remains_required(self):
|
|
src=category.SpellCategoryContextTest().source();src['defensive_context']=self.proof()
|
|
self.assertEqual(src['visuals'],[7362,0]);self.assertEqual([e[2]+1 for e in src['effects']if e[0]],[-3,10])
|
|
with self.assertRaisesRegex(ValueError,'visual link'):m.validate_source(src,defensive=True)
|
|
with self.assertRaises(ValueError):m.validate_source(src)
|
|
def test_generic_finite_reduction_and_defense_keep_signed_amounts_and_categories(self):
|
|
v=self.fixture();before=copy.deepcopy(v[:5]);r=self.convert(v);self.assertEqual(v[:5],before)
|
|
self.assertEqual(r['definition_policy'],m.DEFENSIVE_POLICY);self.assertFalse(r['gameplay_verified']);self.assertFalse(r['installable'])
|
|
effects=[x['record']for x in r['records']if x['table_name']=='SpellEffect']
|
|
self.assertEqual([(e['EffectAura'],e['EffectBasePointsF'],e['EffectMiscValue'])for e in effects],[(87,-3,[1,0]),(30,10,[95,0])])
|
|
categories=[x['record']for x in r['records']if x['table_name']=='SpellCategories'];self.assertEqual(len(categories),1)
|
|
self.assertEqual((categories[0]['DefenseType'],categories[0]['PreventionType']),(1,0))
|
|
self.assertEqual(r['spells'][0]['source_definition'],v[0][0]);v[4]=r['child_id_registry'];self.assertEqual(self.convert(v),r)
|
|
def test_wrong_school_skill_scaling_duplicate_roles_and_contexts_reject(self):
|
|
for mode in ('school','skill','scaling','positive-damage','target','trigger','chance','duplicate','category','proof'):
|
|
v=self.fixture();s=v[0][0]
|
|
if mode=='school':s['effects'][0][7]=3
|
|
elif mode=='skill':s['effects'][1][7]=162
|
|
elif mode=='scaling':s['effects'][0][6]=1
|
|
elif mode=='positive-damage':s['effects'][0][2]=2
|
|
elif mode=='target':s['effects'][0][8]=6
|
|
elif mode=='trigger':s['effects'][0][10]=123
|
|
elif mode=='chance':s['conditions']['procFlags']=139944
|
|
elif mode=='duplicate':s['effects'][1]=copy.deepcopy(s['effects'][0])
|
|
elif mode=='category':s['defense_type']=2
|
|
else:s['defensive_context']['mappings'][0]['value']=7
|
|
with self.assertRaises(ValueError,msg=mode):self.convert(v)
|
|
def test_prior_haste_path_does_not_silently_accept_defensive_aura(self):
|
|
v=self.fixture()
|
|
with self.assertRaises(ValueError):m.new_component(*v[:5],**v[5])
|
|
del v[0][0]['defensive_context']
|
|
with self.assertRaises(ValueError):self.convert(v)
|
|
|
|
if __name__=='__main__':unittest.main()
|