Module:Shards

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

function p.List( frame ) local args = frame.args local fieldstable = { "ShardName", "Icon", "AffixNickname", "AffixType", "Hybrid", "Modifier", "Modifier2", "ApplicableEquip", "ModT1Min", "ModT1Max", "ModT2Min", "ModT2Max", "ModT3Min", "ModT3Max", "ModT4Min", "ModT4Max", "ModT5Min", "ModT5Max", "Mod2T1Min", "Mod2T1Max", "Mod2T2Min", "Mod2T2Max", "Mod2T3Min", "Mod2T3Max", "Mod2T4Min", "Mod2T4Max", "Mod2T5Min", "Mod2T5Max", "_pageName", }   local tables = 'Shards' local fields = table.concat(fieldstable,",") -- optional parameters are grouped in one table -- you can omit any or all of them, except joinOn if you use more than one table local cargoquery = { where = args.where } local result = mw.ext.cargo.query( tables, fields, cargoquery )

if result[1] == nil then return args.default

elseif result[1] ~= nil then --Start the table local tbl = mw.html.create('table') tbl:addClass('wikitable sortable mw-datatable') if args.Icon == "show" then tbl:tag("th"):wikitext("Icon"):done end if args.ShardName ~= "hide" then tbl:tag("th"):wikitext("Name"):done end if args.AffixNickname ~= "hide" then tbl:tag("th"):wikitext("Nickname"):done end if args.AffixType ~= "hide" then tbl:tag("th"):wikitext("Type"):done end if args.Modifiers ~= "hide" then tbl:tag("th"):wikitext("Modifier(s)"):done end if args.ModsT1 ~= "hide" then tbl:tag("th"):wikitext("T1 Range"):done end if args.ModsT2 ~= "hide" then tbl:tag("th"):wikitext("T2 Range"):done end if args.ModsT3 ~= "hide" then tbl:tag("th"):wikitext("T3 Range"):done end if args.ModsT4 ~= "hide" then tbl:tag("th"):wikitext("T4 Range"):done end if args.ModsT5 ~= "hide" then tbl:tag("th"):wikitext("T5 Range"):done end if args.ApplicableEquip == "show" then tbl:tag("th"):wikitext("Applicable Equip."):done end tbl:done --Construct the rows in the table for _,row in ipairs(result) do		tr = tbl:tag("tr") if args.Icon == "show" then tr:tag("td"):wikitext( (row.Icon ~=  and  or '') ) end if args.ShardName ~= "hide" then tr:tag("td"):wikitext( .. row.ShardName .. ):done end if args.AffixNickname ~= "hide" then tr:tag("td"):wikitext(row.AffixNickname):done end if args.AffixType ~= "hide" then tr:tag("td"):wikitext(row.AffixType):done end if args.Modifiers ~= "hide" then tr:tag("td"):wikitext(row.Modifier .. (row.Modifier2 ~= '' and ' ' .. row.Modifier2 or '') ):done end if args.ModsT1 ~= "hide" then tr:tag("td"):wikitext( (row.ModT1Min or ) .. ' -  ' .. (row.ModT1Max or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T1Min or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T1Max or '') ):done end if args.ModsT2 ~= "hide" then tr:tag("td"):wikitext( (row.ModT2Min or ) .. ' -  ' .. (row.ModT2Max or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T2Min or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T2Max or '') ):done end if args.ModsT3 ~= "hide" then tr:tag("td"):wikitext( (row.ModT3Min or ) .. ' -  ' .. (row.ModT3Max or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T3Min or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T3Max or '') ):done end if args.ModsT4 ~= "hide" then tr:tag("td"):wikitext( (row.ModT4Min or ) .. ' -  ' .. (row.ModT4Max or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T4Min or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T4Max or '') ):done end if args.ModsT5 ~= "hide" then tr:tag("td"):wikitext( (row.ModT5Min or ) .. ' -  ' .. (row.ModT5Max or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T5Min or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T5Max or '') ):done end if args.ApplicableEquip == "show" then tr:tag("td"):wikitext(row.ApplicableEquip):done end if args.ScalingRows == "show" then if string.match(row.ApplicableEquip, "Two Handed Sword") or string.match(row.ApplicableEquip, "Two Handed Axe") or string.match(row.ApplicableEquip, "Two Handed Blunt Weapon") or string.match(row.ApplicableEquip, "Two Handed Polearm") then tr = tbl:tag("tr") if args.Icon == "show" then tr:tag("td"):wikitext( (row.Icon ~=  and  or '') ) end if args.ShardName ~= "hide" then tr:tag("td"):wikitext('' .. row.ShardName .. ' (on 2h Weapon)'):done end if args.AffixNickname ~= "hide" then tr:tag("td"):wikitext(row.AffixNickname):done end if args.AffixType ~= "hide" then tr:tag("td"):wikitext(row.AffixType):done end if args.Modifiers ~= "hide" then tr:tag("td"):wikitext(row.Modifier .. '(x2.7)' .. (row.Modifier2 ~= '' and ' ' .. row.Modifier2 .. '(x2.7)' or '') ):done end if args.ModsT1 ~= "hide" then tr:tag("td"):wikitext( (row.ModT1Min ~=  and tonumber(row.ModT1Min) * 2.7 or ) .. ' -  ' .. (row.ModT1Max ~=  and tonumber(row.ModT1Max) * 2.7 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T1Min ~=  and tonumber(row.Mod2T1Min) * 2.7 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T1Max ~=  and row.Mod2T1Max * 2.7 or '') ):done end if args.ModsT2 ~= "hide" then tr:tag("td"):wikitext( (row.ModT2Min ~=  and tonumber(row.ModT2Min) * 2.7 or ) .. ' -  ' .. (row.ModT2Max ~=  and tonumber(row.ModT2Max) * 2.7 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T2Min ~=  and tonumber(row.Mod2T2Min) * 2.7 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T2Max ~=  and row.Mod2T2Max * 2.7 or '') ):done end if args.ModsT3 ~= "hide" then tr:tag("td"):wikitext( (row.ModT3Min ~=  and tonumber(row.ModT3Min) * 2.7 or ) .. ' -  ' .. (row.ModT3Max ~=  and tonumber(row.ModT3Max) * 2.7 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T3Min ~=  and tonumber(row.Mod2T3Min) * 2.7 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T3Max ~=  and row.Mod2T3Max * 2.7 or '') ):done end if args.ModsT4 ~= "hide" then tr:tag("td"):wikitext( (row.ModT4Min ~=  and tonumber(row.ModT4Min) * 2.7 or ) .. ' -  ' .. (row.ModT4Max ~=  and tonumber(row.ModT4Max) * 2.7 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T4Min ~=  and tonumber(row.Mod2T4Min) * 2.7 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T4Max ~=  and row.Mod2T4Max * 2.7 or '') ):done end if args.ModsT5 ~= "hide" then tr:tag("td"):wikitext( (row.ModT5Min ~=  and tonumber(row.ModT5Min) * 2.7 or ) .. ' -  ' .. (row.ModT5Max ~=  and tonumber(row.ModT5Max) * 2.7 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T5Min ~=  and tonumber(row.Mod2T5Min) * 2.7 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T5Max ~=  and row.Mod2T5Max * 2.7 or '') ):done end end if string.match(row.ApplicableEquip, "Body Armor") or string.match(row.ApplicableEquip, "Wand") or string.match(row.ApplicableEquip, "Sceptre") or string.match(row.ApplicableEquip, "One Handed Sword") or string.match(row.ApplicableEquip, "One Handed Axe") or string.match(row.ApplicableEquip, "One Handed Blunt Weapon") then tr = tbl:tag("tr") if args.Icon == "show" then tr:tag("td"):wikitext( (row.Icon ~=  and  or '') ) end if args.ShardName ~= "hide" then tr:tag("td"):wikitext('' .. row.ShardName .. ' (on 1h Weapon and Body Armor)'):done end if args.AffixNickname ~= "hide" then tr:tag("td"):wikitext(row.AffixNickname):done end if args.AffixType ~= "hide" then tr:tag("td"):wikitext(row.AffixType):done end if args.Modifiers ~= "hide" then tr:tag("td"):wikitext(row.Modifier .. '(x1.5)' .. (row.Modifier2 ~= '' and ' ' .. row.Modifier2 .. '(x1.5)' or '') ):done end if args.ModsT1 ~= "hide" then tr:tag("td"):wikitext( (row.ModT1Min ~=  and tonumber(row.ModT1Min) * 1.5 or ) .. ' -  ' .. (row.ModT1Max ~=  and tonumber(row.ModT1Max) * 1.5 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T1Min ~=  and tonumber(row.Mod2T1Min) * 1.5 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T1Max ~=  and row.Mod2T1Max * 1.5 or '') ):done end if args.ModsT2 ~= "hide" then tr:tag("td"):wikitext( (row.ModT2Min ~=  and tonumber(row.ModT2Min) * 1.5 or ) .. ' -  ' .. (row.ModT2Max ~=  and tonumber(row.ModT2Max) * 1.5 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T2Min ~=  and tonumber(row.Mod2T2Min) * 1.5 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T2Max ~=  and row.Mod2T2Max * 1.5 or '') ):done end if args.ModsT3 ~= "hide" then tr:tag("td"):wikitext( (row.ModT3Min ~=  and tonumber(row.ModT3Min) * 1.5 or ) .. ' -  ' .. (row.ModT3Max ~=  and tonumber(row.ModT3Max) * 1.5 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T3Min ~=  and tonumber(row.Mod2T3Min) * 1.5 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T3Max ~=  and row.Mod2T3Max * 1.5 or '') ):done end if args.ModsT4 ~= "hide" then tr:tag("td"):wikitext( (row.ModT4Min ~=  and tonumber(row.ModT4Min) * 1.5 or ) .. ' -  ' .. (row.ModT4Max ~=  and tonumber(row.ModT4Max) * 1.5 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T4Min ~=  and tonumber(row.Mod2T4Min) * 1.5 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T4Max ~=  and row.Mod2T4Max * 1.5 or '') ):done end if args.ModsT5 ~= "hide" then tr:tag("td"):wikitext( (row.ModT5Min ~=  and tonumber(row.ModT5Min) * 1.5 or ) .. ' -  ' .. (row.ModT5Max ~=  and tonumber(row.ModT5Max) * 1.5 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T5Min ~=  and tonumber(row.Mod2T5Min) * 1.5 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T5Max ~=  and row.Mod2T5Max * 1.5 or '') ):done end end if string.match(row.ApplicableEquip, "Amulet") then tr = tbl:tag("tr") if args.Icon == "show" then tr:tag("td"):wikitext( (row.Icon ~=  and  or '') ) end if args.ShardName ~= "hide" then tr:tag("td"):wikitext('' .. row.ShardName .. ' (on Amulet)'):done end if args.AffixNickname ~= "hide" then tr:tag("td"):wikitext(row.AffixNickname):done end if args.AffixType ~= "hide" then tr:tag("td"):wikitext(row.AffixType):done end if args.Modifiers ~= "hide" then tr:tag("td"):wikitext(row.Modifier .. '(x1.17)' .. (row.Modifier2 ~= '' and ' ' .. row.Modifier2 .. '(x1.17)' or '') ):done end if args.ModsT1 ~= "hide" then tr:tag("td"):wikitext( (row.ModT1Min ~=  and tonumber(row.ModT1Min) * 1.17 or ) .. ' -  ' .. (row.ModT1Max ~=  and tonumber(row.ModT1Max) * 1.17 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T1Min ~=  and tonumber(row.Mod2T1Min) * 1.17 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T1Max ~=  and row.Mod2T1Max * 1.17 or '') ):done end if args.ModsT2 ~= "hide" then tr:tag("td"):wikitext( (row.ModT2Min ~=  and tonumber(row.ModT2Min) * 1.17 or ) .. ' -  ' .. (row.ModT2Max ~=  and tonumber(row.ModT2Max) * 1.17 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T2Min ~=  and tonumber(row.Mod2T2Min) * 1.17 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T2Max ~=  and row.Mod2T2Max * 1.17 or '') ):done end if args.ModsT3 ~= "hide" then tr:tag("td"):wikitext( (row.ModT3Min ~=  and tonumber(row.ModT3Min) * 1.17 or ) .. ' -  ' .. (row.ModT3Max ~=  and tonumber(row.ModT3Max) * 1.17 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T3Min ~=  and tonumber(row.Mod2T3Min) * 1.17 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T3Max ~=  and row.Mod2T3Max * 1.17 or '') ):done end if args.ModsT4 ~= "hide" then tr:tag("td"):wikitext( (row.ModT4Min ~=  and tonumber(row.ModT4Min) * 1.17 or ) .. ' -  ' .. (row.ModT4Max ~=  and tonumber(row.ModT4Max) * 1.17 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T4Min ~=  and tonumber(row.Mod2T4Min) * 1.17 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T4Max ~=  and row.Mod2T4Max * 1.17 or '') ):done end if args.ModsT5 ~= "hide" then tr:tag("td"):wikitext( (row.ModT5Min ~=  and tonumber(row.ModT5Min) * 1.17 or ) .. ' -  ' .. (row.ModT5Max ~=  and tonumber(row.ModT5Max) * 1.17 or ) .. (row.Modifier2 ~= '' and ' ' or ) .. (row.Mod2T5Min ~=  and tonumber(row.Mod2T5Min) * 1.17 or ) .. (row.Modifier2 ~=  and ' -  ' or ) .. (row.Mod2T5Max ~=  and row.Mod2T5Max * 1.17 or '') ):done end end end end return tbl end -- . . . end return p