Module:GRPatternTable

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

-- Growth Modifiers local parseGrowthModifiers = function (growthStr, refresher) local modifiers = {} modifiers[#modifiers + 1] = growthStr if refresher then modifiers[#modifiers + 1] = 'Refresher' end return table.concat(modifiers, ', ') end

local main = function local heroQueryResult = cargo.query(		"Units=h,UnitStats=s",		h._pageName=_pageName,IFNULL(CONCAT(Name,': ',Title),Name)=Hero,Entries,WeaponType,MoveType,		 GrowthMod,IF(Properties__full LIKE '%refresher%','1','')=isRefresher,		  CONCAT(HPGR3+AtkGR3+SpdGR3+DefGR3+ResGR3)=TotalGrowths,HPGR3=HP,AtkGR3=Atk,SpdGR3=Spd,DefGR3=Def,ResGR3=Res,		  CONCAT(Lv1HP5+Lv1Atk5+Lv1Spd5+Lv1Def5+Lv1Res5)=TotalLv1Stats, {			join = "h.WikiName=s.WikiName",			groupBy = "h.WikiName",			where = 's._pageName IS NOT NULL AND (Properties__full IS NULL OR Properties__Full NOT LIKE "%enemy%")',			limit = 1000,		}	) local avail = HeroUtil.getLowestRarities {} local releaseTimes = HeroUtil.getReleaseTimes {} for _, v in ipairs(heroQueryResult) do		v.lowestRarity = avail[v._pageName] and avail[v._pageName]:bounds or 6 end

local theUnit = nil local builder = HeroTableBuilder.new

builder:heroIcon('40px'):css('width', '3%') builder:heroLink:css('width', '18%'):css('min-width', '75px') builder:heroEntry('30px'):css('width', '8%'):css('min-width', '70px') builder:moveType:css('width', '8%'):css('min-width', '70px') builder:weaponType:css('width', '8%'):css('min-width', '106px') builder:column('Stats −47', function (elem) elem:wikitext(theUnit.TotalLv1Stats ~= '' and (tonumber(theUnit.TotalLv1Stats) - 47) or '?') end):css('width', '8%') builder:column('Growths −255%', function (elem) elem:wikitext(theUnit.TotalGrowths ~= '' and ((tonumber(theUnit.TotalGrowths) - 255) .. '%') or '?') end):css('width', '8%') builder:column('Growth modifier', function (elem) elem:wikitext(parseGrowthModifiers(theUnit.GrowthMod, theUnit.isRefresher ~= '')) end):css('width', '10%') builder:column('HP', function (elem) elem:wikitext(theUnit.HP ~= '' and tonumber(theUnit.HP) or '??', '%') end):css('width', '4%') builder:column('Atk', function (elem) elem:wikitext(theUnit.Atk ~= '' and tonumber(theUnit.Atk) or '??', '%') end):css('width', '4%') builder:column('Spd', function (elem) elem:wikitext(theUnit.Spd ~= '' and tonumber(theUnit.Spd) or '??', '%') end):css('width', '4%') builder:column('Def', function (elem) elem:wikitext(theUnit.Def ~= '' and tonumber(theUnit.Def) or '??', '%') end):css('width', '4%') builder:column('Res', function (elem) elem:wikitext(theUnit.Res ~= '' and tonumber(theUnit.Res) or '??', '%') end):css('width', '4%') builder:column('Release date', function (elem)		local heroReleaseTime = releaseTimes[theUnit._pageName] and releaseTimes[theUnit._pageName]:earliest or 0x7FFFFFFF		elem:wikitext(heroReleaseTime < 0x7FFFFFFF and os.date('%Y-%m-%d', heroReleaseTime) or 'N/A')	end):css('width', '12%'):css('min-width', '88px') for r = 1, 5 do		builder:column(mw.getCurrentFrame:expandTemplate {title = 'Rarity', args = {r}}, function (elem)			elem:css('background-color', r >= theUnit.lowestRarity and '#d2ffd2' or '#ffd2d2')				:wikitext(r >= theUnit.lowestRarity and "Yes" or "No")		end):css('width', '4%'):css('min-width', '35px') end

for _, v in ipairs(heroQueryResult) do		theUnit = v		builder:addHero(v._pageName, v.Hero, v.MoveType, v.WeaponType, v.Entries) end

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

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