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