Fandom


-- <pre>
local Filename = {}
 
-- Dependencies
local lib = require('Module:Feature')
 
--[[
{{#invoke: Filename | ability
| ability     OR 1 = 
| variant     OR 2 =  -- can be empty
}}
 
{{#invoke: Filename | buff
| buff        OR 1 = 
| variant     OR 2 =  -- can be empty
}}
 
{{#invoke: Filename | champion
| variant     OR 2 =  -- can be empty
}}
 
{{#invoke: Filename | championcircle
| champion    OR 1 = 
| skin        OR 2 =  -- can be empty
| variant     OR 3 =  -- can be empty
}}
 
{{#invoke: Filename | chroma
| champion    OR 1 = 
| skin        OR 2 =  -- can be empty
| chroma      OR 3 = 
}}
 
{{#invoke: Filename | item
| item        OR 1 = 
| enchantment OR 2 =  -- can be empty
| variant     OR 3 =  -- can be empty
}}
 
{{#invoke: Filename | loading
| champion    OR 1 = 
| skin        OR 2 = 
| variant     OR 3 =  -- can be empty
}}
 
{{#invoke: Filename | mastery
| mastery     OR 1 = 
| season      OR 2 = 
}}
 
{{#invoke: Filename | monster
| monster     OR 1 = 
| variant     OR 2 =  -- can be empty
}}
 
{{#invoke: Filename | profileicon
| profileicon OR 1 = 
| variant     OR 2 =  -- can be empty
}}
 
{{#invoke: Filename | rune
| rune        OR 1 = 
| variant     OR 2 =  -- can be empty
}}
 
{{#invoke: Filename | runeold
| stat        OR 1 = 
| rune        OR 2 = 
| tier        OR 3 = 
}}
 
{{#invoke: Filename | skin
| champion    OR 1 = 
| skin        OR 2 = 
| variant     OR 3 =  -- can be empty
}}
 
{{#invoke: Filename | spell
| spell       OR 1 = 
| variant     OR 2 =  -- can be empty
}}
 
{{#invoke: Filename | ward
| ward        OR 1 = 
}}
 
]]--
 
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, mw.text.trim(encode(
        formatnil('%s %s %s.png', args['champion'] or args[1], args['ability'] or args[2], args['variant'] or args[3])
    or
        formatnil('%s %s.png', args['champion'] or args[1], args['ability'] or args[2])
    or
        'Placeholder.svg')))
end
 
function Filename.summonerspell(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, mw.text.trim(encode(
        formatnil('%s Spell %s.png', args['spell'] or args[1], args['variant'] or args[2])
    or
        formatnil('%s Spell.png', args['spell'] or args[1])
    or
        'Placeholder.svg')))
end
 
function Filename.buff(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, mw.text.trim(encode(
        formatnil('%s Buff %s.png', args['buff'] or args[1], args['variant'] or args[2])
    or
        formatnil('%s Buff.png', args['buff'] or args[1])
    or
        'Placeholder.svg')))
end
 
function Filename.nbreward(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, mw.text.trim(encode(
        formatnil('%s NB reward %s.png', args['reward'] or args[1], args['variant'] or args[2])
    or
        formatnil('%s NB reward.png', args['reward'] or args[1])
    or
        'Placeholder.svg')))
end
 
function Filename.nbevent(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, mw.text.trim(encode(
        formatnil('%s NB event %s.png', args['event'] or args[1], args['variant'] or args[2])
    or
        formatnil('%s NB event.png', args['event'] or args[1])
    or
        'Placeholder.svg')))
end
 
function Filename.champion(frame)
    return Filename.championsquare(frame)
end
 
function Filename.championsquare(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, mw.text.trim(encode(
        formatnil('%s %s Sq %s.png', args['champion'] or args[1], 'Standard ' .. (args[1] or args['champion']), args['variant'] or args[2])
    or
        formatnil('%s %s Sq.png', args['champion'] or args[1], 'Standard ' .. (args[1] or args['champion']))
    or
        'ChampionSquare.png')))
end
 
function Filename.championcircle(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, mw.text.trim(encode(
        formatnil('%s %s C %s.png', args['champion'] or args[1], args['skin'] or args[2] or 'Standard ' .. (args[1] or args['champion']), args['variant'] or args[3])
    or
        formatnil('%s %s C.png', args['champion'] or args[1], args['skin'] or args[2] or 'Standard ' .. (args[1] or args['champion']))
    or
        'ChampionSquare.png')))
