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
return p