Module:BTD6 hero xp: Difference between revisions

mNo edit summary
mNo edit summary
Line 10: Line 10:
local mFloor = math.floor
local mFloor = math.floor


local function roundHalfToEven(num)
local function RoundHalfToEven(num)
local floored = mFloor(num)
local floored = mFloor(num)
Line 28: Line 28:
local sformat = string.format
local sformat = string.format
local xp_lv3 = mfloor(640 * curve)
local xp_lv3 = RoundHalfToEven(640 * curve)
local total_required = 0
local total_required = 0
Line 47: Line 47:
elseif total_rounds > 20 and total_rounds <= 50 then xp = (total_rounds * 40 - 380)
elseif total_rounds > 20 and total_rounds <= 50 then xp = (total_rounds * 40 - 380)
else xp = (total_rounds * 90 - 2880) end
else xp = (total_rounds * 90 - 2880) end
local floor = mfloor(xp * mult)
    -- Check if it is a perfect half tie-breaker
    -- Check if it is a perfect half tie-breaker
    total_xp = total_xp + roundHalfToEven(xp * mult)
    total_xp = total_xp + RoundHalfToEven(xp * mult)
end
end
Line 63: Line 61:
for i, v in ipairs(level_reqs) do
for i, v in ipairs(level_reqs) do
local req = roundHalfToEven(v * curve)
local req = RoundHalfToEven(v * curve)
total_required = total_required + req
total_required = total_required + req
tinsert(wikitable, sformat('|-\n!%i\n|%s (%s)', i + 1, lang:formatNum(req), lang:formatNum(total_required)))
tinsert(wikitable, sformat('|-\n!%i\n|%s (%s)', i + 1, lang:formatNum(req), lang:formatNum(total_required)))