Module:SharedSkill

-- (prevents literal interpretation of links or categories within the module code) -- Lua Templating for Shared Skill related displays local p = {} local cargo = mw.ext.cargo

-- Usage: -- Filter header for shared skill lists function p.Filter(frame) local md5 = require('Module:Md5') local skillFilterValues = 'skills=%s|skillImages=%s' local costFilterValues = 'costs=%s' local imageUrl = '/media/%s/%s/%s.png'

local result = {} local skills = cargo.query('Adventurers,Skills', 'SkillLv1IconName', {   join    = 'Adventurers.EditSkillId=Skills.SkillId',    where   = 'EditSkillLevelNum>0',    groupBy = 'SkillLv1IconName',    orderBy = 'SkillLv1IconName',  }) for i, skill in ipairs(skills) do   local icon = skill['SkillLv1IconName'] local iconHash = md5.sumhexa(icon..'.png'):sub(1, 2) local iconPath = string.format(imageUrl, iconHash:sub(1,1), iconHash, icon) result[#result+1] = string.format(skillFilterValues, icon, iconPath) end

local costs = cargo.query('Adventurers', 'EditSkillCost', {   where   = 'EditSkillLevelNum>0',    groupBy = 'EditSkillCost',    orderBy = 'EditSkillCost',  }) for i, cost in ipairs(costs) do   result[#result+1] = string.format(costFilterValues, cost['EditSkillCost']) end return frame:preprocess(string.format('', table.concat(result, '|'))) end

-- Entries for Shared Skill lists Not fully implemented currently Usage: Test using:  frame = mw.getCurrentFrame  print(p.TableEntries(frame)) -- -- function p.TableEntries(frame) --  local filterValues = '|- class="grid-entry" data-element="%s" data-weapon="%s" '.. --      'data-rarity="%s" data-skill="%s" data-cost="%s" data-sharedskill="%s"' --  local row = '| '.. -- Adv icon --              '|| %s'.. -- Adv link --              '|| %s'.. -- Cost --              '||  %s'.. -- Skill link --              '|| %s'.. -- SP cost --              '|| \n%s\n' --  local coabQueryWhere = 'Id="%s"'

--  local result = {} --  local fields = 'Adventurers._pageName=advPage,FullName,ElementalType,WeaponType,Rarity,Availability,Id=advId,VariationId,'.. --      'Skills.Name=SkillName,Skills._pageName=SkillLink,Skills.Type=SkillType,MaxSkillLevel,SpLv4Edit,EditSkillCost,'.. --      'SkillLv1IconName,Description1,Description2,Description3,Description4' --  local skills = cargo.query('Adventurers, Skills', fields, { --     join    = 'Adventurers.EditSkillId=Skills.SkillId', --     where   = 'IsPlayable AND ReleaseDate <= NOW AND EditSkillLevelNum>0', --     groupBy = 'Adventurers._pageName', --     orderBy = 'ElementalTypeId ASC, WeaponTypeId ASC, Rarity DESC, IdLong DESC, FullName ASC', --     limit   = 999 --   }) --  for i, skill in ipairs(skills) do --     local advPage = skill['advPage'] --    local advName = skill['FullName'] --    local element = skill['ElementalType'] --    local weapon = skill['WeaponType'] --    local rarity = skill['Rarity'] --    local skillLink = skill['SkillLink'] --    local skillIcon = skill['SkillLv1IconName'] --    local skillType = skill['SkillType'] --    local cost = skill['EditSkillCost'] --    result[#result+1] = filterValues:format(element, weapon, rarity, skillType, cost, skillIcon) --    result[#result+1] = row:format( --       skill['advId'], skill['VariationId'], rarity, advPage, advPage, advName, --       cost, skillIcon, skillLink, skillLink, skill['SkillName'], skill['SpLv4Edit'], --       skillDescriptionTabs(skill)) --    ) --   end --   return table.concat(result, '\n') -- end

return p --