Модуль:Prototypes/Роль: различия между версиями

мНет описания правки
Нет описания правки
 
(не показано 9 промежуточных версий этого же участника)
Строка 6: Строка 6:
-- Обёртка для вызова перевода
-- Обёртка для вызова перевода
local function translate(value)
local function translate(value)
return "{{#invoke:Ftl|main|translation|" .. value .. "}}"
return "{{ucfirst:{{#invoke:Ftl|main|translation|" .. value .. "}}}}"
end
end


-- Обёртка для доступа
-- Обёртка для доступа
local function wrapAccess(value)
local function wrapAccess(value)
return "{{#invoke:Prototypes/Механика/Доступ|main|}}" .. value .. ""
return "{{#invoke:Prototypes/Механика/Доступ|main|translate|" .. value .. "}}"
end
end


-- Форматирование времени
-- Форматирование времени
local function formatTime(seconds)
local function formatTime(time)
return "{{#invoke:Code/Формат/Время|main|seconds|" .. seconds .. "}}"
return "{{#invoke:Code/Формат/Время|main|" .. time .. "}}"
end
end


Строка 43: Строка 43:
if mode == "requirements" then
if mode == "requirements" then
if job.requirements then
    if job.requirements then
for _, req in ipairs(job.requirements) do
        for _, req in ipairs(job.requirements) do
if req["!type"] == "DepartmentTimeRequirement" and req.department and req.time then
            if req["!type"] == "DepartmentTimeRequirement" and req.department and req.time then
result = result .. "<b>{{ucfirst:{{#invoke:Ftl|main|translation|department-" .. req.department .. "}}}}</b>: " ..
                result = result .. "<li>[[{{ucfirst:{{#invoke:Ftl|main|translation|department-" .. req.department .. "}}}}]]: " ..
formatTime(req.time) .. "<br>"
                    formatTime(req.time) .. "</li>"
elseif req["!type"] == "RoleTimeRequirement" and req.role and req.time then
            elseif req["!type"] == "RoleTimeRequirement" and req.role and req.time then
result = result .. "<b>{{ucfirst:{{#invoke:Ftl|main|translation|" .. req.role .. "}}}}</b>: " ..
                result = result .. "<li>[[{{ucfirst:{{#invoke:Ftl|main|translation|" .. req.role .. "}}}}]]: " ..
formatTime(req.time) .. "<br>"
                    formatTime(req.time) .. "</li>"
end
            elseif req["!type"] == "OverallPlaytimeRequirement" and req.time then
end
                result = result .. "<li>Общее время: " .. formatTime(req.time) .. "</li>"
end
            end
        end
    end
    result = "<ul>" .. result .. "</ul>"
   
elseif mode == "access" then
elseif mode == "access" then
if job.access then
    local accesses = {}
for _, access in ipairs(job.access) do
    if job.accessGroups then
result = result .. wrapAccess(access)
        local groups = type(job.accessGroups[1]) == "table" and job.accessGroups or { job.accessGroups }
end
        for _, group in ipairs(groups) do
end
            for _, access in ipairs(group) do
                table.insert(accesses, wrapAccess(access))
            end
        end
    elseif job.access then
        for _, access in ipairs(job.access) do
            table.insert(accesses, wrapAccess(access))
        end
    end
    result = table.concat(accesses, ", ")
 
elseif mode == "name" then
elseif mode == "name" then
if job.name then
if job.name then