Module:Power

local getArgs = require('Module:Arguments').getArgs

local statname, color = require('Module:Statname'), require('Module:Color') local statData = mw.loadData('Module:Statname/Data')

local p = {}

function p.powerStoneTable(frame) local args = getArgs(frame) local stats = {} for _, stat in pairs(statData) do		stats[stat.shortcode] = args[stat.shortcode] end return p._powerStoneTable(stats, args.unique_power_bonus, args.magical_power) end

function p._powerStoneTable(stats, bonus, magicalPower) local multiplier = 29.97 * math.pow((math.log(0.0019 * (tonumber(magicalPower) or 250) + 1)), 1.2) local wikitable = mw.html.create('table'):addClass('wikitable ct') wikitable:tag('tr') :tag('th'):attr('rowspan', '2'):wikitext('Stat'):done :tag('th'):attr('colspan', '2'):wikitext('Bonus'):done :done :tag('tr') :tag('th'):wikitext('Base'):done :tag('th'):wikitext(('%s'):format(color.colorText('gold', (magicalPower or '250') .. ' Magical Power'))) :done for name, value in pairs(stats) do		local row = wikitable:tag('tr') :tag('td'):wikitext(statname.stat(name)):done :tag('td'):wikitext(color.colorText('green', mw.ext.ParserFunctions.expr(('%s round1'):format(value)))):done -- probably not the best way to round in Lua :tag('td'):wikitext(color.colorText('green', mw.ext.ParserFunctions.expr(('%s round1'):format(value * multiplier)))):done row:done end if bonus then wikitable:tag('tr') :tag('th'):wikitext('Unique Power Bonus'):done :tag('td'):attr('colspan', '2'):css('text-align', 'left'):wikitext(bonus):done :done end wikitable:done return wikitable end

return p