FANDOM


local PrintTable = require('Module:PrintTable')
 
local p = {}
 
function row_attr(lv)
    local value = 'style="text-align: right; '
    if lv == 40 or lv == 50 or lv == 60 or lv == 80 or lv == 100 then
        value = value .. 'font-weight: bold; background-color: rgba(128, 128, 128, 0.3);'
    end
 
    return value .. '"' 
end
 
function cell_transformer(value)
    if value == '' then
        return value
    end
    return '{{formatnum:' .. value .. '}}'
end
 
function preprocess(frame, string)
    if frame ~= nil then 
        return frame:preprocess(string)
    else
        return string
    end
end
 
function p.main(frame)
    local data = {}
    -- 1: "Level" 2: "Exp to next" 3: "Accum. exp to level"
 
    local expToNext = 110       -- expToNext at lv1
    local deltaExpToNext = 0
    local accumExp = 0
 
    for lv = 1, 100 do
        local row = {}
        row[1] = lv
        row[3] = accumExp
 
        if lv == 100 then
            row[2] = ''
        else
            row[2] = expToNext
        end
        data[lv] = row
 
        -- Iterate data
        if lv <= 8 then
            deltaExpToNext = (lv + 2) * 10
        else
            deltaExpToNext = 100
        end
 
        accumExp = accumExp + expToNext
        expToNext = expToNext + deltaExpToNext
 
    end
 
    return preprocess(frame, PrintTable(data, row_attr, nil, cell_transformer))
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.