Module:Sandbox/PhantomCaleb

local p = {} local h = {}

local DataTable = require("Module:Data Table") local utilsCargo = require("Module:UtilsCargo") local utilsTable = require("Module:UtilsTable")

function p.ListAllArmor(frame) local args = frame.args local game = args[1]

local data = utilsCargo.query("Armor2", "armor, armorSet, slot, level, defense, sellPrice, description", {		where = string.format("game = '%s' AND armor IS NOT NULL AND (level IS NULL OR level = '★★★★')", game),		limit = 1000,	}) local maxArmor, baseArmor = utilsTable.partition(data, "level") local maxArmorByName = utilsTable.keyBy(maxArmor, "armor") baseArmor = utilsTable.sortBy(baseArmor, h.armorSortKey) local columns = { "Set [Term][Rowspan]", "Body Part", "Armor [Term]", "Description [Transcript]", "Defense [Defense:BotW:-]", string.format("★★★★ Defense [Defense:%s:-]", game), string.format("Sell Price [Rupees:%s:-]", game), "Effect(s) [TermList]", }	local rows = utilsTable.map(baseArmor, function(armor)		local maxArmor = maxArmorByName[armor.armor]		local maxArmorDefense = maxArmor and maxArmor.defense		return {			cells = {				armor.armorSet or "N/A",				armor.slot or "",				armor.armor or "",				armor.description,				armor.defense or "",				maxArmorDefense or "N/A",				armor.sellPrice or "N/A",				armor.effects or "N/A",			}		}	end) local dataTable = DataTable.printTable(rows, {		game = game,		columns = columns,	}) return dataTable end

function p.ListAllArmorUpgrades(frame) local args = frame.args local game = args[1]

local data = utilsCargo.query("Armor2", "armor, armorSet, slot, level, materials, defense, sellPrice, description", {		where = string.format("game = '%s' AND armor IS NOT NULL AND level IS NOT NULL", game),		limit = 1000,		sortBy = "armor",	}) local columns = { "Armor [Term][Rowspan]", "Level", "Materials [Amounts]", "Defense [Defense:BotW:-]", string.format("Sell Price [Rupees:%s:-]", game), "Description [Transcript]", }	local rows = utilsTable.map(data, function(armor)		return {			cells = {				armor.armor or "",				armor.level or "",				armor.materials or "",				armor.defense or "",				armor.sellPrice or "N/A",				armor.description or "",			}		}	end) local dataTable = DataTable.printTable(rows, {		game = game,		columns = columns,	}) return dataTable end

local slotKeys = ({	["Head"] = "1",	["Chest"] = "2",	["Legs"] = "3", }) function h.armorSortKey(armor) local slotKey = slotKeys[armor.slot or ""] or "" if armor.armorSet then return armor.armorSet..slotKey else return armor.armor end end

return p