(Bot: Automated import of articles *** existing text overwritten ***)
No edit summary
Tag: Manual revert
 
Line 1: Line 1:
require('Module:CommonFunctions');
require('Module:CommonFunctions')
require('Module:InfoboxProto');
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local inspect = require('Module:Inspect').inspect
local p = {}
local p = {}


-- Main process
-- Main process
function p.main(frame)
function p.main(frame)
     local args = getArgs(frame)
     local args = getArgs(frame);
 
     local infobox = require('Module:InfoboxProto').main(frame, args.title);
     function inArgs(key)
    local divclass = args.divclass;
        if args[key] ~= nil then
    if divclass == nil then
            return true
         divclass = 'custom'
         end
     end
     end
    infobox:addClass('infobox-' .. divclass);


    -- Define a table with parsed damage information of all kind.
     for k, v in spairs(args) do
    local DAMAGE_DATA = {}
         if string.match(k, 'data[0-9]+') ~= nil then
 
            local i = k:gsub('data', '');
    -- Store a configuration that will tell the main function how to behave given different inputs.
             addField('data' .. i, args['label' .. i])
    local DAMAGE_CONFIG = {
        total_damage = {
            damage_numbers = args.dmg,
            hit_counts = args.hits
        },
        total_damage_awakening = {
            damage_numbers = args.awk_dmg or args.dmg,
            hit_counts = args.awk_hits or args.hits
        },
        average_damage = {
            damage_numbers = args.dmg,
            hit_counts = args.avg_hits
        },
        average_damage_awakening = {
            damage_numbers = args.awk_dmg or args.dmg,
            hit_counts = args.avg_awk_hits or args.hits
        },
        -- Store the logic for Useful traits
        total_damage_useful = {
            damage_numbers = args.dmg,
            hit_counts = args.hits_useful or args.hits
        },
        total_damage_awakening_useful = {
            damage_numbers = args.awk_dmg or args.dmg,
            hit_counts = args.awk_hits_useful or args.awk_hits or args.hits_useful or args.hits
        },
        average_damage_useful = {
            damage_numbers = args.dmg,
            hit_counts = args.avg_hits_useful or args.avg_hits
        },
        average_damage_awakening_useful = {
            damage_numbers = args.awk_dmg or args.dmg,
            hit_counts = args.avg_awk_hits_useful or args.avg_awk_hits or args.hits_useful or args.hits
        },
    }
 
    --[[
    Change how args are received.
    dmg = 500, 700, 800 (string) -> dmg = { 500, 700, 800 } (table)
    --]]
     for k, v in pairs(args) do
        -- We don't want passives that contain a comma in their names to be included in this.
         if not string.find(k, 'passive') and not string.find(k, 'combine') then
             args[k] = split(v)
         end
         end
     end
     end
   
    return tostring(infobox);


    function dump(tbl)
        local ret = {}
        for k, v in pairs(args) do
            table.insert(ret, k .. ': ' .. inspect(v))
        end
        return frame:preprocess(table.concat(ret, "<br/>"))
    end
    -- Dump all values if wanted.
    if args.dump == 'true' then
        return dump(args)
    end
    -- return frame:preprocess('<pre><nowiki>' .. inspect(args) .. '</nowiki></pre>')
end
end


return p
return p

Latest revision as of 15:22, 17 June 2024

Documentation for this module may be created at Module:Test/doc

require('Module:CommonFunctions')
require('Module:InfoboxProto');
local getArgs = require('Module:Arguments').getArgs
local p = {}

-- Main process
function p.main(frame)
    local args = getArgs(frame);
    local infobox = require('Module:InfoboxProto').main(frame, args.title);
    local divclass = args.divclass;
    if divclass == nil then
        divclass = 'custom'
    end
    infobox:addClass('infobox-' .. divclass);

    for k, v in spairs(args) do
        if string.match(k, 'data[0-9]+') ~= nil then
            local i = k:gsub('data', '');
            addField('data' .. i, args['label' .. i])
        end
    end
    
    return tostring(infobox);

end

return p