Module:User:Saschb/SkillChainChartTest

local p = {} local cargo = mw.ext.cargo local util = require('Module:Util')

function p._fourStarSkillChainsPassive(ptype) -- Initialize the table local tbl = mw.html.create('table') :addClass('wikitable default sortable') :css('text-align','center')

-- Add table headers tbl:tag('th') :wikitext('Skill') :css('width', '150px') tbl:tag('th') :wikitext('Effect')

tbl:tag('th') :wikitext('Characters')

local passiveQuery = cargo.query('PassiveGroup','_pageName',{where='Ptype="'..ptype..'" and Exclusive="No"',groupBy='_pageName',limit='300'})

for _, passive in ipairs(passiveQuery) do   local passiveSingleQuery = cargo.query('PassiveSingle','_pageName,Name,Effect',{where='_pageName="'.. passive._pageName ..'"',groupBy='Name',orderBy='Name DESC',limit='1',default=''}) local maxTierSkillName = passiveSingleQuery[1].Name local heroStr = ''

if not util.isNilOrEmpty(maxTierSkillName) then local tr = tbl:tag('tr') tr:tag('td') :wikitext( .. maxTierSkillName .. ) tr:tag('td') :wikitext(passiveSingleQuery.Effect)

local heroQuery = cargo.query('Heroes=h,HeroPassives=p','h._pageName=fulltext',{join='h._pageName=p._pageName',where='((p.passive'..ptype..'1="'..maxTierSkillName..'" AND p.passive'..ptype..'1Unlock!="5") OR (p.passive'..ptype..'2="'..maxTierSkillName..'" AND p.passive'..ptype..'2Unlock!="5") OR (p.passive'..ptype..'3="'..maxTierSkillName..'" AND p.passive'..ptype..'3Unlock!="5"))',groupBy='h._pageName',limit='300'})

for k, hero in util.sortedPairs(heroQuery) do       if not isUninheritable(hero.fulltext) then heroStr = heroStr .. '' .. hero.fulltext .. ', ' end end

heroStr = string.sub(heroStr,1,-3)

tr:tag('td') :wikitext(util.returnDefaultIfEmpty(heroStr)) end end

return tostring(tbl) end

function isUninheritable(hero) local uninheritableHeroes = { ["Alfonse"] = "1", ["Sharena"] = "1", ["Anna"] = "1", } return uninheritableHeroes[hero] end

function p.fourStarSkillChains(frame) local args = frame.args if args[1] == 'passive' then return p._fourStarSkillChainsPassive(args[2]) end end

return p