Module:Level1StatsTable

local HeroTableBuilder = require 'Module:HeroTableBuilder' local cargo = mw.ext.cargo local toboolean = require 'Module:Bool'.toboolean

local main = function (args, frame) local units = cargo.query('UnitStats,Units', "Units._pageName=page,IFNULL(CONCAT(Name,': ',Title),Name)=name,Entries,MoveType,WeaponType,Lv1HP5,Lv1Atk5,Lv1Spd5,Lv1Def5,Lv1Res5", {		join = 'UnitStats.WikiName=Units.WikiName',		where = "IFNULL(Properties__full,) NOT LIKE '%enemy%'"			.. (toboolean(args.refresher) and "AND Properties HOLDS 'refresher'" or ),		groupBy = 'Units.WikiName',		orderBy = 'name',		limit = 1000,	}) if toboolean(args.common) then local HeroUtil = require 'Module:HeroUtil' local List = require 'Module:ListUtil' local commonUnits = HeroUtil.getLowestRarities {current = true, mask = {nonfocus = true}} List.keep_if(units, function (v)			local rarities = commonUnits[v.page]			return rarities and List.any(rarities.nonfocus, function (r) return r < 5 end)		end) end

for _, v in ipairs(units) do		v.hp = tonumber(v.Lv1HP5) v.atk = tonumber(v.Lv1Atk5) v.spd = tonumber(v.Lv1Spd5) v.def = tonumber(v.Lv1Def5) v.res = tonumber(v.Lv1Res5) 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 (x) return x and (args.unrounded and '%.3f' or '%d'):format(x) or '?' end builder:heroIcon builder:heroLink:css('width', '25em') builder:heroEntry:css('width', '6%') builder:moveType:css('width', '4%') builder:weaponType:css('width', '4%') builder:column('HP', function (elem) elem:wikitext(fmt(theUnit.hp)) end):css('width', '11%') builder:column('Atk', function (elem) elem:wikitext(fmt(theUnit.atk)) end):css('width', '11%') builder:column('Spd', function (elem) elem:wikitext(fmt(theUnit.spd)) end):css('width', '11%') builder:column('Def', function (elem) elem:wikitext(fmt(theUnit.def)) end):css('width', '11%') builder:column('Res', function (elem) elem:wikitext(fmt(theUnit.res)) end):css('width', '11%') builder:column('Total', function (elem) elem:wikitext(fmt(theUnit.total)) 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%'):attr('id', 'max-stats-table') end

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