Module:BTD6 paragon stats

From Blooncyclopedia, the independent Bloons knowledge base
Revision as of 17:56, 24 July 2024 by Polavux (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:BTD6 paragon stats/doc

local p = {}

local degreeRequirements = {
	0,      2000,   2324,   2666,   3027,   3408,   3808,   4228,   4669,   5131,
	5615,   6121,   6650,   7203,   7779,   8379,   9004,   9654,   10330,  11032,
	11761,  12518,  13302,  14114,  14955,  15825,  16725,  17655,  18616,  19609,
	20633,  21689,  22778,  23900,  25056,  26246,  27471,  28732,  30028,  31360,
	32729,  34135,  35579,  37061,  38582,  40143,  41743,  43383,  45064,  46786,
	48550,  50356,  52205,  54098,  56034,  58014,  60039,  62109,  64225,  66387,
	68596,  70853,  73157,  75509,  77910,  80360,  82860,  85410,  88011,  90664,
	93368,  96124,  98933,  101795, 104711, 107681, 110706, 113787, 116923, 120115,
	123364, 126670, 130034, 133456, 136937, 140478, 144078, 147738, 151459, 155241,
	159085, 162991, 166960, 170993, 175089, 179249, 183474, 187764, 192120, 200000
}

function p.main(frame)
	local ret = {
		'{|class="wikitable mw-collapsible mw-collapsed" style="text-align:center"\n|+style="white-space:nowrap"|Degree-dependent stats\n',
	}
	
	-- upper header
	table.insert(ret, '!rowspan="2"|Degree\n!rowspan="2"|Power')
	local labels = {}
	local sublabels = {}
	local colspans = {}
	
	for label in string.gmatch(frame.args['labels'], string.format('([^,]+)')) do
		table.insert(labels, label)
	end
	
	for colspan in string.gmatch(frame.args['colspans'], string.format('([^,]+)')) do
		table.insert(colspans, colspan)
	end
	
	for i=1, #labels do
		table.insert(ret, string.format('!colspan="%s"|<i>%s</i>', colspans[i], labels[i]))
	end
	
	-- lower header
	table.insert(ret, '|-')
	for label in string.gmatch(frame.args['sublabels'], string.format('([^,]+)')) do
		table.insert(sublabels, label)
		table.insert(ret, string.format('!%s', label))
	end
	
	-- values by degree
	for i=1, 100 do
		table.insert(ret, '|-')
		table.insert(ret, string.format("!%s\n|%s", i, degreeRequirements[i]))
		
		local values = {}
		
		for value in string.gmatch(frame.args['values'], string.format('([^,]+)')) do
			table.insert(values, value)
		end
		
		local bd = 0
		local amount = 0
		local prefix = ''
		local suffix = ''
		for j=1, #values do
			if sublabels[j] == 'Damage' then bd = values[j] end
			if sublabels[j] == 'MOAB-Class damage' then bd = bd + values[j] end
			if sublabels[j] == 'Boss damage' then bd = bd + values[j] end
			
			prefix = ''
			suffix = ''
			
			if sublabels[j] == 'Cooldown' then
				amount = values[j] / (1 + (0.01 * math.sqrt((i-1)*50)))
				suffix = 's'
			elseif sublabels[j] == 'Pierce' then
				if i == 100 then	amount = values[j] * 2 + 100
				else				amount = values[j] * (1 + (i-1) * 0.01) + i - 1
				end
			elseif sublabels[j] == 'Damage' then
				if i == 100 then	amount = values[j] * 2 + 10
				else				amount = values[j] * (1 + (i-1) * 0.01) + math.floor((i-1)/10)
				end
				bd = amount
			elseif sublabels[j] == 'Ceramic damage' or sublabels[j] == 'MOAB-Class damage' then
				if i == 100 then	amount = values[j] * 2
				else				amount = values[j] * (1 + (i-1) * 0.01)
				end
				prefix = '+'
				if sublabels[j] == 'MOAB-Class damage' then bd = bd + amount end
			elseif sublabels[j] == 'Boss damage' then
				if i == 100 then	amount = values[j] * 2
				else				amount = values[j] * (1 + (i-1) * 0.01)
				end
				prefix = '+'
				amount = ((amount + bd) * (1 + (math.floor(i/20)/4)) - amount)
			end
			if amount > 999 then table.insert(ret, string.format('|%s%.8g%s', prefix, amount, suffix))
			else table.insert(ret, string.format('|%sc%.4g%s', prefix, amount, suffix)) end
		end
	end
	
	table.insert(ret, '|}')
	return table.concat(ret, '\n')
end

return p