FANDOM


local p = {}
 
-- Stops page from being evaluated as wiki text
-- <nowiki>
 
--
-- list_verbose - generates verbose list entries
--
-- parameter [string] name - mod name
-- parameter [table] effects - list of effects for the mod
--
-- returns [string] - fully generated HTML list
--
function list_verbose( name, effects )
    local entry = "[[" .. name .. "]] - "
 
    for k,v in ipairs( effects ) do
        local op, val, skill = v:match( "([%+%-])(%d+) (.*)" )
 
        mw.log( op )
 
        if op == '+' then
            entry = entry .. 'adds ' .. val .. ' points to ' .. skill .. ', '
        elseif op == '-' then
            entry = entry .. 'reduces ' .. skill .. ' by ' .. val .. ' points, '
        end
    end
 
    return entry:match( "(.*), " )
end
 
--
-- generate_list - generates an HTML list
--
-- parameter [table] modifications - list of mod info for the weapon
--
-- returns [string] - fully generated HTML list
--
function generate_list( modifications )
    local list = "<ul>\n"
 
    for key,value in ipairs( modifications ) do
        list = list .. "<li>" .. list_verbose( key, value['effects'] ) .. "\n"
    end
 
    list = list .. '</ul>'
 
    return list
end
 
--
-- p.list - entry point for verbose mod list generation
--
-- parameters [table] frame - all arguments
--
-- returns [string] - fully generated HTML list
--
function p.list( frame )
    local page = tostring( frame.args[1] )
    local data = mw.loadData( page .. '/data' )
 
    return frame:preprocess( generate_list( data ) )
end
 
return p
 
-- </nowiki>