Module:BTD6 hero xp: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 10: | Line 10: | ||
local mFloor = math.floor | local mFloor = math.floor | ||
local function | local function RoundHalfUp(num) | ||
local floored = mFloor(num) | local floored = mFloor(num) | ||
return (num - floored | return floored + ((num - floored >= 0.5) and 1 or 0) | ||
end | end | ||
| Line 25: | Line 25: | ||
-- local functions to improve performance | -- local functions to improve performance | ||
local tinsert = table.insert | local tinsert = table.insert | ||
local sformat = string.format | local sformat = string.format | ||
local xp_lv3 = | local xp_lv3 = RoundHalfUp(640 * curve) | ||
local total_required = 0 | local total_required = 0 | ||
| Line 48: | 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 | ||
-- Check if it is a perfect half tie-breaker | -- Check if it is a perfect half tie-breaker | ||
total_xp = total_xp + | total_xp = total_xp + RoundHalfUp(xp * mult) | ||
end | end | ||
| Line 64: | Line 61: | ||
for i, v in ipairs(level_reqs) do | for i, v in ipairs(level_reqs) do | ||
local req = | local req = RoundHalfUp(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))) | ||