Module:Test: Difference between revisions

From Elwiki
No edit summary
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 p = {}
local p = {}
Line 6: Line 7:
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 dump(o)
     local divclass = args.divclass;
        if type(o) == 'table' then
     if divclass == nil then
            local s = '{ <br>'
         divclass = 'custom'
            for k, v in pairs(o) do
                if type(k) ~= 'number' then
                    k = '"' .. k .. '"'
                end
                s = s .. '[' .. k .. '] = ' .. dump(v) .. ',<br>'
            end
            return s .. '}'
        else
            return tostring(o)
        end
    end
 
    -- Argument init
     local traits = args[3]
     if (traits == nil) then
         traits = '-, -'
    end
    traits = split(traits);
    local skill = args[2]
 
    -- Define the class blueprint for traits.
    Trait = {
        name = "",
        multipliers = {
            mp_cost = 100,
            cooldown = 100
        },
        details = {
            mp_cost = {0, 0},
            cooldown = {0, 0},
            duration = {0, 0}
        }
    }
 
    function Trait:new(t)
        t = t or {}
 
        x = {}
        x.multipliers.duration = 555
 
        self.__index = x
        setmetatable(t, self)
       
        return t
     end
     end
    infobox:addClass('infobox-' .. divclass);


     function Trait:math()
     for k, v in spairs(args) do
        for k, v in pairs(self.details) do
        if string.match(k, 'data[0-9]+') ~= nil then
             for i = 1, 2, 1 do
             local i = k:gsub('data', '');
                self.details[k][i] = v[i] * (self.multipliers[k] / 100)
            addField('data' .. i, args['label' .. i])
            end
         end
         end
        return self
     end
     end
 
      
    local data = {
     return tostring(infobox);
        mp_cost = {{300, 300}, 60},
        cooldown = {{22, 50}, 150},
        duration = {{10, 3}, 100}
    }
 
    -- Define the mother object of traits.
    local reversed = Trait:new({
        name = "Reversed",
        multipliers = {
            mp_cost = data.mp_cost[2],
            cooldown = data.cooldown[2],
            duration = 300
        },
        details = {
            mp_cost = data.mp_cost[1],
            cooldown = data.cooldown[1]
        }
    })
 
     -- Output point
     -- return tostring(trait_table);
    return dump(reversed:math());


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