end
 
function Filename.chroma(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, mw.text.trim(encode(
        formatnil('%s %s %sM%s.png', args['champion'] or args[1], args['skin'] or args[2] or 'Standard '.. (args[1] or args['champion']), (args['chroma'] or args[3]) and ('('..(args['chroma'] or args[3])..') ') or '', (args['variant'] or args[4]) and ' '..(args['variant'] or args[4]) or '') or 'Placeholder.svg')))
end
 
function Filename.item(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    if (args['enchantment']) then
        result = handleArgs(args, mw.text.trim(encode(
            formatnil('%s (%s) item %s.png', args['item'] or args[1], args['enchantment'] or args[2], args['variant'] or args[3])
        or
            formatnil('%s (%s) item.png', args['item'] or args[1], args['enchantment'] or args[2])
        or
            'Placeholder.svg')))
    else
        result = handleArgs(args, mw.text.trim(encode(
            formatnil('%s item %s.png', args['item'] or args[1], args['variant'] or args[2])
        or
            formatnil('%s item.png', args['item'] or args[1])
        or
            'Placeholder.svg')))
    end
    return result
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, mw.text.trim(encode(
        formatnil('%s %s L %s.jpg', args['champion'] or args[1], args['skin'] or args[2] or 'Standard ' .. (args['champion'] and args['champion'] or args[1]), args['variant'] or args[3])
    or
        formatnil('%s %s L.jpg', args['champion'] or args[1], args['skin'] or args[2] or 'Standard '.. (args['champion'] and args['champion'] or args[1]), args['champion'] or args[1])
    or
        'Champion SkinLoading.jpg')))
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, mw.text.trim(encode(
        formatnil('%s mastery %d.png', args['mastery'] or args[1], tonumber(args['season'] or args[2]))
    or 
        'Placeholder.svg')))
end
 
function Filename.monster(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, mw.text.trim(encode(
        formatnil('%sSquare %s.png', args['monster'] or args[1], args['variant'] or args[2])
    or
        formatnil('%sSquare.png', args['monster'] or args[1])
    or
        'Placeholder.svg')))
end
 
function Filename.profileicon(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, mw.text.trim(encode(
        formatnil('%s profileicon %s.png', args['profileicon'] or args[1], args['variant'] or args[2])
    or
        formatnil('%s profileicon.png', args['profileicon'] or args[1])
    or
        'Placeholder.svg')))
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, mw.text.trim(encode(
        formatnil('%s Rune %s.png', args['rune'] or args[1], args['variant'] or args[2])
    or
        formatnil('%s Rune.png', args['rune'] or args[1])
    or
        'Placeholder.svg')))
end
 
function Filename.runeold(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, mw.text.trim(encode(
        formatnil('%s %s %d.png', args['stat'] or args[1], args['rune'] or args[2], tonumber(args['tier'] or args[3]))
    or
        'Placeholder.svg')))
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, mw.text.trim(encode(
        formatnil('%s %s S %s.jpg', args['champion'] or args[1], args['skin'] or args[2] or 'Standard ' .. (args['champion'] and args['champion'] or args[1]), args['variant'] or args[3])
    or
        formatnil('%s %s S.jpg', args['champion'] or args[1], args['skin'] or args[2] or 'Standard '.. (args['champion'] and args['champion'] or args[1]), args['champion'] or args[1])
    or
        'Champion SkinSkin.jpg')))
end
 
function Filename.ward(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return handleArgs(args, mw.text.trim(encode(formatnil('%s Auge.png', args['ward'] or args[1]) or 'Placeholder.svg')))
end
 
-- Helper functions
function Filename.encode(frame)
    return mw.text.trim(encode(frame.args[1]))
end
 
function encode(text)
    if text == nil then return nil end
    text = mw.ustring.gsub(text, ':', '-')
    text = mw.ustring.gsub(text, '/', '')
    return text
end
 
function handleArgs(args, filename)
    local result = filename
    if args['prefix'] then filename = args['prefix'] .. filename end
    if args['suffix'] then filename = filename .. args['suffix'] end
    if args['parse'] then filename = mw.getCurrentFrame():preprocess(filename) end
    return result
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
 
return Filename
-- </pre>
-- [[Kategorie:Module]]
Nutzung von Community-Inhalten gemäß CC-BY-SA , sofern nicht anders angegeben.