FANDOM


local Achievements = {}
----------------------------
-- Libraries of functions --
----------------------------
-- Loads high frequency functions
local HF = require('Module:HF')
 
-- Parses invocation and template parameters, trims whitespace, and removes blanks.
local getArgs = require('Dev:Arguments').getArgs
 
-- Language functions for the default language
local lang = mw.language.getContentLanguage()
 
-- Wikitext lists
local L = require( 'Dev:List' )
 
function Achievements.category(frame)
    local args = getArgs(frame)
    local categorymain = args['maincategory']
    if not categorymain then return nil end
    local categories = {}
    for category in mw.text.gsplit(categorymain, '%s*;%s*') do
        table.insert(categories, HF.Link(category..' achievements',category)..HF.Category(category..' achievements'))
    end
    if #categories > 1 then
        return L.makeList('bulleted', categories)
    else
        return categories[1]:lower() == 'none' and 'None'..HF.Category('Achievements not in interface') or categories[1]
    end
end
function Achievements.subcategory(frame)
    local args = getArgs(frame)
    local CM = args['maincategory']
    local _SC = args['subcategory']
    if not CM or not _SC then return nil end
    local subcategories = {}
    local out = {}
    local maincategories = mw.text.split(CM, '%s*;%s*')
    for subcat_group in mw.text.gsplit(_SC, '%s*;%s*') do
        local subcats = mw.text.split(subcat_group, '%s*,%s*')
        table.insert(subcategories, subcats)
    end
    if #subcategories == 1 and #subcategories[1] == 1 and subcategories[1] then return string.lower(subcategories[1][1]) == 'no' and 'No' or HF.Link(subcategories[1][1]..' achievements',subcategories[1][1])..HF.Category(subcategories[1][1]..' achievements') end
    for MC,SC in ipairs(subcategories) do
        for item in ipairs(SC) do
            item = SC[item]
            table.insert(out, item:lower() == 'no' and 'No' or HF.Link(item..' achievements',item)..HF.Category(item..' achievements') ..
                (#maincategories > 1 and (' (%s)'):format(maincategories[MC]) or '')
            )
        end
    end
    return out and L.makeList('bulleted',out)
end
return Achievements
Community content is available under CC-BY-SA unless otherwise noted.