Module:Items

-- local p = {}

local data = require("Module:Items/Data") local data_e = require("Module:Equipment/Data") local all_items = data.items local all_equipment = data_e.equipment

Count function p.ItemCount local count = 0 for i in pairs(all_items) do   count = count + 1 end return count end

Item Infobox local infobox_template_item = [=[ ]=]

function p.InfoboxItem(frame) local item_name = frame.args[1] local item = all_items[item_name] return frame:preprocess(string.format(infobox_template_item, item_name, item_name, item.Rarity, item.Desc, Stacking(item.Stacking), Category(item.Category), (item.Unlock == "" or item.Unlock == nil) and "" or "" .. item.Unlock .. "", item.ID, item.Quote )) end

Equipment Infobox local infobox_template_equipment = [=[ ]=]

function p.InfoboxEquipment(frame) local equipment_name = frame.args[1] local equipment = all_equipment[equipment_name] return frame:preprocess(string.format(infobox_template_equipment, equipment_name, equipment_name, equipment.Rarity, equipment.Desc, equipment.Cooldown and equipment.Cooldown .. "s" or "", (equipment.Unlock == "" or equipment.Unlock == nil) and "" or "" .. equipment.Unlock .. "", equipment.ID, equipment.Quote )) end

Stacking function Stacking(list) local stacking = "" for m in string.gmatch(list, "[^,]+") do   m = m:gsub("^%l", string.upper) stacking = stacking .. "" .. m  .. " Stacking " end return stacking end

Category function Category(list) local validCategories = { "Damage", "Healing", "Utility" } local category = "" for m in string.gmatch(list, "[^,]+") do   m = m:gsub("^%l", string.upper) for i, v in ipairs(validCategories) do     if m == v then category = category .. "" .. m  .. " " end end end return category end

Table local table_head = [=[{| class="article-table sortable floatheader header-center firstcolumn-center-nowrap" style="width:100%" ! style="width:25%" | Item ! class="unsortable" | Description ]=]

local table_row = [=[|- ]=]
 * data-sort-value="%s" | %s.png%s
 * %s

function p.Table(frame) local rarity = frame.args[1] local table = table_head for name, item in pairs(all_items) do   if item.Rarity == rarity then table = table .. frame:preprocess(string.format(table_row, name, name, name, name, item.Desc)) end end table = table .. "|}" return table end

Boss Table local table_head_boss = [=[{| class="article-table sortable floatheader header-center firstcolumn-center-nowrap" style="width:100%" ! style="width:25%" | Item ! class="unsortable" | Description ! style="width:20%" class="unsortable" | Boss ]=]

local table_row_boss = [=[|- ]=]
 * data-sort-value="%s" | %s.png%s
 * %s
 * style="text-align:center;white-space:nowrap" data-sort-value="%s" | %s.png%s

function p.BossTable(frame) local table = table_head_boss for name, item in pairs(all_items) do   if item.Rarity == "Boss" then table = table .. frame:preprocess(string.format(table_row_boss, name, name, name, name, item.Desc, item.Boss, item.Boss, item.Boss, item.Boss)) end end table = table .. "|}" return table end

Equipment Table local table_head_equipment = [=[{| class="article-table sortable floatheader header-center firstcolumn-center-nowrap" style="width:100%" ! style="width:25%" | Item ! class="unsortable" | Description ! style="white-space:nowrap;width:15%" data-sort-type="number" | Cooldown ]=]

local table_row_equipment = [=[|- ]=]
 * data-sort-value="%s" | %s.png%s
 * %s
 * style="text-align:center" | %s

function p.EquipmentTable(frame) local rarity = frame.args[1] local table = table_head_equipment for name, equipment in pairs(all_equipment) do   if equipment.Rarity == rarity then table = table .. frame:preprocess(string.format(table_row_equipment, name, name, name, name, equipment.Desc, equipment.Cooldown and equipment.Cooldown .. "s" or "-")) end end table = table .. "|}" return table end

-- function ItemList local items = {}  for name, item in pairs(all_items) do    item.Name = name    table.insert(items, item)  end  table.sort(items, function(a, b) return a.Name < b.Name end)  return items end --

return p --