Files
WoW-Hybrid-gateway/tests/spell_effect_coefficients_test.py

78 lines
3.9 KiB
Python

"""Check the classic coefficient source paths and the gates on native projection."""
from pathlib import Path
import sys
import unittest
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "ops/octo_parity"))
from spell_effect_coefficients import decision, default_coefficient, f32
def shape(effect=2, aura=0, period=0, targets=(6, 0)):
return dict(effect=effect, aura=aura, period=period, targets=targets,
per_level=0, combo=0, bonus=-1, mean=42, source_parity=True)
def source(*slots, **overrides):
return dict(id=10934, name="Smite", school=1, level=54, base_level=54,
attributes=0, attributes_ex=0, attributes_ex3=0, cast=1, duration=1,
family=6, family_mask=128, custom=0, dmg_class=1, script="",
slots=list(slots)) | overrides
def native(slot):
return dict(Effect=slot['effect'], EffectAura=slot['aura'], EffectAuraPeriod=slot['period'],
ImplicitTarget=','.join(map(str, slot['targets'])), ScalingClass=0, Coefficient=0,
ResourceCoefficient=0, EffectBasePointsF=42, EffectRealPointsPerLevel=0,
EffectPointsPerResource=0, EffectBonusCoefficient=0, BonusCoefficientFromAP=0)
class SpellEffectCoefficientsTest(unittest.TestCase):
def setUp(self):
self.cast = {1: (1, 3500, 0, 0)}
self.duration = {1: (1, 15000, 0, 15000)}
def select(self, spell, **native_changes):
slot = spell['slots'][0]
return decision(spell, 0, (slot['effect'],slot['aura']), native(slot) | native_changes,
spell['level'], None, self.cast, self.duration)
def test_explicit_smite_and_low_level_consumer(self):
slot = shape() | {'bonus': 0.7497}
status, terms, origin, _ = self.select(source(slot), EffectBonusCoefficient=0.714)
self.assertEqual((status, terms, origin), ('change', (f32(0.7497), 0.0), 'explicit'))
self.assertEqual(self.select(source(slot, level=6))[0], 'low-level-penalty-consumer')
def test_direct_periodic_area_and_leech_defaults(self):
spell = source(shape())
self.assertEqual(default_coefficient(spell, False, self.cast, self.duration), 1.0)
periodic = source(shape(6, 3, 3000))
self.assertEqual(default_coefficient(periodic, True, self.cast, self.duration), f32(0.2))
aoe = source(shape(targets=(15, 0)))
self.assertEqual(default_coefficient(aoe, False, self.cast, self.duration), 0.5)
leech = source(shape(9))
self.assertEqual(default_coefficient(leech, False, self.cast, self.duration), 0.5)
hybrid = source(shape(), shape(6, 3, 3000))
self.assertEqual(default_coefficient(hybrid, False, self.cast, self.duration), 0.5)
self.assertEqual(default_coefficient(hybrid, True, self.cast, self.duration), f32(0.1))
def test_a_caster_bypass_has_precedence_over_an_explicit_coefficient(self):
heal = shape(10) | {'bonus': 0.17}
self.assertEqual(self.select(source(heal, attributes_ex3=0x20000000))[0], 'caster-modifiers-bypassed')
self.assertEqual(self.select(source(heal, attributes=0x40, dmg_class=0))[0], 'passive-heal-bypass')
dot = shape(6, 3, 3000)
self.assertEqual(self.select(source(dot, family=3, family_mask=1 << 27))[0], 'ignite-bonus-already-included')
def test_swipe_uses_melee_attack_power(self):
swipe = source(shape() | {'bonus': 0.04}, custom=0x800000, school=0, dmg_class=2)
self.assertEqual(self.select(swipe, BonusCoefficientFromAP=0.06)[:3],
('change', (0.0, f32(0.04)), 'explicit'))
def test_conflicting_native_base_and_custom_script_are_held(self):
spell = source(shape() | {'bonus': 0.714})
self.assertEqual(self.select(spell, EffectBasePointsF=99)[0], 'native-base-differs')
self.assertEqual(self.select(spell | {'script':'custom_damage'})[0], 'script-dependent')
if __name__ == '__main__':
unittest.main()