Module:EHPChart

local Util = require 'Module:Util' local FEHStatUtil = require 'Module:FEHStatUtil' local HeroTableBuilder = require 'Module:HeroTableBuilder' 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 local rarity = 5

local units = cargo.query('UnitStats,Units', "Units._pageName=page,IFNULL(CONCAT(Name,': ',Title),Name)=name,Entries,MoveType,WeaponType,Lv1HP5,Lv1Def5,Lv1Res5,HPGR3,DefGR3,ResGR3", {		join = 'UnitStats.WikiName=Units.WikiName',		where = "IFNULL(Properties__full,'') NOT LIKE '%enemy%'",		orderBy = 'name',		limit = 1000,	}) for _, v in ipairs(units) do		v.hp = getMaxStat(rarity, tonumber(v.Lv1HP5), tonumber(v.HPGR3)) v.def = getMaxStat(rarity, tonumber(v.Lv1Def5), tonumber(v.DefGR3)) v.res = getMaxStat(rarity, tonumber(v.Lv1Res5), tonumber(v.ResGR3)) end

local theUnit = nil local builder = HeroTableBuilder.new

local ehpFunc = function (elem, mit, hits) elem:wikitext(theUnit.hp and mit and (math.ceil(theUnit.hp / hits) + mit) or '?') if hits == 1 then elem:css('font-weight', '700') else elem:wikitext((" ×%d"):format(hits)) end end

builder:heroIcon('40px'):css('width', '4%') builder:heroLink:css('width', '25%') builder:heroEntry:css('width', '6%') builder:moveType:css('width', '4%') builder:weaponType:css('width', '4%') builder:column('Single Hit Physical eHP', function (elem) ehpFunc(elem, theUnit.def, 1) end):css('width', '10%') builder:column('Single Hit Magical eHP', function (elem) ehpFunc(elem, theUnit.res, 1) end):css('width', '10%') builder:column('Double Hit Physical eHP', function (elem) ehpFunc(elem, theUnit.def, 2) end):css('width', '10%') builder:column('Double Hit Magical eHP', function (elem) ehpFunc(elem, theUnit.res, 2) end):css('width', '10%') builder:column('Quadruple Hit Physical eHP', function (elem) ehpFunc(elem, theUnit.def, 4) end):css('width', '10%') builder:column('Quadruple Hit Magical eHP', function (elem) ehpFunc(elem, theUnit.res, 4) end):css('width', '10%')

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'):addClass('default'):css('text-align', 'center'):css('width', '100%') end

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