Module:Damage: Difference between revisions

no edit summary
(revert)
Tag: Manual revert
No edit summary
Line 281: Line 281:


     -- Function to apply inheritance for a specific argument key
     -- Function to apply inheritance for a specific argument key
     local function applyInheritanceForKey(args, prefix, mainKey, argTable, damageTypeIndex)
     local function applyInheritanceForKey(args, prefix, argTable, damageTypeIndex, damageType)
        local mainKey = argTable[1] .. damageType
         local mainKeyPrefixed = prefix .. mainKey
         local mainKeyPrefixed = prefix .. mainKey
         local mainArgValues = args[mainKeyPrefixed]
         local mainArgValues = args[mainKeyPrefixed]
Line 293: Line 294:


                 for ix, inheritKey in ipairs(argTable) do
                 for ix, inheritKey in ipairs(argTable) do
                     local inheritArg = args[prefix .. inheritKey] or args[inheritKey]
                     local inheritArg = args[prefix .. inheritKey .. damageType] or args[inheritKey .. damageType]


                     if inheritArg and inheritArg[i] and inheritArg[i] ~= '' and
                    -- Basic damage/hits inheritance request detected. Ignore min/max.
                         (damageTypeIndex == 1 and ix ~= 1 or damageTypeIndex ~= 1)
                     if damageType and mainKey:gsub(damageType, "") == argTable[#argTable] then
                        inheritArg = args[prefix .. inheritKey] or args[inheritKey]
                    end
 
                    if inheritArg and inheritArg[i] and
                         (damageTypeIndex == 1 and ix ~= 1 or damageTypeIndex ~= 1) and tonumber(inheritArg[i])
                     then
                     then
                         mainArgValues[i] = applyInheritance(mainArgValues, inheritArg, mainArgValue, inheritArg[i])
                         mainArgValues[i] = applyInheritance(mainArgValues, inheritArg, mainArgValue, inheritArg[i])
Line 316: Line 322:
                 if argTableKey ~= 'provided' and isTableNotEmpty(argTable) then
                 if argTableKey ~= 'provided' and isTableNotEmpty(argTable) then
                     for damageTypeIndex, damageType in ipairs({ '', '_min', '_max' }) do
                     for damageTypeIndex, damageType in ipairs({ '', '_min', '_max' }) do
                         applyInheritanceForKey(args, prefix, argTable[1] .. damageType, argTable, damageTypeIndex)
                         applyInheritanceForKey(args, prefix, argTable, damageTypeIndex, damageType)
                     end
                     end
                 end
                 end