Модуль:Местонахождение: различия между версиями

мНет описания правки
мНет описания правки
Строка 74: Строка 74:
-- Формирование ссылки для роли/джоба (reverseEquipment)
-- Формирование ссылки для роли/джоба (reverseEquipment)
local function createJobLink(jobId)
local function createJobLink(jobId)
     local translation = "{{#invoke:Ftl|main|translation|" .. jobId .. "}}"
     local translation = "{{#invoke:Ftl|main|translation|Job" .. jobId .. "}}"
     return "[[" .. translation .. "|{{ucfirst:" .. translation .. "}}]]"
     return "[[" .. translation .. "|{{ucfirst:" .. translation .. "}}]]"
end
end
Строка 188: Строка 188:


     local resultsMap = {}
     local resultsMap = {}
--[[
 
     -- Обработка startingGear (gearData)
     -- Обработка startingGear (gearData)
     for _, gear in pairs(gearData) do
     for _, gear in pairs(gearData) do
        local currentGearId = gear.id or "Unknown"
         if gear.equipment then
         if gear.equipment then
             for slot, equipId in pairs(gear.equipment) do
             for slot, equipId in pairs(gear.equipment) do
                 if equipId == targetId and (not slotFilter or slot == slotFilter) then
                 if equipId == targetId and (not slotFilter or slot == slotFilter) then
                     for jobId, job in pairs(jobData) do
                     local gearId = gear.id
                        if job.startingGear == currentGearId then
                    if gearId then
                            resultsMap[jobId] = true
                        for _, job in ipairs(jobData) do
                             break
                            if job.startingGear == gearId then
                                resultsMap[job.id] = true
                             end
                         end
                         end
                     end
                     end
Строка 205: Строка 206:
         end
         end
     end
     end
]]
     -- loadout + loadoutGroup + roleLoadout
     -- для loadout + loadoutGroup + roleLoadout
     for _, loadout in pairs(loadoutData) do
     for _, loadout in pairs(loadoutData) do
         if loadout.equipment then
         if loadout.equipment then
             for slot, equipId in pairs(loadout.equipment) do
             for slot, equipId in pairs(loadout.equipment) do
                 if equipId == targetId and (not slotFilter or slot == slotFilter) then
                 if equipId == targetId and (not slotFilter or slot == slotFilter) then
                    -- для каждого loadout ищем все группы, где он упоминается
                     for _, group in pairs(loadoutGroupData) do
                     for _, group in pairs(loadoutGroupData) do
                         if group.loadouts and type(group.loadouts) == "table" then
                         if group.loadouts and type(group.loadouts) == "table" then
                             for _, lId in ipairs(group.loadouts) do
                             for _, lId in ipairs(group.loadouts) do
                                 if lId == loadout.id then
                                 if lId == loadout.id then
                                    -- для каждой найденной группы ищем все роли
                                     for _, role in pairs(gearRoleLoadout) do
                                     for _, role in pairs(gearRoleLoadout) do
                                         if role.groups and type(role.groups) == "table" then
                                         if role.groups and type(role.groups) == "table" then
                                             for _, g in ipairs(role.groups) do
                                             for _, g in ipairs(role.groups) do
                                                 if g == group.id then
                                                 if g == group.id then
                                                     resultsMap[role.id] = true
                                                     local moduleKey = role.id:gsub("^Job", "")
                                                    resultsMap[moduleKey] = true
                                                 end
                                                 end
                                             end
                                             end
Строка 234: Строка 233:
         end
         end
     end
     end


     -- Собираем результаты, убираем дубликаты
     -- Собираем результаты, убираем дубликаты
Строка 264: Строка 264:


     if #directCargo > 0 then
     if #directCargo > 0 then
local links = {}
        local links = {}
for _, storage in ipairs(directCargo) do
        for _, storage in ipairs(directCargo) do
table.insert(links, createCargoLink(storage))
            table.insert(links, createCargoLink(storage))
end
        end
return table.concat(links, ", ")
        return table.concat(links, ", ")
     end
     end