Модуль:UnitData
Данная группа модулей хранит информацию обо всех юнитах из Крушителей подземелий. Перечень модулей:
- Модуль:UnitData - основные функции
- Модуль:UnitData/data - массив данных о юнитах
- Модуль:UnitData/getter - сборщик данных о юнитах
Информация из Модуль:UnitData/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:UnitData/getter') local unit = args['unit'] or args[1] local datatype = args['datatype'] or args[2] local output = args['output'] or args[3] or nil local result = get[datatype](unit) 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.getUnitAbility(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local get = require ('Module:UnitData/getter') local unit = args['unit'] or args[1] local ability = "abilities" local str = "" local result = get[ability](unit) for k, v in ipairs(result) do if tonumber(args['index']) == k then str = mw.ustring.format('%s/%s/%s/%s', v[1], v[2], v[3], v[4]) end end return str end function p.getUnitSource(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local get = require ('Module:UnitData/getter') local data = require ('Module:RecipeData/data') local loot_data = require ('Module:ItemData/loot') local boss_data = require ('Module:BossData/data') local item_data = require ('Module:ItemData/data') local unit = args['unit'] or args[1] local source = "source" local str = mw.ustring.format('<h2>Способ получения</h2>') local result = get[source](unit) local data = data[unit] if (result == "Крафт") then if (data) == nil then return "" end str = str .. mw.ustring.format('<div class="recipes">') for k, v in ipairs(data) do str = str .. mw.ustring.format('{{rp|%s|%d}}', item, k) end str = str .. mw.ustring.format('</div>') elseif (result == "Сундук") then str = str .. mw.ustring.format('<div class="chests" style="width:fit-content; width: -moz-fit-content">') for k, v in ipairs(loot_data) do for k1, v1 in ipairs(v) do if (v[k1][1] == item) then for k2, v2 in pairs(item_data) do for k3, v3 in pairs(item_data[k2]["loot"]) do if (v3[1] == k) then str = str .. mw.ustring.format('%s', libItem.getItemIcon(k2, "100px")) end end end end end end str = str .. mw.ustring.format('</div>') elseif (result == "Босс") then str = str .. mw.ustring.format('<div class="bosses" style="width:fit-content; width: -moz-fit-content">') for k, v in pairs(boss_data) do for k2, v2 in pairs(boss_data[k]["loot"]) do if (v2[1] == item) then str = str .. mw.ustring.format('[[Файл:%s|100px|ссылка=%s/босс]]', boss_data[k]["icon"], k) end end end str = str .. mw.ustring.format('</div>') elseif (result == "Крафт/Сундук") then str = str .. mw.ustring.format('<div class="recipes">') for k, v in ipairs(data) do str = str .. mw.ustring.format('{{rp|%s|%d}}', item, k) end str = str .. mw.ustring.format('</div>') str = str .. mw.ustring.format('<div class="chests" style="width:fit-content; width: -moz-fit-content">') for k, v in ipairs(loot_data) do for k1, v1 in ipairs(v) do if (v[k1][1] == item) then for k2, v2 in pairs(item_data) do for k3, v3 in pairs(item_data[k2]["loot"]) do if (v3[1] == k) then str = str .. mw.ustring.format('%s', libItem.getItemIcon(k2, "100px")) end end end end end end str = str .. mw.ustring.format('</div>') elseif (result == "Крафт/Босс") then str = str .. mw.ustring.format('<div class="recipes">') for k, v in ipairs(data) do str = str .. mw.ustring.format('{{rp|%s|%d}}', item, k) end str = str .. mw.ustring.format('</div>') str = str .. mw.ustring.format('<div class="bosses" style="width:fit-content; width: -moz-fit-content">') for k, v in pairs(boss_data) do for k2, v2 in pairs(boss_data[k]["loot"]) do if (v2[1] == item) then str = str .. mw.ustring.format('[[Файл:%s|100px|ссылка=%s/босс]]', boss_data[k]["icon"], k) end end end str = str .. mw.ustring.format('</div>') elseif (result == "Сундук/Босс") then str = str .. mw.ustring.format('<div class="chests" style="width:fit-content; width: -moz-fit-content">') for k, v in ipairs(loot_data) do for k1, v1 in ipairs(v) do if (v[k1][1] == item) then for k2, v2 in pairs(item_data) do for k3, v3 in pairs(item_data[k2]["loot"]) do if (v3[1] == k) then str = str .. mw.ustring.format('%s', libItem.getItemIcon(k2, "100px")) end end end end end end str = str .. mw.ustring.format('</div>') str = str .. mw.ustring.format('<div class="bosses" style="width:fit-content; width: -moz-fit-content">') for k, v in pairs(boss_data) do for k2, v2 in pairs(boss_data[k]["loot"]) do if (v2[1] == item) then str = str .. mw.ustring.format('[[Файл:%s|100px|ссылка=%s/босс]]', boss_data[k]["icon"], k) end end end str = str .. mw.ustring.format('</div>') end return frame:preprocess(tostring(str)) end function p.getIconUnit(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local unit_data = require ('Module:UnitData/data') local rarity_data = require ('Module:ItemData/rarities') local rarity, icon, size, count = "" if args['size'] == nil then size = "30px" else size = args['size'] end if args['count'] == nil then count = "" else count = args['count'] end if args['link'] == nil then link = "" else link = args['link'] end if args['caption'] == nil then caption = "" else caption = args['caption'] end if lib.lookup(unit_data, args['unit']) then icon = unit_data[args['unit']]["icon"] else return args['unit'] end if rarity_data[unit_data[args['unit']]["rarity"]] and rarity_data[unit_data[args['unit']]["rarity"]] ~= nil then rarity = rarity_data[unit_data[args['unit']]["rarity"]] else rarity = "обычный" end return frame:preprocess(mw.ustring.format('{{ii|%s|%s|%s|size=%s|count=%s|link=%s|caption=%s}}', args['unit'], icon, rarity, size, count, link, caption)) end function p.getAllianceIcon(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local icons_data = require ('Module:IconData/alliances') local alliance = args['alliance'] or args[1] local size = args['size'] or args[2] local icon = "" local str = "" if icons_data[alliance] ~= nil then icon = icons_data[alliance] else return "-" end str = mw.ustring.format('[[Файл:%s|%s|link=:Категория:%s (альянс)]]', icon, size, alliance) return frame:preprocess(tostring(str)) end function p.getUnitIcon(item, size, count, link) local unit_data = require ('Module:UnitData/data') local rarity_data = require ('Module:ItemData/rarities') local rarity, icon = "" if size == nil then size = "30px" end if count == nil then count = "" end if link == nil then link = "" end if lib.lookup(unit_data, unit) then icon = unit_data[unit]["icon"] else return unit end if rarity_data[item_data[unit]["rarity"]] and rarity_data[item_data[unit]["rarity"]] ~= nil then rarity = rarity_data[item_data[unit]["rarity"]] else rarity = "обычный" end return mw.ustring.format('{{ui|%s|%s|%s|size=%s|count=%s|link=%s}}', unit, icon, rarity, size, count, link) end return p