Module:Armor

local p = {} local h = {}

local DataTable = require("Module:Data Table") local TermList = require("Module:Term List") local utilsString = require("Module:UtilsString") local utilsTable = require("Module:UtilsTable")

local CATEGORY_INVALID_ARGS = require("Module:Constants/category/invalidArgs") local COLUMNS = {"Set", "Body Part", "Armor", "Defense", "Effect(s)", "Sell Price", "Inventory Description"}

function p.ArmorTable(frame) return DataTable.Main(frame, h.store, {		requiredColumns = COLUMNS	}) end function h.store(args) local categories = "" for i, row in ipairs(args.rows) do		local data, rowCategories = h.parseRow(row.cells, i)		categories = categories..rowCategories mw.logObject({				armorSet = data["Set"],				armor = data["Armor"],				bodyPart = data["Body Part"],				level = nil,				defense = data["Defense"],				sellPrice = data["Sell Price"],				effects = data["Effect(s)"],				materials = nil,				description = data["Inventory Description"]			}) mw.getCurrentFrame:expandTemplate({			title = "Armor/Store",			args = {				armorSet = data["Set"],				armor = data["Armor"],				bodyPart = data["Body Part"],				level = nil,				defense = data["Defense"],				sellPrice = data["Sell Price"],				effects = data["Effect(s)"],				materials = nil,				description = data["Inventory Description"]			}		}) end return categories end function h.parseRow(cells, rowIndex) local categories = "" local row = {} local cellsByColumn = utilsTable.keyBy(cells, "columnHeader") for i, column in ipairs(COLUMNS) do		local cell = cellsByColumn[column] or {} if cell.raw == "" or cell.raw == nil then local utilsError = require("Module:UtilsError") utilsError.warn(string.format("The value for column  in row %d should not be empty.", column, rowIndex)) categories = categories.."" cell = nil elseif string.find(cell.raw, "^N/A") then cell = nil else cell = TermList.separateAdditionalInfo(cell.raw) end row[column] = cell end return row, categories end

p.Templates = { ["Armor/Store"] = { purpose = "Used by Template:Data Table/Armor to store armor data.", wip = true, format = "block", storesData = true, paramOrder = {"armorSet", "armor", "bodyPart", "level", "defense", "sellPrice", "effects", "materials", "description"}, boilerplate = { separateRequiredParams = false, },		params = { armorSet = { type = "wiki-page-name", desc = "If applicable, a wiki page name on the Armor Set that this Armor belongs to.", trim = true, },			armor = { required = true, type = "wiki-page-name", desc = "A wiki article name on a particular piece of Armor.", trim = true, nilIfEmpty = true, },			bodyPart = { required = true, type = "string", enum = {"Head", "Chest", "Legs"}, desc = "The slot that this Armor occupies on Link's body.", trim = true, nilIfEmpty = true, },			level = { type = "number", desc = "The level of the Armor upgrade, as an integer. Blank for base items.", trim = true, nilIfEmpty = true, },			defense = { required = true, type = "number", desc = "The defensive value for the Armor at the specified level.", trim = true, nilIfEmpty = true, },			sellPrice = { type = "number", desc = "An integer – the amount of Rupees that Link can sell the Armor for at the specified level.", trim = true, nilIfEmpty = true, },			effects = { type = "string", desc = "A comma-separated list of the Armor's Effects, if any.", trim = true, nilIfEmpty = true, },			materials = { required = true, type = "string", desc = "A list of the materials required to obtain specified upgrade level.", trim = true, nilIfEmpty = true, },			description = { required = true, type = "content", desc = "A transcript of the item's description on the Inventory screen.", trim = true, nilIfEmpty = true, },		},	}, }

return p