Модуль:BossData
Данная группа модулей хранит информацию обо всех боссах из Крушителей подземелий. Перечень модулей:
- Модуль:BossData - основные функции
- Модуль:BossData/data - массив данных о боссах
- Модуль:BossData/getter - сборщик данных о боссах
- Модуль:BossData/types - массив данных c типами боссов
Информация из Модуль:BossData/doc
local p = {}
local lib = require('Module:Feature')
local libItem = require('Module:ItemData')
function p.get(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
local get = require ('Module:BossData/getter')
local boss = args['boss'] or args[1]
local datatype = args['datatype'] or args[2]
local output = args['output'] or args[3] or nil
local result = get[datatype](boss)
if output ~= nil and type(result) == "table" then
if output == "csv" then
return lib.tbl_concat{result}
elseif output == "custom" then
return frame:preprocess(lib.tbl_concat({result, prepend = args['prepend'], append = args['append'], separator = args['separator'], index = args["index"]}))
elseif output == "template" then
return frame:preprocess(lib.tbl_concat{result, prepend = "{{" .. args['t_name'] .. "|", append = "}}", separator = args['separator']})
end
elseif result == nil then
return ""
else
return result
end
end
function p.getBossInfo(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
local get = require ('Module:BossData/getter')
local boss = args['boss'] or args[1]
local info = "info"
local str = ""
local result = get[info](boss)
str = mw.ustring.format('%s', result)
return frame:preprocess(tostring(str))
end
function p.getBossLoot(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
local get = require ('Module:BossData/getter')
local boss = args['boss'] or args[1]
local loot = "loot"
local str = ""
local count = 0
local result = get[loot](boss)
for k, v in ipairs(result) do
if tonumber(args['index']) == k then
if v[2] == 1 then count = "" else count = v[2] end
str = mw.ustring.format('%s!%s', v[1], count)
end
end
return frame:preprocess(tostring(str))
end
function p.getBossGuards(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
local get = require ('Module:BossData/getter')
local boss = args['boss'] or args[1]
local guards = "guards"
local feature = ""
local str = ""
local result = get[guards](boss)
for k, v in ipairs(result) do
if tonumber(args['index']) == k then
for _, v1 in ipairs(v["feature"]) do
feature = lib.tbl_concat{v["feature"], separator = ","}
end
str = mw.ustring.format('%s/%s/%s', v["icon"], lib.comma_value(v["hp"]), feature)
end
end
return frame:preprocess(tostring(str))
end
function p.getBossesTable(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
local type = args['type'] or args[1]
local loot = ""
local count = 0
local tableNode = mw.html.create('table')
tableNode
:addClass('custom-table active-hover sortable')
:cssText('width: 80%; text-align: center; display: table;')
:newline()
tableNode
:tag('tr')
:css('white-space', 'nowrap')
:tag('th')
:wikitext('Имя')
:done()
:tag('th')
:attr('class', 'unsortable')
:css('width', '60px')
:wikitext('Иконка')
:done()
:tag('th')
:css('width', '80px')
:wikitext('Раса')
:done()
:tag('th')
:css('width', '80px')
:wikitext('Здоровье')
:done()
:tag('th')
:css('width', '60px')
:wikitext('Очки осады')
:done()
:tag('th')
:attr('class', 'unsortable')
:wikitext('Добыча')
:done()
:done()
local bosses = mw.loadData('Module:BossData/data')
local race = mw.loadData('Module:HeroData/races')
for k, v in lib.pairsByAlphabeticalKeys(bosses) do
if tonumber(type) == v['type'] then
for k1, v1 in ipairs(v['loot']) do
if v['loot'][k1][2] == 1 then count = nil else count = v['loot'][k1][2] end
loot = loot .. mw.ustring.format('%s', libItem.getItemIcon(v['loot'][k1][1], "30px", count))
end
local rowNode = mw.html.create('tr')
rowNode
:tag('td')
:attr('data-sort-value', k)
:wikitext(mw.ustring.format('[[%s/босс|%s]]', k, v['name']))
:done()
:tag('td')
:wikitext(mw.ustring.format('<div class="boss-icon" style="width:45px;">[[Файл:%s|45px|ссылка=%s/босс]]</div>', v['icon'], k))
:done()
:tag('td')
:attr('data-sort-value', race[v['race']])
:wikitext(mw.ustring.format(lib.ternary(v['race'] == nil, "N/A", '[[:Категория:%s (раса)|%s]]'), race[v['race']], race[v['race']]))
:done()
:tag('td')
:wikitext(mw.ustring.format('<div class="boss-hp" style="width: fit-content; margin: 0 auto;">%s</div>', lib.comma_value(v['hp'])))
:done()
:tag('td')
:attr('data-sort-value', v['points'])
:wikitext(mw.ustring.format('<div style="display: flex;">{{Очки осады}} <span class="score">%s</span></div>', v['points']))
:done()
:tag('td')
:wikitext(mw.ustring.format('<div style="display: flex; justify-content: space-evenly; width: 170px;">%s</div>', loot))
:done()
:done()
tableNode:node(rowNode):newline()
loot = ""
end
end
return frame:preprocess(tostring(tableNode))
end
function p.getBossIcon(boss, size, link)
local boss_data = require ('Module:BossData/data')
if size == nil then
size = "30px"
end
if link == nil then
link = boss
end
local icon = boss_data[boss]["icon"]
return mw.ustring.format('<div style="width:%s; border:3px ridge #3d8ac2;">[[Файл:%s|%s|ссылка=%s/босс]]</div>', size, icon, size, link)
end
function p.getIconBoss(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
local boss_data = require ('Module:BossData/data')
local icon, size, link, caption, border = ""
if args['size'] == nil then
size = "30px"
else
size = args['size']
end
if args['link'] == nil then
link = ""
else
link = args['link']
end
if args['caption'] == nil then
caption = ""
else
caption = args['caption']
end
if args['border'] == nil then
border = "1px solid #667985"
else
border = args['border']
end
if args['tooltip'] == nil then
tooltip = ""
else
if args['tooltip'] == "true" then
tooltip = args['boss']
else
tooltip = ""
end
end
if lib.lookup(boss_data, args['boss']) then
icon = boss_data[args['boss']]["icon"]
else
return args['boss']
end
return frame:preprocess(mw.ustring.format('{{BossIcon|%s|%s|size=%s|link=%s|caption=%s|border=%s|tooltip=%s}}', args['boss'], icon, size, link, caption, border, tooltip))
end
return p