Anonymous

Module:Sandbox/AuronTest: Difference between revisions

From Melvor Idle
m
Test amend to support familiars
m (Special attack testing)
m (Test amend to support familiars)
Line 1: Line 1:
-- For tables & other outputs generated with attack data, see: Module:Attacks/Tables
local p = {}
local p = {}


Line 7: Line 9:
p.effectDefinition = {
p.effectDefinition = {
     ["Burn"] = {
     ["Burn"] = {
         ["type"] = 'DOT',
         {
         ["subtype"] = 'Burn'
            ["type"] = 'DOT',
            ["subtype"] = 'Burn'
         },
        -- Alternative definition specifically for familiars like Dragon
        {
            ["type"] = 'Modifier',
            ["subtype"] = 'Familiar',
            ["modifiers"] = {
                ["include"] = { 'increasedChanceToApplyBurn' }
            }
        }
     },
     },
     ["Poison"] = {
     ["Poison"] = {
Line 95: Line 107:
end
end


-- Determines if attack applies the effect defined in effectDefiniton
-- Determines if attack applies the effect defined in effectDefinition
function p.attackHasEffect(attack, effectDefn)
function p.attackHasEffect(attack, effectDefn)
     if type(attack) == 'table' and type(effectDefn) == 'table' and type(effectDefn.type) == 'string' then
     if type(attack) == 'table' and type(effectDefn) == 'table' then
         -- Process pre-hit effects
         -- Process pre-hit effects
         for i, effect in ipairs(attack.prehitEffects) do
         for i, effect in ipairs(attack.prehitEffects) do
Line 114: Line 126:
end
end


function p.effectMatchesDefn(effect, effectDefn)
function p.effectMatchesDefn(effect, effectDefnIn)
    -- Some effects (e.g. Burn) have multiple definitions, so handle these correctly
    local effectDefnList = nil
    if effectDefnIn[1] ~= nil and type(effectDefnIn[1]) == 'table' then
        -- Definition is actually multiple definitions
        effectDefnList = effectDefnIn
    else
        -- Definition is singular, wrap it within a table so we can iterate
        effectDefnList = { effectDefnIn }
    end
 
    for i, effectDefn in pairs(effectDefnList) do
        if p.effectMatchesDefnSingle(effect, effectDefn) then
            return true
        end
    end
    return false
end
 
function p.effectMatchesDefnSingle(effect, effectDefn)
     if effectDefn.type ~= effect.type then
     if effectDefn.type ~= effect.type then
         -- Effect's type doesn't match that of the effect definition
         -- Effect's type doesn't match that of the effect definition