Module:GrowthRateTable

local cargo = mw.ext.cargo local p = {}

function p.Table local frame = mw.getCurrentFrame --Initialize table local tbl = mw.html.create('table') :addClass('wikitable default') :css('text-align','center') -- Add table headers tbl:tag('th') :wikitext('PGR ')

for i = 1,5 do		tbl:tag('th') :wikitext( frame:expandTemplate{ title = "Rarity", args = { i } } ) end

local rateQuery = cargo.query("UnitStats", "MAX(HPGR3)=maxhp,MAX(AtkGR3)=maxatk,MAX(SpdGR3)=maxspd,MAX(DefGR3)=maxdef,MAX(ResGR3)=maxres,MIN(HPGR3)=minhp,MIN(AtkGR3)=minatk,MIN(SpdGR3)=minspd,MIN(DefGR3)=mindef,MIN(ResGR3)=minres" )[1] rateQuery = rateQuery or { ["maxhp"] = 80, ["maxatk"] = 80, ["maxspd"] = 80, ["maxdef"] = 80, ["maxres"] = 80, ["minhp"] = 25, ["minatk"] = 25, ["minspd"] = 25, ["mindef"] = 25, ["minres"] = 25 } local maxRate = math.max(rateQuery["maxhp"], rateQuery["maxatk"], rateQuery["maxspd"], rateQuery["maxdef"], rateQuery["maxres"]) + 5 local minRate = math.min(rateQuery["minhp"], rateQuery["minatk"], rateQuery["minspd"], rateQuery["mindef"], rateQuery["minres"]) - 5

for i = (minRate - (minRate % 5)),(maxRate+9) - ((maxRate+9)%5),5 do -- last multiple of 5 before minrate, next multiple of 5 after maxRate,increment by 5 local tr = tbl:tag('tr') tr:tag('td') :wikitext("" .. i .. "%") for r = 1,5 do				tr:tag('td') :wikitext(math.floor(0.39 * math.floor(i * (0.79 + 0.07 * r)))) end end return tostring(tbl) end return p