Module:BTD6 hero xp
Documentation for this module may be created at Module:BTD6 hero xp/doc
local p = {}
local level_reqs = { 180, 460, 1000, 1860, 3280, 5180, 8320, 9380, 13620, 16380, 14400, 16650, 14940, 16380, 17820, 19260, 20700, 16470, 17280 }
local difficulty_modifiers = { 1, 1.1, 1.2, 1.3 }
function p.main(frame)
local wikitable = {
'{|class="wikitable" style="text-align:center;display:inline-table"\n!rowspan="2"|Level!!rowspan="2"|XP required!!colspan="4"|<abbr title="if placed on round 1">Rounds to level up</abbr>\n|-\n![[Beginner]]!![[Intermediate]]!![[Advanced]]!![[Expert]]'
}
local curve = tonumber(frame.args[1])
local total_required = 0
local total_xp_diff = {0, 0, 0, 0}
local total_rounds_diff = {0, 0, 0, 0}
local function insert_rounds(index, req)
local xp = 0
local mult = difficulty_modifiers[index]
local total_xp = total_xp_diff[index]
local total_rounds = total_rounds_diff[index]
while total_xp < req do
total_rounds = total_rounds + 1
if total_rounds <= 20 then xp = (total_rounds * 20 + 20)
elseif total_rounds > 20 and total_rounds <= 50 then xp = (total_rounds * 50 - 380)
else xp = (total_rounds * 90 - 2880) end
total_xp = total_xp + (xp * mult)
end
table.insert(wikitable, string.format('|%i (%i)', total_rounds - total_rounds_diff[index], total_rounds))
total_xp_diff[index] = total_xp
total_rounds_diff[index] = total_rounds
end
for i, v in ipairs(level_reqs) do
local req = math.floor(v * curve)
total_required = total_required + req
table.insert(wikitable, string.format('|-\n!%i\n|%i (%i)', i + 1, req, total_required))
insert_rounds(1, total_required)
insert_rounds(2, total_required)
insert_rounds(3, total_required)
insert_rounds(4, total_required)
end
table.insert(wikitable, '|}')
return table.concat(wikitable, '\n')
end
return p