Module:Item Drop
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Item Drop/doc
local p = {}
local cargo = mw.ext.cargo
local func = require('Module:Func')
function p.item_drop(frame)
local acquisition = {}
local item = mw.text.jsonDecode(frame:callParserFunction("#var", { "itemData" }))
table.insert(acquisition, string.format("\n== Item Acquisition ==\n"))
if item.Item_Rarity == "Runeword" then
table.insert(acquisition, string.format('<p>%s has restrictions on where and how it can drop. It can be crafted using the Runeword recipe below.</p>', item.Item_Name))
elseif item.Item_Restricted_Drop == '1' and item.Item_Craftable == '0' then
--local where = string.format("Item_Name = '%s'", p.encodeName(item.Item_Name))
local drops, queryError = cargo.query(
'boss_drops',
'Boss_Name, Hell_5',
{
where = "Item_Name = '" .. func.encodeName(item.Item_Name) .. "'",
}
)
if #drops > 0 then
for _, drop in ipairs(drops) do
if drop and drop ~= "" then
table.insert(acquisition, string.format('<p>%s has restrictions on where and how it can drop. It cannot be crafted.', item.Item_Name))
table.insert(acquisition, '<p>Drops from the following Boss</p>')
table.insert(acquisition, string.format('<ul><li>[[%s]]</li></ul>', drop.Boss_Name or ""))
else
table.insert(acquisition, string.format('<p>No Results</p>'))
end
end
else
table.insert(acquisition, string.format('<p>%s has restrictions on where and how it can drop. It cannot be crafted.', item.Item_Name))
end
elseif item.Item_Craftable == '1' and item.Item_Restricted_Drop == '1' then
table.insert(acquisition, string.format('<p>%s has restrictions on where and how it can drop. It can be crafted.', item.Item_Name))
elseif item.Item_Restricted_Drop == '0' and item.Item_Craftable == '1' then
table.insert(acquisition, string.format('<p>%s has no restrictions on where it can drop. It can be crafted.</p>', item.Item_Name))
elseif item.Item_Restricted_Drop == '0' and item.Item_Craftable == '0' then
table.insert(acquisition, string.format('<p>%s has no restrictions on where it can drop. It cannot be crafted.</p>', item.Item_Name))
end
table.insert(acquisition, p.zoneDrops(item))
return table.concat(acquisition)
end
function p.zoneDrops(item)
local zone_drops = {}
--local where = string.format("Item_Name = '%s'", p.encodeName(item.Item_Name))
local cargo = mw.ext.cargo
local drops, queryError = cargo.query(
'zone_drops',
'Zone_Name',
{
where = "Item_Name = '" .. func.encodeName(item.Item_Name) .. "'",
}
)
if #drops > 0 then
for _, drop in ipairs(drops) do
table.insert(zone_drops, "<p>Has increased drop chance in</p>")
table.insert(zone_drops, string.format('<ul><li>[[%s]]</li></ul>', drop.Zone_Name or ""))
end
end
return table.concat(zone_drops)
end
return p