Module:Armor

local p = {} local h = {}

local DataTable = require("Module:Data Table") local TermLite = require("Module:TermLite")

function p.StoreArmor(frame) return DataTable.Main(frame, {		storeFn = h.storeArmor,		requiredColumns = {"Set", "Body Part", "Armor", "Effect(s)"},	}) end function h.storeArmor(args, rows) for i, row in ipairs(rows) do		local armorSet = mw.text.killMarkers(row["Set"]) local bodyPart = mw.text.killMarkers(row["Body Part"]) local armor = mw.text.killMarkers(row["Armor"]) local effects = mw.text.killMarkers(row["Effect(s)"]) local hasArmorSet = armorSet == "N/A" and "0" or "1" local hasEffects = effects == "N/A" and "0" or "1" mw.getCurrentFrame:expandTemplate({			title = "Armor/Store",			args = {				game = args.game,				armorSet = hasArmorSet == "1" and armorSet or nil,				bodyPart = bodyPart,				armor = armor,				effects = hasEffects == "1" and effects or nil,				hasArmorSet = hasArmorSet,				hasEffects= hasEffects,			},		}) end end

function p.StoreArmorLevels(frame) return DataTable.Main(frame, {		storeFn = h.storeArmorLevels,		requiredColumns = {"Armor", "Level", "Defense", "Sell Price", "Materials", "Description"},	}) end function h.storeArmorLevels(args, rows) for i, row in ipairs(rows) do		local armor = mw.text.killMarkers(row["Armor"]) local level = mw.text.killMarkers(row["Level"]) local defense = mw.text.killMarkers(row["Defense"]) local sellPrice = mw.text.killMarkers(row["Sell Price"]) local materials = mw.text.killMarkers(row["Materials"]) local description = mw.text.killMarkers(row["Description"]) local sellable = sellPrice ~= "N/A" local armorTerm = TermLite.fetchTerm(args.game, armor) or armor mw.getCurrentFrame:expandTemplate({			title = "Armor Levels/Store",			args = {				game = args.game,				armor = armor,				level = level ~= "N/A" and level or nil,				defense = defense,				sellPrice = sellable and sellPrice or nil,				sellable = sellable and "1" or "0",				materials = materials ~= "N/A" and materials or nil,				description = description,			}		}) mw.getCurrentFrame:expandTemplate({			title = "Descriptions/Store",			args = {				game = args.game,				descriptionType = "Inventory",				context = level ~= "N/A" and level or nil,				subject = armor,				subjectDisplayName = armorTerm,				description = description,				image = string.format("File:%s %s Icon.png", args.game, armorTerm),			},		}) end end

p.Templates = { ["Armor Levels/Store"] = { format = "block", paramOrder = {"game", "armor", "level", "defense", "sellPrice", "sellable", "materials", "description"}, boilerplate = { separateRequiredParams = false, },		params = { game = { required = true, type = "string", desc = "A game code from Data:Franchise", trim = true, nilIfEmpty = true, },			armor = { required = true, type = "wiki-page-name", desc = "The wiki article for the piece of Armor.", 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, },			sellable = { type = "boolean", desc = "A boolean indicating whether the armor can be sold.", required = true, trim = true, nilIfEmpty = true, },			materials = { type = "string", desc = "A list of the materials required to obtain specified upgrade level. Blank for base items.", 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, },		}	},	["Armor/Store"] = { format = "block", paramOrder = {"game", "armorSet", "bodyPart", "armor", "effects", "hasArmorSet", "hasEffects"}, params = { game = { required = true, type = "string", desc = "A game code from Data:Franchise", trim = true, nilIfEmpty = true, },			armorSet = { required = true, type = "wiki-page-name", desc = "A wiki page name of the Armor Set that  belongs to.", trim = true, nilIfEmpty = true, },			bodyPart = { required = true, type = "string", enum = {"Head", "Chest", "Legs"}, desc = "The slot that  occupies on Link's body.", trim = true, nilIfEmpty = true, },			armor = { required = true, type = "wiki-page-name", desc = "The wiki article for the piece of Armor.", trim = true, nilIfEmpty = true, },			effects = { required = true, type = "string", desc = "Comma-separated list of Effect article names referring to the effects that this armor has, if any.", },			hasArmorSet = { required = true, type = "boolean", desc = "Indicates whether the Armor piece belongs to an Armor Set. Allows queries to determine whether the  field is empty because a value hasn't been filled in yet or because the field is not applicable.", trim = true, nilIfEmpty = true, },			hasEffects = { required = true, type = "boolean", desc = "Indicates whether the Armor has any effects. Allows queries to determine whether the  field is empty because a value hasn't been filled in yet or because the field is not applicable.", trim = true, nilIfEmpty = true, },		},	}, }

return p