Module:BestAssetsWorstFlaws

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

local main = function local rarity = 5

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

local grFunc = function (elem, rarity, gr) if not gr then elem:wikitext('?') else local growthkind = FEHStatUtil.getSupergrowth(rarity, gr) if growthkind > 0 then elem:css('color', '#090'):wikitext("Best") elseif growthkind < 0 then elem:css('color', '#900'):wikitext("Worst") else elem:wikitext('—') end end end

local theUnit = nil local builder = HeroTableBuilder.new

builder:heroIcon builder:heroLink builder:heroEntry:css('width', '6%') builder:moveType:css('width', '4%') builder:weaponType:css('width', '4%') builder:column('HP', function (elem, page) return grFunc(elem, rarity, tonumber(theUnit.HPGR3)) end):css('width', '11%') builder:column('Atk', function (elem, page) return grFunc(elem, rarity, tonumber(theUnit.AtkGR3)) end):css('width', '11%') builder:column('Spd', function (elem, page) return grFunc(elem, rarity, tonumber(theUnit.SpdGR3)) end):css('width', '11%') builder:column('Def', function (elem, page) return grFunc(elem, rarity, tonumber(theUnit.DefGR3)) end):css('width', '11%') builder:column('Res', function (elem, page) return grFunc(elem, rarity, tonumber(theUnit.ResGR3)) end):css('width', '11%')

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

return builder:build:addClass('wikitable'):css('text-align', 'center'):css('width', '100%'):attr('id', 'max-stats-table') end

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