FANDOM


--
-- Implements [[Calculator:Dungeoneering/Daily]]
--
local p = {}
 
local dung_daily_exp = require('Module:Dungeoneering Dailies/data')
local XPAtLevel = require('Module:Experience/data')
 
function p.dung_dailies_for_level(frame)
	local target_level = frame.args.level
	local current_xp = frame.args.xp
 
	if type(current_xp) == 'string' then
		 current_xp = tonumber(current_xp)
	end
 
	if type(target_level) == 'string' then
		 target_level = tonumber(target_level)
	end
 
	local current_lvl
	local function level_at_xp(xp)
		local level
		for i=120,1,-1 do
		   if XPAtLevel[i] <= xp then
				level = i
				break
		   end
		end
		return level
	end
 
    if current_xp == 0 then
    	current_level = 1
    elseif current_xp > 120 then
        current_level = level_at_xp(current_xp)
    else
        current_level = current_xp
        current_xp = XPAtLevel[current_level]
    end
 
    local target_xp
    if target_level > 120 then
        target_xp = target_level
        target_level = level_at_xp(target_xp)
    else
	    target_xp = XPAtLevel[target_level]
    end
 
	local dung_dailies = 0
 
	while current_xp < target_xp do
		dung_dailies = dung_dailies + 1
		current_level = level_at_xp(current_xp)
		local xp_per_dung_daily = dung_daily_exp[current_level]
 
		current_xp = current_xp + xp_per_dung_daily
	end
 
    return dung_dailies
end
 
--
-- Module access point
--
function p._dung_dailies_for_level(args)
    return p.dung_dailies_for_level(args)
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.