883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
105 lines
5.8 KiB
Python
105 lines
5.8 KiB
Python
"""Affected legacy healing coefficient policy; generic coefficients stay closed."""
|
|
from copy import deepcopy
|
|
import unittest
|
|
import spell_item_static_compat as m
|
|
import spell_passive_compat as codec
|
|
import spell_item_static_compat_test as fixtures
|
|
|
|
class HealingCoefficientParity(unittest.TestCase):
|
|
def context(self):
|
|
src, f, schemas = fixtures.ItemCasterBonusCompatibilityTest().source(7676, spell_bonus=True)
|
|
src = deepcopy(src); native = deepcopy(f['native'])
|
|
index = next(i for i,e in enumerate(src['effects']) if e[0] and e[1] == 135)
|
|
src['effects'][index][11] = 1
|
|
old = next(e for e in native['SpellEffect'] if e['SpellID'] == src['entry'] and e['EffectIndex'] == index)
|
|
old['EffectBonusCoefficient'] = 1
|
|
return src, native, schemas, f['duration_reference'], index
|
|
|
|
def compose(self, src, native, schemas, duration):
|
|
return m.component([src], native, schemas, {t:1500000 for t in schemas},
|
|
dict(schema_version=1,build=codec.BUILD,SpellEffect={}),
|
|
duration_reference=duration,spell_bonus=True)
|
|
|
|
def test_exact_positive_native_coefficient_is_retained_in_correction(self):
|
|
src,native,schemas,duration,index = self.context()
|
|
src['effects'][index][2] += 4
|
|
result = self.compose(src,native,schemas,duration)
|
|
row = next(r for r in result['records'] if r['table_name']=='SpellEffect')
|
|
self.assertEqual(row['record']['EffectBonusCoefficient'],1)
|
|
self.assertEqual(row['record']['EffectBasePointsF'],src['effects'][index][2]+1)
|
|
self.assertEqual(bytes.fromhex(row['wire_hex']),codec.encode(row['record'],schemas['SpellEffect']))
|
|
|
|
def test_original_unchanged_positive_is_noop(self):
|
|
src,native,schemas,duration,index=self.context()
|
|
self.assertEqual(self.compose(src,native,schemas,duration)['records'],[])
|
|
|
|
def test_native_coefficient_mismatch_refuses(self):
|
|
src,native,schemas,duration,index=self.context()
|
|
for effect in native['SpellEffect']:
|
|
if effect['SpellID']==src['entry'] and effect['EffectIndex']==index:effect['EffectBonusCoefficient']=0
|
|
with self.assertRaisesRegex(ValueError,'exact positive source/native parity'):
|
|
self.compose(src,native,schemas,duration)
|
|
|
|
def test_missing_native_healing_slot_is_not_synthesized(self):
|
|
src,native,schemas,duration,index=self.context()
|
|
native['SpellEffect']=[e for e in native['SpellEffect'] if not(e['SpellID']==src['entry'] and e['EffectIndex']==index)]
|
|
with self.assertRaises(ValueError):self.compose(src,native,schemas,duration)
|
|
|
|
def test_damage_coefficient_one_remains_held(self):
|
|
src,_,_,_,index=self.context();src['effects'][index][1]=13
|
|
with self.assertRaisesRegex(ValueError,'constant item-stat mechanic'):m.validate_source(src,spell_bonus=True)
|
|
|
|
def test_other_healing_coefficients_remain_held(self):
|
|
src,_,_,_,index=self.context()
|
|
for value in (-2,0.5,2):
|
|
with self.subTest(value=value):
|
|
src['effects'][index][11]=value
|
|
with self.assertRaises(ValueError):m.validate_source(src,spell_bonus=True)
|
|
|
|
def mixed_context(self):
|
|
src,f,schemas=fixtures.ItemCasterBonusCompatibilityTest().source(28152,spell_bonus=True)
|
|
src=deepcopy(src);native=deepcopy(f['native'])
|
|
for index,e in enumerate(src['effects']):
|
|
if e[0]and e[1]==135:
|
|
e[11]=1
|
|
next(n for n in native['SpellEffect']if n['SpellID']==src['entry']and n['EffectIndex']==index)['EffectBonusCoefficient']=1
|
|
return src,native,schemas,f['duration_reference']
|
|
|
|
def test_mixed_healing_and_damage_correct_every_active_slot(self):
|
|
src,native,schemas,duration=self.mixed_context()
|
|
for e in src['effects']:
|
|
if e[0]:e[2]+=4
|
|
rows=[r for r in self.compose(src,native,schemas,duration)['records']if r['table_name']=='SpellEffect']
|
|
self.assertEqual({r['record']['EffectIndex']for r in rows},{0,1})
|
|
self.assertEqual({r['record']['EffectAura']for r in rows},{13,135})
|
|
|
|
def test_mixed_family_checks_nonfinal_slot_semantics(self):
|
|
src,native,schemas,duration=self.mixed_context()
|
|
next(n for n in native['SpellEffect']if n['SpellID']==src['entry']and n['EffectIndex']==0)['EffectAura']=57
|
|
with self.assertRaises(ValueError):self.compose(src,native,schemas,duration)
|
|
|
|
def test_invalid_damage_sibling_before_valid_healing_is_refused(self):
|
|
src,native,schemas,duration=self.mixed_context()
|
|
src['effects'][0],src['effects'][1]=src['effects'][1],src['effects'][0]
|
|
for effect in native['SpellEffect']:
|
|
if effect['SpellID']==src['entry']:effect['EffectIndex']=1-effect['EffectIndex']
|
|
native['SpellEffect'].append(dict(codec.NEW_EFFECT_NEUTRAL,ID=999900,SpellID=src['entry'],EffectIndex=0,EffectAura=57,EffectMiscValue=[src['effects'][0][7],0],EffectBasePointsF=src['effects'][0][2]+1))
|
|
with self.assertRaisesRegex(ValueError,'effect semantics differ'):
|
|
self.compose(src,native,schemas,duration)
|
|
|
|
def test_boolean_source_coefficient_is_not_numeric_one(self):
|
|
src,_,_,_,index=self.context();src['effects'][index][11]=True
|
|
with self.assertRaises(ValueError):m.validate_source(src,spell_bonus=True)
|
|
|
|
def test_boolean_native_coefficient_is_not_exact_parity(self):
|
|
src,native,schemas,duration,index=self.context()
|
|
for effect in native['SpellEffect']:
|
|
if effect['SpellID']==src['entry'] and effect['EffectIndex']==index:effect['EffectBonusCoefficient']=True
|
|
with self.assertRaises(ValueError):self.compose(src,native,schemas,duration)
|
|
|
|
def test_generic_static_policy_does_not_admit_healing_coefficient(self):
|
|
src,_,_,_,_=self.context()
|
|
with self.assertRaises(ValueError):m.validate_source(src)
|
|
|
|
if __name__=='__main__':unittest.main()
|