Path of Exile Wiki

Wiki поддерживается сообществом, поэтому подумайте над тем, чтобы внести свой вклад.

ПОДРОБНЕЕ

Path of Exile Wiki
Advertisement
Template info icon Документация модуля[просмотр] [править] [история] [очистить]

Реализует {{Item class infocard}}.

-------------------------------------------------------------------------------
-- 
--                        Module:Item class infocard
-- 
-- This module implements Template:Item class infocard
-------------------------------------------------------------------------------

-- ----------------------------------------------------------------------------
-- Includes
-- ----------------------------------------------------------------------------

local getArgs = require('Module:Arguments').getArgs
local m_util = require('Module:Util')

-- Should we use the sandbox version of the game data?
local use_sandbox = m_util.misc.maybe_sandbox('Item class infocard')

local m_game = use_sandbox and mw.loadData('Module:Game/sandbox') or mw.loadData('Module:Game')

local i18n = {
    page = '[[Класс предметов]]',
    info = m_util.html.abbr('(?)', 'Классы предметов помогают классифицировать предметы. Классы в основном используются для разграничения предметов или камней умений по определенному классу или для создания фильтров предметов.'),
    also_referred_to_as = 'Также упоминается как: %s',
    filterid = 'Item filter ID: %s',
    is_removed = "''Удалено из игры.''",
    long_upper = 'Полное название в верхнем регистре: %s',
    long_lower = 'Полное название в нижнем регистре: %s',

    errors = {
        invalid_class = 'Название класса предметов "%s" недопустимо.',
    },
}

-- ----------------------------------------------------------------------------
-- Exported functions
-- ----------------------------------------------------------------------------
local p = {}

function p.main(frame)
    -- Get args
    local tpl_args = getArgs(frame, {
        parentFirst = true
    })

    frame = m_util.misc.get_frame(frame)
    
    if not doInfoCard then
        doInfoCard = require('Module:Infocard')._main
    end

    local constinfo = nil
    local filterid = nil
    for id, row in pairs(m_game.constants.item.classes) do
        if row['full'] == tpl_args.name then
            constinfo = row
            filterid = id
            break
        end
    end
    
    if constinfo == nil then
        error(string.format(i18n.errors.invalid_class, tostring(tpl_args.name)))
    end

    --
    
    local infocard_args = {}

    if tpl_args.name_list ~= nil then
        tpl_args.name_list = m_util.string.split(tpl_args.name_list, ',%s*')
    else
        tpl_args.name_list = {}
    end

    local ul = mw.html.create('ul')
    for _, item in ipairs(tpl_args.name_list) do
        ul
            :tag('li')
                :wikitext(item)
                :done()
    end
    table.insert(infocard_args, string.format(i18n.also_referred_to_as, tostring(ul)))    

    if (tpl_args.verbose) then
        table.insert(infocard_args, string.format(i18n.long_upper, tostring(constinfo['long_upper'])))
        table.insert(infocard_args, string.format(i18n.long_lower, tostring(constinfo['long_lower'])))
    end
    table.insert(infocard_args, string.format(i18n.filterid, tostring(filterid)))

    if (constinfo['is_removed'] == true) then
        table.insert(infocard_args, i18n.is_removed)
    end
    
    -- Output Infocard

    infocard_args['header'] = tpl_args.name
    infocard_args['subheader'] = i18n.page .. i18n.info
    
    -- cats
    
    local cats = {
        'Классы предметов',
        tpl_args.name,
    }
    
    -- Done
    
    return doInfoCard(infocard_args) .. m_util.misc.add_category(cats, {ignore_blacklist=tpl_args.debug})
end

return p
Advertisement