Module:Page/GearList

local dataModel = require("Module:Data").model local p = {}

local gearTypeMap = mw.loadData("Module:Data/Extra/GearTypeMap")

local getGearName = function(iname) return dataModel.getLoc('Data:Game/MasterParam/Artifact/' .. string.gsub(iname, '_', ' '), 'name') end

function p.gearListBySource(frame) local args = require('Module:Arguments').getArgs(frame, {       parentFirst = true,    }) local source = args[1] return p._gearListBySource(source) end

function p._gearListBySource(source) local gearExtra = mw.loadData("Module:Data/Extra/Gear") local render_gear_icon = require('Module:Render/Gear')._icon

local sb = {}

table.insert(sb, '{| class="wikitable sortable frozen-header"') table.insert(sb, '!GearIcon') table.insert(sb, '!Gear Name') table.insert(sb, '!Gear Class') table.insert(sb, '!Gear Type') table.insert(sb, '!Rarity') table.insert(sb, '!Source') local gearRows = {} for iname, gearData in pairs(gearExtra) do       if string.find(gearData['source'], source) then local gear = dataModel.query("Artifact", "rini,type,tag", {where = 'iname="'..iname..'" and server = "gl"'})[1] or {} if gear.rini then gearName = string.gsub(getGearName(iname) or gearData[name], '%[', '【') gearName = string.gsub(gearName, '%]', '】') local tempGearOutput = {} table.insert(tempGearOutput, '|-') table.insert(tempGearOutput, '|'..render_gear_icon({iname, name='none'})) table.insert(tempGearOutput, '|'..gearName..'') table.insert(tempGearOutput, '|'..gearTypeMap['gearClass'][gear.type]) table.insert(tempGearOutput, '|'..(gearTypeMap['gearType'][gear.tag] or gear.tag or '')) table.insert(tempGearOutput, '|'..(gear.rini+1)) table.insert(tempGearOutput, '|'..gearData['source']) table.insert(gearRows, {                   name = gearName,                    output = table.concat(tempGearOutput, "\n")                }) end end end

table.sort(gearRows, function(a, b) return a.name < b.name end) for i, row in ipairs(gearRows) do       table.insert(sb, row.output) end table.insert(sb, "|}")

return table.concat(sb, "\n") end

return p