FANDOM


local T = {}
local lang = mw.language.new('pl')
 
-- Po przecinku
function T.decimals(frame)
    local text = frame.args and frame.args[1] or frame or ''
    text = mw.ustring.gsub(text, '([0-9]+),([0-9])', '%1.%2')
    text = mw.ustring.gsub(text, '([0-9]+)%.([0-9]*)', '%1<small>,%2</small>')
    return text
end
-- Poziomy
function T.progression(frame)
    local text = frame.args and frame.args[1] or frame or ''
    local parts = {}
    for _,v in ipairs(mw.text.split(text, '%s*/%s*')) do
        parts[#parts+1] = mw.text.trim(v)
    end
    return table.concat(parts, ' / ')
end
-- Kolorowanie nawiasów
local colors = {
    {'[×x] poziom', 'color-lv'},
    {'na poziom', 'color-lv'},
    {'co poziom', 'color-lv'},
    {'mocy umiejętności', 'color-ap'},
    {'AP', 'color-ap'},
    {'obrażeń ataku', 'color-ad'},
    {'AD', 'color-ad'},
    {'pancerza', 'color-ar'},
    {'premii do zdrowia', 'color-hp'},
    {'brakującego zdrowia', 'color-hp'},
    {'maksymalnego zdrowia', 'color-hp'},
    {'premii do many', 'color-mp'},
    {'brakującej many', 'color-mp'},
    {'maksymalnej many', 'color-mp'},
    {'Wysysającym Uderzeniem', 'color-ss'},
    {'złota', 'color-gold'},
    {'zł', 'color-gold'},
}
local function color_check(text)
    for i,v in ipairs(colors) do
        if mw.ustring.find(text, v[1]) then return v[2] end
    end
    return nil
end
local function color(text, top)
    text = text or ''
    top = top and true or false
    local i, segments = 1, {}
    while true do
        local s,e = mw.ustring.find(text, '%b()', i)
        if s == nil then break end
        if s > i then segments[#segments+1] = {t=mw.ustring.sub(text, i, s-1)} end
 
        segments[#segments+1] = {p=mw.ustring.sub(text, s+1, e-1)}
        i = e+1
    end
    segments[#segments+1] = {t=mw.ustring.sub(text, i, #text)}
 
    local text, first = '', nil
 
    for i,v in ipairs(segments) do
        if v.t then
            if top then first = first or color_check(v.t) end
            text = text .. v.t
        else
            local t, c = color(v.p, true)
            if c then
                text = text .. mw.ustring.format('<span class="%s">(%s)</span>', c, t)
            else
                text = text .. '(' .. t ..')'
            end
        end
    end
    if top then return text, first end
    return text
end
function T.color(frame)
    local text = frame.args and frame.args[1] or frame or ''
    return color(text)
end
function T.colorTop(frame)
    local text = frame.args and frame.args[1] or frame or ''
    local t, c = color(text, true)
    if c then return mw.ustring.format('<span class="%s">%s</span>', c, t) end
    return t
end
 
return T

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.