Module:WeaponList

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

-- Usage: or function p._weaponList(frame) -- Cargo Query local tables = 'Weapons,WeaponSkin' local typeFilter = frame.args['Type'] and ' AND Weapons.WeaponType="'..frame.args['Type']..'"' or '' local queryFields = "WeaponSkin.BaseId=BaseId,WeaponSkin.FormId=FormId,Weapons._pageName=pageName,Weapons.Name=Name,Weapons.Rarity=Rarity,Weapons.WeaponSeries=Availability,Weapons.ElementalType=ElementalType,Weapons.WeaponType=Type,MaxHp1,MaxHp2,MaxHp3,MaxAtk1,MaxAtk2,MaxAtk3,ChangeSkillId3,CreateStartDate,Abilities13,Abilities23" local queryArgs = { join ='Weapons.WeaponSkinId=WeaponSkin.Id', where ='Weapons.Name!="Zethia\'s Staff" AND CreateStartDate <= NOW'..typeFilter, groupBy = 'Weapons._pageName', limit = '9999', orderBy = "Weapons.Rarity DESC, Weapons.WeaponSeriesId DESC, Weapons.ElementalTypeId ASC, Weapons.WeaponTypeId ASC, Weapons.Id DESC, Weapons.Name ASC" } local queryResult = cargo.query(tables, queryFields, queryArgs) if queryResult == nil then return "(no values)" end

-- Initialize the table local tbl = mw.html.create('table') :addClass('wikitable sortable center') :css('text-align','center') :css('width','100%')

-- Table headers tbl:tag('th') :wikitext('Icon') :addClass('unsortable') tbl:tag('th') :wikitext('Name') tbl:tag('th') :wikitext('Rarity') tbl:tag('th') :wikitext('Type') tbl:tag('th') :wikitext('Element') tbl:tag('th') :wikitext('HP') tbl:tag('th') :wikitext('Str') tbl:tag('th') :wikitext('Skills') tbl:tag('th') :wikitext('Ability 1') tbl:tag('th') :wikitext('Ability 2') tbl:tag('th') :wikitext('Release date') :css('width', '12%')

if type( queryResult ) == "table" then -- Go through all the weapons in the query result for _, weapon in ipairs(queryResult) do         local tr = tbl:tag('tr') tr:addClass('character-grid-entry') :addClass('grid-entry') :attr('data-weapon', weapon.Type) :attr('data-element', weapon.ElementalType) :attr('data-rarity', weapon.Rarity) :attr('data-availability', weapon.Availability) :attr('data-weapon-group', getWeaponGroup(weapon))

-- Icon tr:tag('td') :wikitext('') -- Weapon Name tr:tag('td') :wikitext(  .. weapon.Name ..  ) -- Rarity tr:tag('td') :wikitext(string.format('', weapon.Rarity, weapon.Rarity)) -- Type tr:tag('td') :wikitext(string.format('', weapon.Type, weapon.Type))

-- Element tr:tag('td') :wikitext(string.format('', weapon.ElementalType, weapon.ElementalType))

-- HP         tr:tag('td'):wikitext(math.max(weapon.MaxHp1,weapon.MaxHp2,weapon.MaxHp3)):done

-- Str tr:tag('td'):wikitext(math.max(weapon.MaxAtk1,weapon.MaxAtk2,weapon.MaxAtk3)):done

-- Skill if (weapon.ChangeSkillId3 and weapon.ChangeSkillId3 ~= '' and weapon.ChangeSkillId3 ~= '0') then tr:tag('td') :css('text-align', 'left') :wikitext(               frame:expandTemplate{                  title = 'SkillTooltip',                  args = { weapon.ChangeSkillId3 }                }              ) else tr:tag('td') :wikitext('-') end

-- Ability 1 if (weapon.Abilities13 ~= 'nil' and weapon.Abilities13 ~= '' and weapon.Abilities13 ~= '0') then tr:tag('td') :css('text-align', 'left') :wikitext(               frame:expandTemplate{                  title = 'AbilityText',                  args = {                    Id = weapon.Abilities13,                  }                }              ) else tr:tag('td') :wikitext('-') end

-- Ability 2 if (weapon.Abilities23 ~= 'nil' and weapon.Abilities23 ~= '' and weapon.Abilities23 ~= '0') then tr:tag('td') :css('text-align', 'left') :wikitext(               frame:expandTemplate{                  title = 'AbilityText',                  args = {                    Id = weapon.Abilities23,                  }                }              ) else tr:tag('td') :wikitext('-') end

-- Release Date tr:tag('td') :wikitext(               frame:expandTemplate{                  title = 'ModuleReleaseDate',                  args = {                    Date = weapon.CreateStartDate,                  }                }              ) end return tostring(tbl) end end

function getWeaponGroup(weapon) if (weapon.Abilities11 ~= 'nil' and weapon.Abilities11 ~= '' and weapon.Abilities11 ~= '0') then return 'void' end return 'standard' end function p.weaponList(frame) return p._weaponList(frame) end

return p