Модуль:Песочница/Pok: различия между версиями

мНет описания правки
мНет описания правки
Строка 15: Строка 15:
end
end
return results
return results
end
-- Функция для поиска исследования по ID
local function findResearchById(dataCache, id)
for _, research in ipairs(dataCache) do
if research.technology and research.technology.id == id then
return research.technology
end
end
return nil
end
end


Строка 41: Строка 51:
local discipline = frame.args[1] or ""
local discipline = frame.args[1] or ""


if discipline then
if discipline and discipline ~= "" then
-- Если это дисциплина, выводим все исследования данной группы
-- Инициализация строки вывода
local out = cssLink .. '<div class="research-group">'
 
-- Получаем список исследований по дисциплине
local researches = findResearchByDiscipline(dataCache, discipline)
local researches = findResearchByDiscipline(dataCache, discipline)


Строка 50: Строка 63:
local iconPath = tech.icon.sprite
local iconPath = tech.icon.sprite


out = out .. '<div class="research" id="' .. tech.discipline .. '">'
-- Основной блок исследования
out = out .. '<div class="research" id="' .. tech.id .. '">'
out = out .. '<div class="research__images">{{#invoke:Entity Sprite|main|path|' .. iconPath .. '}}</div>'
out = out .. '<div class="research__images">{{#invoke:Entity Sprite|main|path|' .. iconPath .. '}}</div>'
out = out .. '<div class="research__name">' .. tech.name .. '[[Файл:' .. tech.discipline .. '.png|16px|link=]]</div>'
out = out .. '<div class="research__name">' .. tech.name .. '[[Файл:' .. tech.discipline .. '.png|16px|link=]]</div>'
Строка 58: Строка 72:
out = out .. '<div>Стоимость: <span style="color:#DA70D6;">' .. tech.cost .. '</span></div>'
out = out .. '<div>Стоимость: <span style="color:#DA70D6;">' .. tech.cost .. '</span></div>'
out = out .. '</div>'
out = out .. '</div>'
out = out .. '</div>'
end


-- Блок необходимых исследований
-- Блок необходимых исследований
if tech.technologyPrerequisites and #tech.technologyPrerequisites > 0 then
if tech.technologyPrerequisites and #tech.technologyPrerequisites > 0 then
out = out .. '<div class="research__technologies-prerequisites">Необходимые исследования:'
out = out .. '<div class="research__technologies-prerequisites">Необходимые исследования:'
out = out .. '<ul>'
out = out .. '<ul>'
 
for _, prerequisiteId in ipairs(tech.technologyPrerequisites) do
for _, prerequisiteId in ipairs(tech.technologyPrerequisites) do
local prerequisiteTech = findResearchById(dataCache, prerequisiteId)
local prerequisiteTech = findResearchById(dataCache, prerequisiteId)
 
if prerequisiteTech then
if prerequisiteTech then
out = out .. '<li>' .. prerequisiteTech.name .. '</li>'
out = out .. '<li>' .. prerequisiteTech.name .. '</li>'
else
else
out = out .. '<li>Неизвестное исследование (' .. prerequisiteId .. ')</li>'
out = out .. '<li>Неизвестное исследование (' .. prerequisiteId .. ')</li>'
end
end
end
out = out .. '</ul>'
out = out .. '</div>'
end
end
 
out = out .. '</ul>'
-- Блок открываемых рецептов
out = out .. '</div>'
if tech.recipeUnlocks and #tech.recipeUnlocks > 0 then
else
out = out .. '<div class="research__technologies-unlocks">Разблокирует:'
out = out .. ''
out = out .. '<ul>'
end
 
for _, recipe in ipairs(tech.recipeUnlocks) do
-- Блок открываемых рецептов
out = out .. '<li>' .. recipe .. '</li>'
if tech.recipeUnlocks and #tech.recipeUnlocks > 0 then
end
out = out .. '<div class="research__technologies-unlocks">Разблокирует:'
 
out = out .. '<ul>'
out = out .. '</ul>'
out = out .. '</div>'
for _, recipe in ipairs(tech.recipeUnlocks) do
out = out .. '<li>' .. recipe .. '</li>'
end
end
 
out = out .. '</ul>'
out = out .. '</div>'
out = out .. '</div>'
else
out = out .. '<div class="research__technologies-unlocks">Не разблокирует ничего.</div>'
end
end


out = out .. '</div>'
return out
return out
else
else