FANDOM


--
-- Implements [[Calculator:Other/Dragonkin lamps]]
--
local p = {}
 
local effigy_exp = require('Module:Effigies/data')
local XPAtLevel = require('Module:Experience/data')
local commas = require('Module:Addcommas')
 
function p.effigies_for_level(frame)
    local target_level = frame.args.level
    local current_xp = frame.args.xp
    local dungeoneering = string.lower(frame.args.dg) == 'yes'
 
    if type(current_xp) == 'string' then
         current_xp = commas._strip(current_xp)
         current_xp = tonumber(current_xp)
    end
 
    if type(target_level) == 'string' then
         target_level = commas._strip(target_level)
         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
        if (level > 99 and not dungeoneering) then
            return 99
        else
            return level
        end
    end
 
    local target_xp = XPAtLevel[target_level]
    local effigies = 0
 
    while current_xp < target_xp do
        effigies = effigies + 1
        current_level = level_at_xp(current_xp)
        local xp_per_effigy = effigy_exp[current_level]
 
        current_xp = current_xp + xp_per_effigy
    end
 
    return 'You will need '..commas._add(effigies)..' dragonkin lamps.'
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.