FANDOM


local Filename = {}
local lib = require('Module:Funkcje')
 
function Filename.ability(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args,
        'Umiejętność.png',
        '%s.%s.png',
        args['champion'] or args[1],
        args['ability'] or args[2]
    )
end
function Filename.rune(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args,
        'Runa.png',
        '%s.png',
        args['rune'] or args[1]
    )
end
function Filename.mastery(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args,
        'Specjalizacja.png',
        '%s.specjalizacja.s%d.png',
        empty(string.gsub(args['mastery'] or args[1] or '', '%s*%b()$', '')),
        tonumber(args['season'] or args[2])
    )
end
function Filename.item(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args,
        'Przedmiot.png',
        '%s przedmiot.png',
        args['item'] or args[1]
    )
end
function Filename.spell(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args,
        'Czar.png',
        '%s.png',
        args['spell'] or args[1]
    )
end
function Filename.effect(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args,
        'Efekt.png',
        '%s.png',
        args['effect'] or args[1]
    )
end
function Filename.enchantment(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, 
        'Przedmiot.png',
        '%s - %s przedmiot.png',
        args['item'] or args[1],
        args['enchantment'] or args[2]
    )
end
function Filename.character(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args,
        'Postać.png',
        '%sSquare.png',
        args['character'] or args[1]
    )
end
function Filename.skin(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args,
        'Skórka.jpg',
        '%s.%s.skórka.jpg',
        args['champion'] or args[1],
        args['skin'] or args[2] or 'Klasyczna'
    )
end
function Filename.loading(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args,
        'Portret.jpg',
        '%s.%s.portret.jpg',
        args['champion'] or args[1],
        args['skin'] or args[2] or 'Klasyczna'
    )
end
 
function Filename.encode(frame)
    return mw.text.trim(encode(frame.args[1]))
end
 
---------------------------------------------------------------
function handleArgs(args, default, filename, ...)
    if args['test'] then
        return testString(args['test'], (args['prefix'] or '') .. filename .. (args['suffix'] or ''), args['return'])
    end
    local result = mw.text.trim(encode(formatnil(filename, ...) or default or ''))
    if not args['raw'] then result = string.gsub(result or '', '[:\\|/\?<>\*"]', '') end
    result = (args['prefix'] or '') .. result .. (args['suffix'] or '')
    if args['parse'] then result = mw.getCurrentFrame():preprocess(result) end
    return result
end
function testString(text, filename, index)
    pattern = '^' .. string.gsub(filename, '[%^%$%(%)%%%.%[%]%*%+%-%?]', '%%%1') .. '$'
 
    pattern = string.gsub(pattern, '%%%%[0-9]*d', '(%%-?%%d*)')
    pattern = string.gsub(pattern, '%%%%s', '(.-)')
 
    local matches = {string.match(text, pattern)}
    if #matches > 0 then
        if index then return matches[tonumber(index)] end
        return #matches
    end
    return nil
end
function encode(text)
    if text == nil then return nil end
    text = mw.ustring.gsub(text, ':', '')
    return text
end
function formatnil(text, ...)
    if select("#", ...) == 0 then return text end
    for i=1, select("#", ...) do
        if select(i, ...) == nil then return nil end
    end
    return mw.ustring.format(text, ...)
end
function empty(text)
    if text == '' then return nil end
    return text
end
return Filename

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.