Module:Damage: Difference between revisions

104 bytes removed ,  10 October 2023
revert
No edit summary
Tag: Reverted
(revert)
Tag: Manual revert
Line 271: Line 271:


     -- Function to apply inheritance for a specific damage type and argument
     -- Function to apply inheritance for a specific damage type and argument
     local function applyInheritance(mainArgValues, inheritArg, mainArgValue, inheritValue, mainKeyPrefixed, inheritKeyPrefixed)
     local function applyInheritance(mainArgValues, inheritArg, mainArgValue, inheritValue)
         if mainArgValue == '' then
         if mainArgValue == '' then
             return inheritValue
             return inheritValue
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, damageType, damageTypeIndex, argTable)
     local function applyInheritanceForKey(args, prefix, mainKey, argTable, damageTypeIndex)
        local mainKey = argTable[1] .. damageType
         local mainKeyPrefixed = prefix .. mainKey
         local mainKeyPrefixed = prefix .. mainKey
         local mainArgValues = args[mainKeyPrefixed]
         local mainArgValues = args[mainKeyPrefixed]
Line 294: Line 293:


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


                     if inheritArg and inheritArg[i] and inheritArg[i] ~= '' and ix ~= 1 then
                     if inheritArg and inheritArg[i] and inheritArg[i] ~= '' and
                        (damageTypeIndex == 1 and ix ~= 1 or damageTypeIndex ~= 1)
                    then
                         mainArgValues[i] = applyInheritance(mainArgValues, inheritArg, mainArgValue, inheritArg[i])
                         mainArgValues[i] = applyInheritance(mainArgValues, inheritArg, mainArgValue, inheritArg[i])
                         break
                         break
Line 315: Line 316:
                 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, damageType, damageTypeIndex, argTable)
                         applyInheritanceForKey(args, prefix, argTable[1] .. damageType, argTable, damageTypeIndex)
                     end
                     end
                 end
                 end