70 lines
3.8 KiB
Lua
70 lines
3.8 KiB
Lua
-- Extend the real parser/storage compatibility checks with warlock events.
|
|
dofile('tests/classicapi-updates.lua')
|
|
local oldName=UnitName
|
|
UnitName=function(unit)
|
|
if unit=='raid3' or unit=='0xWARLOCK' then return 'Warlock' end
|
|
if unit=='0xIMP' then return 'Imp' end
|
|
if unit=='0xGUARDIAN' then return 'Infernal' end
|
|
return oldName(unit)
|
|
end
|
|
UnitOwnerGUID=function(unit)
|
|
if unit=='0xIMP' or unit=='0xGUARDIAN' then return '0xWARLOCK' end
|
|
end
|
|
local p,d=ShaguDPS.parser,ShaguDPS.data
|
|
dofile('parser-native.lua')
|
|
p.sources.classicapi.enable()
|
|
local function damage(kind,guid,name,flags,spell,amount)
|
|
arg2,arg3,arg4,arg5,arg6,arg8,arg9=kind,false,guid,name,flags,'0xENEMY','Enemy'
|
|
arg12,arg13,arg14,arg15=172,spell,32,amount
|
|
p.OnEvent()
|
|
end
|
|
damage('SPELL_PERIODIC_DAMAGE','0xWARLOCK','Warlock',1028,'Corruption',120)
|
|
damage('SPELL_PERIODIC_DAMAGE','0xWARLOCK','Warlock',1028,'Corruption',120)
|
|
damage('SPELL_DAMAGE','0xWARLOCK','Warlock',1028,'Shadow Bolt',500)
|
|
assert(d.damage[0].Warlock.Corruption==240 and d.damage[0].Warlock['Shadow Bolt']==500)
|
|
damage('SPELL_DAMAGE','0xIMP','Imp',4100,'Firebolt',80)
|
|
damage('SPELL_DAMAGE','0xGUARDIAN','Infernal',8196,'Immolation',60)
|
|
assert(d.damage[0].Warlock['Pet: Imp - Firebolt']==80 and d.damage[0].Warlock['Pet: Infernal - Immolation']==60)
|
|
assert(d.damage[0].Warlock._sum==880,'DoTs, direct damage, pet and guardian count once')
|
|
assert(d.damage[1].Warlock._sum==880,'current and overall agree')
|
|
damage('SPELL_DAMAGE','0xIMP','Imp',4100,'Fire Shield',25)
|
|
assert(d.damage[0].Warlock['Pet: Imp - Fire Shield']==25,'pet spells stay separate')
|
|
damage('SPELL_DAMAGE','0xIMP','Imp',4100,'Firebolt',20)
|
|
assert(d.damage[0].Warlock['Pet: Imp - Firebolt']==100,'repeated spells reuse their entry')
|
|
ShaguDPS.config.merge_pets=0
|
|
damage('SPELL_DAMAGE','0xIMP','Imp',4100,'Firebolt',90)
|
|
assert(d.damage[0]['Imp (Warlock)'].Firebolt==90 and d.damage[0].Warlock._sum==925)
|
|
damage('SPELL_DAMAGE','0xOUTSIDER','Stranger',1032,'Shadow Bolt',999)
|
|
assert(not d.damage[0].Stranger,'outsiders excluded')
|
|
local before=d.heal[0].Priest._esum
|
|
arg2,arg3,arg4,arg5,arg6,arg8,arg9='SPELL_PERIODIC_HEAL',false,'0xPRIEST','Priest',1025,'0xTARGET','Mage'
|
|
arg12,arg13,arg14,arg15,arg16=139,'Renew',2,100,60
|
|
p.OnEvent()
|
|
assert(d.heal[0].Priest._esum==before+40,'periodic healing uses valid overhealing')
|
|
UnitHealthMax=function() return 100 end
|
|
UnitHealth=function() return 95 end
|
|
arg16=0
|
|
before=d.heal[0].Priest._esum
|
|
p.OnEvent()
|
|
assert(d.heal[0].Priest._esum==before+5,'percentage-like health keeps estimation fallback')
|
|
-- Recorded control-loss flags: same GUID changes from mine/friendly/pet to
|
|
-- outsider/hostile/NPC. Its first hostile hit must not reuse the owner cache.
|
|
ShaguDPS.config.merge_pets=1
|
|
local groupName=UnitName
|
|
UnitName=function(unit) if unit=='player' then return 'Warlock' end return groupName(unit) end
|
|
damage('SPELL_DAMAGE','0xGUARDIAN','Infernal',4369,'Immolation',20)
|
|
local ownerTotal=d.damage[0].Warlock._sum
|
|
damage('SPELL_DAMAGE','0xGUARDIAN','Infernal',68168,'Immolation',30)
|
|
damage('SPELL_DAMAGE','0xGUARDIAN','Infernal',2632,'Immolation',30)
|
|
assert(d.damage[0].Warlock._sum==ownerTotal,'hostile NPC events never credit former owner')
|
|
-- A hostile unit retaining a PET type must also ignore stale UnitOwnerGUID.
|
|
damage('SPELL_DAMAGE','0xGUARDIAN','Infernal',4424,'Immolation',30)
|
|
assert(d.damage[0].Warlock._sum==ownerTotal,'hostile pet flags override stale owner APIs')
|
|
damage('SPELL_DAMAGE','0xGUARDIAN','Infernal',4369,'Immolation',20)
|
|
assert(d.damage[0].Warlock._sum==ownerTotal+20,'control regained bypasses cached exclusion immediately')
|
|
ShaguDPS.config.track_all_units=1
|
|
damage('SPELL_DAMAGE','0xGUARDIAN','Infernal',68168,'Immolation',30)
|
|
assert(d.damage[0].Warlock._sum==ownerTotal+20 and d.damage[0].Infernal._sum==30,
|
|
'track-all records hostile creature independently without crediting owner')
|
|
print('Warlock DoT, demon, guardian and merge accuracy checks passed (Lua 5.0)')
|