Module:Charge drain

local p = {}

local reduction = { [0] = 1,	[1] = 0.99,	[2] = 0.97,	[3] = 0.95,	[4] = 0.93,	[5] = 0.91,	[6] = 0.88,	[7] = 0.86,	[8] = 0.83,	[9] = 0.8, }

local slot = { ['2h'] = 1.5, mh = 1, ['1h'] = 1, armour = 1, a = 1, oh = 0.5, t = 0.25, tool = 0.25, }

local eff = { [0] = 1,	[1] = 0.94,	[2] = 0.88,	[3] = 0.82 }

local lv = { [false] = 1, [true] = 0.9, }

local function floor(n) return math.floor(n*100)/100 end

local function floor_s(n) return string.format('%.2f', floor(n)) end

p.table = function (frame) local args = frame:getParent.args local tier = tonumber(args.tier) or 70 if tier < 70 then tier = 67 end local base = (tier - 60) / 8 local t = mw.html.create('table') local function make_4(tr, i, mult) tr	:tag('td') :wikitext(floor_s(base * slot['2h'] * reduction[i] * mult)) :done :tag('td') :wikitext(floor_s(base * slot['1h'] * reduction[i] * mult)) :done :tag('td') :wikitext(floor_s(base * slot['oh'] * reduction[i] * mult)) :done :tag('td') :wikitext(floor_s(base * slot['t'] * reduction[i] * mult)) :done end local function make_row(i, lvl) local tr = t:tag('tr') tr	:tag('th') :wikitext(i) :done make_4(tr, i, lv[lvl] * eff[0]) make_4(tr, i, lv[lvl] * eff[1]) make_4(tr, i, lv[lvl] * eff[2]) make_4(tr, i, lv[lvl] * eff[3]) end local function make_header(lv) local str = 'Item level 1-4' if lv then str = 'Item level 5+' end t	:addClass('wikitable') :css('text-align', 'right') :tag('tr') :tag('th') :attr('rowspan', 3) :wikitext('Reduction') :done :tag('th') :attr('colspan', 19) :wikitext(str) :done :done :tag('tr') :tag('th') :attr('colspan', 4) :wikitext('Base') :done :tag('th') :attr('rowspan', 12) :wikitext(' ') :done :tag('th') :attr('colspan', 4) :wikitext('Efficient 1') :done :tag('th') :attr('rowspan', 12) :wikitext(' ') :done :tag('th') :attr('colspan', 4) :wikitext('Efficient 2') :done :tag('th') :attr('rowspan', 12) :wikitext(' ') :done :tag('th') :attr('colspan', 4) :wikitext('Efficient 3') :done :done :tag('tr') :tag('th') :wikitext('2H') :done :tag('th') :wikitext('MH/A') :done :tag('th') :wikitext('OH') :done :tag('th') :wikitext('T') :done :tag('th') :wikitext('2H') :done :tag('th') :wikitext('MH/A') :done :tag('th') :wikitext('OH') :done :tag('th') :wikitext('T') :done :tag('th') :wikitext('2H') :done :tag('th') :wikitext('MH/A') :done :tag('th') :wikitext('OH') :done :tag('th') :wikitext('T') :done :tag('th') :wikitext('2H') :done :tag('th') :wikitext('MH/A') :done :tag('th') :wikitext('OH') :done :tag('th') :wikitext('T') :done :done :done end make_header(false) for i = 0, 9, 1 do		make_row(i, false) end make_header(true) for i = 0, 9, 1 do		make_row(i, true) end return t end

return p