Module:PairStatsTable

local HeroTableBuilder = require 'Module:HeroTableBuilder' local FEHStatUtil = require 'Module:FEHStatUtil' local cargo = mw.ext.cargo

local getMaxStat = function (rarity, b, g)	return b and g and (b + FEHStatUtil.getGrowthValue(rarity, g)) end

local main = function (args, frame) local rarity = 5

local units = cargo.query('UnitStats,Units', "Units._pageName=page,IFNULL(CONCAT(Name,': ',Title),Name)=name,Entries,MoveType,WeaponType,Lv1Atk5,Lv1Spd5,Lv1Def5,Lv1Res5,AtkGR3,SpdGR3,DefGR3,ResGR3", {		join = 'UnitStats.WikiName=Units.WikiName',		where = "IFNULL(Properties__full,'') NOT LIKE '%enemy%'",		groupBy = 'Units.WikiName',		orderBy = 'IFNULL(IntID,9999)',		limit = 5000,	})

for _, v in ipairs(units) do --		v.hp = getMaxStat(rarity, tonumber(v.Lv1HP5), tonumber(v.HPGR3)) v.atk = getMaxStat(rarity, tonumber(v.Lv1Atk5), tonumber(v.AtkGR3)) v.spd = getMaxStat(rarity, tonumber(v.Lv1Spd5), tonumber(v.SpdGR3)) v.def = getMaxStat(rarity, tonumber(v.Lv1Def5), tonumber(v.DefGR3)) v.res = getMaxStat(rarity, tonumber(v.Lv1Res5), tonumber(v.ResGR3)) --		if v.hp and v.atk and v.spd and v.def and v.res then			v.total = v.hp + v.atk + v.spd + v.def + v.res		end end

local theUnit = nil local builder = HeroTableBuilder.new

local fmt = function (s1, s2) return (s1 and s2) and (s1+s2) or '?' end builder:heroIcon builder:heroLink:css('width', '25em') builder:heroEntry:css('width', '80px') builder:moveType:css('width', '55px') builder:weaponType:css('width', '55px') builder:column('Atk+Spd', function (elem) elem:wikitext(fmt(theUnit.atk,theUnit.spd)) end) builder:column('Atk+Def', function (elem) elem:wikitext(fmt(theUnit.atk,theUnit.def)) end) builder:column('Atk+Res', function (elem) elem:wikitext(fmt(theUnit.atk,theUnit.res)) end) builder:column('Spd+Def', function (elem) elem:wikitext(fmt(theUnit.spd,theUnit.def)) end) builder:column('Spd+Res', function (elem) elem:wikitext(fmt(theUnit.spd,theUnit.res)) end) builder:column('Def+Res', function (elem) elem:wikitext(fmt(theUnit.def,theUnit.res)) end)

for _, v in ipairs(units) do		theUnit = v		builder:addHero(v.page, v.name, v.MoveType, v.WeaponType, v.Entries) end

return builder:build:addClass('wikitable'):css('text-align', 'center'):css('width', '100%') end

return require 'Module:MakeMWModule'.makeMWModule {main = main}