Module:ListArmors

local p = {} local cargo = mw.ext.cargo

-- Convenience method: format the string "pageName1,pageName2,pageName3" as wikitext links. -- @param {string} commaSeparatedTitles -- @return {string} local function showPageLinks( commaSeparatedTitles ) if commaSeparatedTitles == '' then return '' end

local links = {} for _, pageName in ipairs( mw.text.split( commaSeparatedTitles, ',' ) ) do table.insert( links,  .. pageName ..  ) end

return table.concat( links, ', ' ) end

-- Print the list of all armor sets in the game. (based on Special:CargoTables/armorset) -- Usage: function p.ListAllSets -- Perform a SQL query to the Cargo database. local tables = 'armorset' local fields = 'tier,rarity,headPage,chestPage,legsPage,damage,protection,energy,health,setBonus,price,physical,radioactive,poison,electric,fire,ice,cosmic,shadow' local queryOpt = { limit = 5000, orderBy = 'tier DESC,price DESC' }	local rows = cargo.query( tables, fields, queryOpt ) or {}

-- Show a table of all sets. -- Resistances must be in the same order as displayed in-game. local ret = '{| class="wikitable sortable"\n' .. '|-\n! Tier !! Rarity !! Head !! Chest !! Legs !! ' ..		'!! ' ..		'!! ' ..		'!! ' ..		'!! ' ..		'!! ' ..		'!! ' ..		'!! ' ..		'!! ' ..		'!! ' ..		'!! ' ..		'!! ' ..		'!! Set bonus !! Total price\n'

for _, row in ipairs( rows ) do ret = ret .. '|-\n|' .. row.tier .. '||' .. row.rarity .. '||' .. showPageLinks( row.headPage ) .. '||' .. showPageLinks( row.chestPage ) .. '||' .. showPageLinks( row.legsPage ) .. '||' .. row.damage .. '%' ..			'||' .. row.protection .. '||' .. row.energy .. '||' .. row.health .. '||' .. row.physical .. '||' .. row.ice .. '||' .. row.fire .. '||' .. row.electric .. '||' .. row.poison .. '||' .. row.radioactive .. '||' .. row.cosmic .. '||' .. row.shadow .. '||' .. row.setBonus .. '\n|' .. row.price .. '\n' end

ret = ret .. '\n|}' return ret end

return p