FANDOM


local R = {}
 
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 R.color(frame)
    local text = frame.args and frame.args[1] or frame[1] or frame or ''
    return color(text)
end
function R.colorTop(frame)
    local text = frame.args and frame.args[1] or frame[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 R

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.