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

мНет описания правки
мНет описания правки
Строка 24: Строка 24:
local function formatPercentage(value)
local function formatPercentage(value)
return value and round((1 - value) * 100) .. "%" or "-"
return value and round((1 - value) * 100) .. "%" or "-"
end
-- Функция для создания строк для таблицы по типу защиты
local function createProtectionRow(class, color, value)
return '|class="' .. class .. '" style="font-weight:bold;color: ' .. color .. ';"|' .. value .. '\n'
end
end


Строка 33: Строка 38:
-- Получаем защитные значения из coefficients, если они присутствуют
-- Получаем защитные значения из coefficients, если они присутствуют
local coefficients = itemData and itemData.coefficients
local coefficients = itemData and itemData.coefficients
local protBlunt = formatPercentage(coefficients and coefficients.Blunt)
local protBlunt = formatPercentage(coefficients and coefficients.Blunt)
local protSlash = formatPercentage(coefficients and coefficients.Slash)
local protSlash = formatPercentage(coefficients and coefficients.Slash)
Строка 53: Строка 57:
local sprintPercent = round((1 - sprintModifier) * 100)
local sprintPercent = round((1 - sprintModifier) * 100)
local walkPercent = round((1 - walkModifier) * 100)
local walkPercent = round((1 - walkModifier) * 100)
 
if sprintModifier == walkModifier then
speedDescription = "* Понижает скорость " .. (sprintModifier == walkModifier and "передвижения" or "бега и ходьбы") ..  
speedDescription = "* Понижает скорость передвижения на <span style=\"color:yellow\">'''" .. sprintPercent .. " %'''</span>\n"
  " на <span style=\"color:yellow\">'''" .. sprintPercent .. " %'''</span>\n"
else
if sprintModifier ~= walkModifier then
speedDescription = "* Понижает скорость бега на <span style=\"color:yellow\">'''" .. sprintPercent .. " %'''</span>\n"
speedDescription = speedDescription .. "* Понижает скорость ходьбы на <span style=\"color:yellow\">'''" .. walkPercent .. " %'''</span>\n"
speedDescription = speedDescription .. "* Понижает скорость ходьбы на <span style=\"color:yellow\">'''" .. walkPercent .. " %'''</span>\n"
end
end
Строка 63: Строка 66:


-- Формируем сообщение для огневой защиты, если значение присутствует
-- Формируем сообщение для огневой защиты, если значение присутствует
local fireProtectionDescription = ""
local fireProtectionDescription = fireProtection and
if fireProtection then
"* Имеет огневую защиту в <span style=\"color:OrangeRed\">'''" .. round((1 - fireProtection) * 100) .. " %'''</span>\n" or ""
local fireProtectionPercent = round((1 - fireProtection) * 100)
fireProtectionDescription = "* Имеет огневую защиту в <span style=\"color:OrangeRed\">'''" .. fireProtectionPercent .. " %'''</span>\n"
end


-- Формируем сообщение для сопротивления к критическим температурам, если значение присутствует
-- Формируем сообщение для сопротивления к критическим температурам, если значение присутствует
local temperatureProtectionDescription = ""
local temperatureProtectionDescription = temperatureProtection and
if temperatureProtection then
"* Имеет значительное сопротивление к критическим температурам\n" or ""
temperatureProtectionDescription = "* Имеет значительное сопротивление к критическим температурам\n"
end


-- Описание и местоположение
-- Описание и местоположение
Строка 85: Строка 83:


-- Формирование строк для ячеек таблицы
-- Формирование строк для ячеек таблицы
local out = ""
local out = ''
out = out .. '!class="' .. class .. '" style="background-color: ' .. backgroundColor .. ';"|' .. frame:preprocess('{{Anchor|' .. anchorName .. '}}')  
out = out .. '!class="' .. class .. '" style="background-color: ' .. backgroundColor .. ';"|' .. frame:preprocess('{{Anchor|' .. anchorName .. '}}')  
out = out .. frame:preprocess('{{#invoke:Entity Lookup|createimagetooltip|File:' .. id .. '|' .. id .. '|Мета=64x64px}}')
out = out .. frame:preprocess('{{#invoke:Entity Lookup|createimagetooltip|File:' .. id .. '|' .. id .. '|Мета=64x64px}}')
out = out .. '<br>' .. frame:preprocess('{{#invoke:Entity Lookup|getname|' .. id .. '}}') .. '\n'
out = out .. '<br>' .. frame:preprocess('{{#invoke:Entity Lookup|getname|' .. id .. '}}') .. '\n'
out = out .. '|class="' .. class .. '" style="font-weight:bold;color: crimson;"|' .. protBlunt .. '\n'
 
out = out .. '|class="' .. class .. '" style="font-weight:bold;color: indianred;"|' .. protSlash .. '\n'
-- Используем функцию для формирования строк защиты
out = out .. '|class="' .. class .. '" style="font-weight:bold;color: darksalmon;"|' .. protPiercing .. '\n'
out = out .. createProtectionRow(class, "crimson", protBlunt)
out = out .. '|class="' .. class .. '" style="font-weight:bold;color: orange;"|' .. protHeat .. '\n'
out = out .. createProtectionRow(class, "indianred", protSlash)
out = out .. '|class="' .. class .. '" style="font-weight:bold;color: plum;"|' .. protCaustic .. '\n'
out = out .. createProtectionRow(class, "darksalmon", protPiercing)
out = out .. '|class="' .. class .. '" style="font-weight:bold;color: limegreen;"|' .. protRadiation .. '\n'
out = out .. createProtectionRow(class, "orange", protHeat)
out = out .. '|class="' .. class .. '" style="font-weight:bold;color: tan;"|' .. protExplosion .. '\n'
out = out .. createProtectionRow(class, "plum", protCaustic)
out = out .. createProtectionRow(class, "limegreen", protRadiation)
out = out .. createProtectionRow(class, "tan", protExplosion)
 
out = out .. '|class="' .. class .. '" style=""|\n' .. description .. '\n'
out = out .. '|class="' .. class .. '" style=""|\n' .. description .. '\n'
out = out .. '|class="' .. class .. '" style=""|\n'
-- Местоположение
-- Местоположение
out = out .. '|class="' .. class .. '" style=""|\n'
if location ~= "" then
if location ~= "" then
out = out .. frame:preprocess('{{SlideMenu|overlay|color=#e1f6ff|title=Список [[File:Examine.svg.192dpi.png|24x24px]]|content=<p></p>\n' .. location .. '}}\n')
out = out .. frame:preprocess('{{SlideMenu|overlay|color=#e1f6ff|title=Список [[File:Examine.svg.192dpi.png|24x24px]]|content=<p></p>\n' .. location .. '}}\n')
Строка 109: Строка 111:
out = out .. frame:preprocess('{{FrameText|color=#82d1c4|content=Нет гарантированных мест спавна}}\n')
out = out .. frame:preprocess('{{FrameText|color=#82d1c4|content=Нет гарантированных мест спавна}}\n')
end
end
 
out = out .. '|-\n'
out = out .. '|-\n'