Для документации этого модуля может быть создана страница Модуль:Test/doc
local itemIcon = require('Модуль:Item_icon')
local item_acquisition = require('Модуль:Item/Item acquisition')
local p = {}
function p.equipmentTable( frame )
local cargo = mw.ext.cargo
local tables = 'Items'
local fields = '_pageName, name, icon, quality, level, item_min_level, requires_class, categories, categories__full, item_use, equip, stat_power, stat_accuracy, stat_combat_advantage, stat_crit_chance, stat_critical_severity, item_defense, stat_awareness, stat_crit_resist, stat_deflect, stat_deflect_sev, stat_forte, utility_control_bonus, utility_control_resist, utility_incoming_healing, outhealing, module, locations'
local args = {
where = 'categories HOLDS "Голова" OR categories HOLDS "Доспехи" OR categories HOLDS "Руки" OR categories HOLDS "Ноги" OR categories HOLDS "Кольцо" OR categories HOLDS "Рубаха" OR categories HOLDS "Штаны"',
limit = '100',
format = 'dynamic table',
orderBy = '_pageName',
}
local result = cargo.query( tables, fields, args )
local r = result[1]
local current_number_of_items = #result
local tbl = mw.html.create('table')
tbl:addClass('wikitable sortable jquery-tablesorter'):attr("id", "equipment-table"):attr("style", "width: 100%;")
tbl:tag("th"):attr("tabindex", 0):attr("style", "width: 40%;"):attr("tabindex", 0):wikitext("Имя"):done()
tbl:tag("th"):attr("tabindex", 0):wikitext("Категория"):done()
tbl:tag("th"):attr("tabindex", 0):wikitext("Ур. предмета"):done()
tbl:tag("th"):attr("tabindex", 0):wikitext("Мин. уровень"):done()
tbl:tag("th"):attr("tabindex", 0):wikitext("Получение"):done()
tbl:tag("th"):attr("tabindex", 0):wikitext("параметры"):done()
tbl:done()
count = 0
for k,v in pairs(tbl) do
count = count + 1
end
local classIcons = {
['варвар'] = '[[Файл:Icon_Build_Player_Greatweapon.png|20px|ссылка=Варвар]]',
['воин'] = '[[Файл:Icon_Build_Player_Guardian.png|20px|ссылка=Воин]]',
['волшебник'] = '[[Файл:Icon_Build_Player_Controller.png|20px|ссылка=Волшебник]]',
['клирик'] = '[[Файл:Icon_Build_Player_Devoted.png|20px|ссылка=Клирик]]',
['следопыт'] = '[[Файл:Icon_Build_Player_Archer.png|20px|ссылка=Следопыт]]',
['плут'] = '[[Файл:Icon_Build_Player_Trickster.png|20px|ссылка=Плут]]',
['паладин'] = '[[Файл:Icon_Build_Player_Paladin.png|20px|ссылка=Паладин]]',
['чернокнижник'] = '[[Файл:Icon_Build_Player_Scourge.png|20px|ссылка=Чернокнижник]]'
}
for _, item in ipairs(result) do
local item_stats = {}
local class_name = {}
local class_icons = {}
local class_name_link = {}
local item_stats_value = {
{ name = 'Могущество', value = item.stat_power },
{ name = 'Точность', value = item.stat_accuracy },
{ name = 'Боевое преимущество', value = item.stat_combat_advantage },
{ name = 'Шанс критического удара', value = item.stat_crit_chance },
{ name = 'Критический урон', value = item.stat_critical_severity },
{ name = 'Оборона', value = item.item_defense },
{ name = 'Осведомленность', value = item.stat_awareness },
{ name = 'Критическое уклонение', value = item.stat_crit_resist },
{ name = 'Парирование', value = item.stat_deflect },
{ name = 'Сила парирования', value = item.stat_deflect_sev },
{ name = 'Сильная сторона', value = item.stat_forte },
{ name = 'Бонус к контролю', value = item.utility_control_bonus },
{ name = 'Сопротивляемость контролю', value = item.utility_control_resist },
{ name = 'Принимаемое лечение', value = item.utility_incoming_healing },
{ name = 'Исходящее лечение', value = item.outhealing },
{ name = 'Получаемые очки действия', value = item.utility_action_point_gain }
}
for i, stat in ipairs(item_stats_value) do
if stat.value ~= '' then
table.insert(item_stats, stat.name)
end
end
-- Добавляет HTML-атрибут "data-equip" с умениями экипировки
local data_equip
if item.equip ~= '' then
data_equip = item.equip
else
data_equip = "Все"
end
if item.requires_class then
for i in string.gmatch(item.requires_class, "[^%p%d%s%c]+") do
table.insert(class_name, mw.getContentLanguage():ucfirst(i))
table.insert(class_icons, classIcons[mw.ustring.lower(i)])
table.insert(class_name_link, '[[' .. mw.getContentLanguage():ucfirst(i) .. ']]')
end
end
local data_attribute_class_text
if item.requires_class ~= '' then
data_attribute_class_text = table.concat(class_name, ', ')
else
data_attribute_class_text = "Любой класс"
end
local categories = {}
for i in mw.text.gsplit(item.categories__full, ",%s*") do
table.insert(categories, mw.getContentLanguage():ucfirst(i))
end
local data_attribute_categories
if table.concat(categories, ", ") == "Кольцо, Только для спутников" or table.concat(categories, ", ") == "Только для спутников, Кольцо" then
data_attribute_categories = "Только для спутников"
else
data_attribute_categories = mw.getContentLanguage():ucfirst(item.categories)
end
local tr = tbl:tag("tr"):attr("data-subject", item.name):attr("data-level", item.item_min_level):attr("data-quality", mw.getContentLanguage():ucfirst(item.quality)):attr("data-equip", data_equip):attr("data-stats", table.concat(item_stats, ", ")):attr("data-category", data_attribute_categories):attr("data-role", data_attribute_class_text)
tr:tag("td"):wikitext('<div>' .. itemIcon.Main({args={item.name,""}}) .. '</div><div style="font-size: 13px">' .. table.concat(class_name_link, ', ') .. '</div>'):done()
--tr:tag("td"):wikitext('[[File:' .. item.icon .. '|38px]] <div>[[' .. item.name .. ']]</div><div style="font-size: 13px">' .. table.concat(class_name_link, ', ') .. '</div>'):done()
tr:tag("td"):wikitext(item.equip):done()
--tr:tag("td"):wikitext(data_attribute_categories):done()
tr:tag("td"):attr("style", "text-align:center;"):wikitext(item.level):done()
tr:tag("td"):attr("style", "text-align:center;"):wikitext(item.item_min_level):done()
--tr:tag("td"):wikitext(item_acquisition.itemAcquisition({args={item._pageName,""}})):done()
tr:tag("td"):attr("style", "text-align:center;"):wikitext(table.concat(item_stats, ", ")):done()
end
return tbl
end
return p