Die Dokumentation für dieses Modul kann unter Modul:UniverseData/Doku erstellt werden

-- <pre>

--[[
        Key
            reference       String
            author          String
            artwork         String
            starring        Tabelle
            mentioned       Tabelle
            region          Tabelle
            loretype        String | Biographie, Comic, Fraktion, Kurzgeschichte, Video, Musikvideo
            duration        Zahl
            description     String
            previous        String
            following       String  | (note: 'next' is a reserved word)
            au              String  | wenn Alternatives Universum, setze auf "True"
            status          String  | wenn veraltet, setze auf "Veraltet" steht
]]

local p = {}

local loreData  = mw.loadData('Module:UniverseData/data')
local lib       = require('Module:Feature')
local FN        = require('Module:Filename')


function p.loreTemplate()
    local loreList = mw.html.create('ul')
    local lore = {}
 
    for x in pairs(loreData) do
        table.insert(lore, x)
    end
    table.sort(lore)
 
    for _, piece in pairs(lore) do
        local t = loreData[piece]
        local link = piece
        local name = piece
        local loretype = t.loretype or "N/A"
        local starring = t.starring
        local entry = ''
        
        if starring then
            entry = '[[' .. link .. '|' .. name .. ']] <small>('.. getChampions(starring) ..')</small>'
        else
            entry = '[[' .. link .. '|' .. name .. ']]'
        end
        
        if loretype == "Kurzgeschichte" then
            loreList
                :tag('li')
                    :tag('div')
                        :wikitext(entry)
                    :done()
                :done()
                :newline()
        end
    end
    
    return loreList
end

function p.getBanner(frame) 
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    return banner(args[1])
end

function p.getCategories(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    
    local s = ""
    local t = loreData[args[1]] or loreData["Etwas ist schiefgelaufen"]
    local loretype = t.loretype or nil
    local starring = t.starring or {}
    local mentioned = t.mentioned or {}
    local region = t.region or {}
    local canon = t.status or {}
    local count = 0
    
    if t.english == "True" then
        s = s .. "[[Category:Seiten mit Übersetzungsproblemen]]"
        s = s .. "<table style='' class='plainlinks ambox ambox-green'><tr><td class='ambox-image'>[[File:Aber warum? Sticker.png|65px|link=]]</td><td class='ambox-info' style='line-height: 1.5em;'>\Diese Artikelseite wurde erstellt, nachdem die zugehörige Quelle (League-Website, Event, o. Ä.) nicht mehr verfügbar / auffindbar war. Daher ist es möglich, dass Teile dieser Seite nicht korrekt übersetzt wurden oder auf Englisch sind!\</td></tr></table>"
    end
    if t.realmsofruneterra == "True" then
        s = s .. "[[Category:Reiche von Runeterra]]"
        s = s .. "<table style='' class='plainlinks ambox ambox-purple'><tr><td class='ambox-image'>[[File:LoL_Facebook_Icon_29.png|65px|link=]]</td><td class='ambox-info' style='line-height: 1.5em;'>\Diese Geschichte ist Teil des Buches [[Reiche von Runeterra]]. Die ganze Geschichte gibt es im physischen Buch. Aus rechtlichen Gründen darf hier im Wiki nur eine Zusammenfassung stehen.\</td></tr></table>"
    end
    
    if canon == "Veraltet" then
        s = s .. "[[Category:Alte Geschichte]]"
        s = s .. "<table style='' class='plainlinks ambox ambox-green'><tr><td class='ambox-image'>[[File:Adieu, Freund! Sticker.png|65px|link=]]</td><td class='ambox-info' style='line-height: 1.5em;'><i>\"Sind wir endlich fertig in dieser Realität? Hallo? Halooo?\"</i><ul><li> Diese Geschichte zählt nicht länger zum [[Runeterra Prime|Hauptkanon]], aber existiert hier für historische Zwecke.</li></ul></td></tr></table>"
    end
    if canon == "Fragwürdig" then
        s = s .. "[[Category:Fragwürdige Kanon-Geschichte]]"
        s = s .. "<table style='' class='plainlinks ambox ambox-green'><tr><td class='ambox-image'>[[File:Oops Sticker.png|65px|link=]]</td><td class='ambox-info' style='line-height: 1.5em;'><i>\"Paradoxe. Wie ich sie hasse.\"</i><ul><li> Diese Geschichte zählt nicht länger zum [[Runeterra Prime|Hauptkanon]], aber existiert hier für historische Zwecke.</li></ul></td></tr></table>"
    end
    if t.au == "True" then
        s = s .. "<table style='' class='plainlinks ambox ambox-green'><tr><td class='ambox-image'>[[File:Howdy Sticker.png|65px|link=]]</td><td class='ambox-info' style='line-height: 1.5em;'><i>\"Das Grenzland kann sein, was immer du willst.\"</i><ul><li> Diese Geschichte spielt in einem anderen [[Multiversum|Universum]] als dem [[Runeterra Prime|Hauptuniversum]].</li></ul></td></tr></table>"
        if loretype ~= nil then
            if loretype == "Video" then
                s = s .. "[[Category:Alternatives Universum-Video]]"
            elseif loretype == "Comic" then
                s = s .. "[[Category:" .. args[1] .. "]][[Category:Alternatives Universum-Comic]]"
            else
                s = s .. "[[Category:Alternatives Universum-" .. loretype .. "]]"
            end
        end
    else            
        if region ~= nil then
            for i, region in pairs(region) do
                s = s .. "[[Category:Geschichte von " .. region .. "]]"
            end
        else
            s = s .. "[[Category: Geschichte ohne Region]]"
        end
        if loretype ~= nil then
            if loretype == "Video" then
                s = s .. "[[Category:Video-Geschichte]]"
            elseif loretype == "Comic" then
                s = s .. "[[Category:" .. args[1] .. "]][[Category:Comic]]"
            else
                s = s .. "[[Category:" .. loretype .. "]]"
            end
        end
    end
        
    for i, champion in pairs(starring) do
        s = s .. "[[Category:" .. champion .. " Geschichte]]"
        count = count + 1
    end
        
    for i, champion in pairs(mentioned) do
        s = s .. "[[Category:" .. champion .. " Geschichte]]"
    end
        
    if count == 0 then
        s = s .. "[[Category: Geschichte ohne auftretende Champions]]"
    end

    return s    
end

function p.getAuthor(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    return loreData[args[1]].author or {"Unbekannter Autor"}
end

function p.getAuthorlist()
    local authors = {}
    local hash = {}
    local authorList = mw.html.create('ul')
 
    authorList:newline()
 
    for _, x in pairs(loreData) do
        if x.author ~= nil then
            for _, value in pairs(x.author) do
                if (not hash[value]) then
                    table.insert(authors, value)
                    hash[value] = true
                end
            end
        end
    end
    table.sort(authors)
 
    for _, author in pairs(authors) do
        authorList
            :tag('li')
                :wikitext('[[' .. author .. ']]')
                :done()
            :done()
            :newline()
    end
 
    return authorList
end

function p.getReference(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    return loreData[args[1]].reference or "https://universe.leagueoflegends.com/de_DE/"
end

function p.getArtwork(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    return loreData[args[1]].artwork or "Bard promo 2.jpg"
end

function p.getLorelist(frame)
    local loreList = mw.html.create('ul')
    local lore = {}
 
    for x in pairs(loreData) do
        table.insert(lore, x)
    end
    table.sort(lore)
 
    for _, piece in pairs(lore) do
        local t = loreData[piece]
        local link = piece
        local name = piece
        local loretype = t.loretype or "N/A"
        
        if loretype == "Biographie" then
            link = t.starring[1]
        end
        
        loreList
            :tag('li')
                :tag('div')
                    :wikitext('[[' .. link .. '|' .. name .. ']] ('.. loretype ..')')
                :done()
            :done()
            :newline()
    end
    
    return loreList
end

function p.getMore(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
 
    local champion      = args[1]
    local loreList      = "<h3>Mitspielende Champions</h3>"
    local mentionedList = ""
    local auList        = ""
    local lore          = {}
 
    for x in pairs(loreData) do
        table.insert(lore, x)
    end
    table.sort(lore)
 
    for _, piece in pairs(lore) do
        local hit = false
        local t = loreData[piece]
 
        if t.starring ~= nil and t.loretype ~= "Biographie" and t.loretype ~= "Fraktion" and t.status ~= "Veraltet" then
            for _, substarring in pairs(t.starring) do
                if substarring == champion then
                    hit = true
                end
            end
        end
        if hit == true then
            if t.au ~= "True" then
                loreList = loreList .. banner(piece)
            else
                auList = auList .. banner(piece)
            end
        end
    end
 
    for _, piece in pairs(lore) do
        local hit = false
        local t = loreData[piece]
 
        if t.mentioned ~= nil then
            for _, submentioned in pairs(t.mentioned) do
                if submentioned == champion then
                    hit = true
                end
            end
        end
        
        if hit == true then
            if t.au ~= "True" then
                mentionedList = mentionedList .. banner(piece)
            else
                auList = auList .. banner(piece)
            end
        end
 
    end
 
    if mentionedList ~= "" then 
       loreList = loreList .. "\n<div class='va-collapsible-content mw-collapsible mw-collapsed' data-expandtext='Einblenden' data-collapsetext='Ausblenden'><h3>Erwähnte Champions</h3><div class='va-collapsible-content mw-collapsible-content'>" .. mentionedList .. "</div></div>"
    end
 
    if auList ~= "" then 
       loreList = loreList .. "\n<div class='va-collapsible-content mw-collapsible mw-collapsed' data-expandtext='Einblenden' data-collapsetext='Ausblenden'><h3>Alternative Universen</h3><div class='va-collapsible-content mw-collapsible-content'>" .. auList .. "</div></div>"
    end
    
    return loreList
end

function p.getRegionlore(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
 
    local loreList = ""
    local lore = {}
    local result = false
 
    for x in pairs(loreData) do
        table.insert(lore, x)
    end
    table.sort(lore)
 
    for _, piece in pairs(lore) do
        local hit = false
        local t = loreData[piece]
        
        if (t.region ~= nil) then
            for _, subregion in pairs(t.region) do
                if subregion == args[1] then
                    hit = true
                    result = true
                end
            end
        else 
            if args[1] == "Runeterra" then 
                hit = true
                result = true
            end
            
        end
    
        if hit == true then
            loreList = loreList .. banner(piece, t)
        end
    end
 
    if result == false then 
       loreList = "Kein Ergebnis für " .. args[1] .. " gefunden."
    end
 
    return loreList .. "[[Category:Test]]"
end

function p.getDescription(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    return loreData[args[1]].description or "Beschreibung nicht spezifiziert."
end

function p.getDuration(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    return loreData[args[1]].duration or "Länge nicht spezifiziert."
end

function p.getLoretype(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    return loreData[args[1]].loretype or "Art der Geschichte nicht spezifiziert."
end

function p.getMentioned(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    if loreData[args[1]].mentioned == nil then
        return "N/A"
    else
        return getChampions(loreData[args[1]].mentioned)
    end
end

function p.getRegion(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    if loreData[args[1]].region == nil then
        return "Runeterra"
    else
        return lib.tbl(loreData[args[1]].region)
    end
end

function p.getStarring(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    
    if loreData[args[1]].starring == nil then
        return "N/A"
    else
        return getChampions(loreData[args[1]].starring)
    end
end

function p.getTest(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    return "{{User:TheTimebreaker/Lore/Banner|" .. args[1] .. "}}"
end

function p.getPrevious(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    return loreData[args[1]].previous or nil
end

function p.getFollowing(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

    return loreData[args[1]].following or nil
end


-- local functions

function banner(name)
    local piece = loreData[name] or loreData["Etwas ist schiefgelaufen"]
    local s = ""

    local bName = piece.disp_name or name
    local artwork = piece.artwork or "Bard promo 2.jpg"
    local author = piece.author or {"Unbekannter Autor"}
    local reference = piece.reference or "https://universe.leagueoflegends.com/de_DE/"
    local link = name
    local region = "Runeterra"
    local duration = piece.duration or "0"
    local starring = "N/A"
    local mentioned = "N/A"
    local canon = piece.status or ""
    local loretype = piece.loretype or ""
    local description = piece.description or ""
    
    if loretype == "Biographie" then link = piece.starring[1] end
    if piece.region ~= nil then region = piece.region[1] end
    if piece.starring ~= nil then starring = getChampions(piece.starring) end
    if piece.mentioned ~= nil then mentioned = getChampions(piece.mentioned) end
    
    s = s .. "<div class='champinfo-container' style='width:100%; min-height: 290px; overflow:hidden; position:relative; font-size:14px; color: #dddddd; display:flex;'>"
        --image
        s = s .. "<div class='FillImage' style='width:100%; height:100%; position:absolute; top: 0; left:0; opacity:0.2;'>[[File:" .. artwork .."|link=]]</div>"
        --/image
        --edit
        s = s .. "<sup style='position: absolute; top: 1em; right: 1em;'><span class='plainlinks'>[https://leagueoflegends.fandom.com/de/wiki/Modul:UniverseData/data?action=edit Bearbeiten]</span> • [[:File:" .. artwork .."|Bild]] • [" .. reference.. " Referenz]</sup>"
        --/edit
        --content
        s = s .. "<div style='text-align:center; z-index: 1; width: 500px; margin:auto;'><div style='margin:3em 0'>"
            
            s = s .. "<p id='title' style='margin:1em 0 1em 0;'>[[File:" .. region .. " Tip.png|x56px|link=" .. region .."]]</p>"
            
            if loretype == "Kurzgeschichte" then
                if duration == "0" then
                    s = s .. "<p id='duration' style='margin:1em 0 0 0;'> Kurzgeschichte </p>"
                else
                    s = s .. "<p id='duration' style='margin:1em 0 0 0;'> Kurzgeschichte • " .. duration .." Minuten zu lesen</p>"
                end
            else
                s = s .. "<p id='duration' style='margin:1em 0 0 0;'>" .. loretype .. "</p>"
            end
            
            if piece.previous ~= nil then
                s = s .. "<div style='position: absolute; top: 50%; left:1em; font-size:3em;'>[[" .. piece.previous .. "|⮜]]</div>"
            end
            
            s = s .. "<p id='title' style='font-size:250%; line-height:100%; margin:0;color:#c9aa71;'>[[" .. link .. "|" .. bName .."]]</p>"
            
            if loretype ~= "Video" then
                s = s .. "<p id='duration' style='margin:0 0 1em 0;'> Von "
                for i, value in ipairs(author) do
                    if i ~= 1 then
                        s = s  .. ", "
                    end
                    if value == "Unbekannter Autor" or value == "Mehrere Autoren" then
                        s = s .. value
                    else 
                        s = s .. "[[" .. value .. "]]"
                    end
                end
                s = s .. "</p>"
            end
            
            if piece.following ~= nil then
                s = s .. "<div style='position: absolute; top: 50%; right: 1em; font-size:3em;'>[[" .. piece.following .. "|⮞]]</div>"
            end
            
            if loretype ~= "Biographie" then 
                s = s .. "<p id='blurb' style='margin:1em 0 1em 0; font-size: 89%; text-transform: initial;'>" .. description:gsub("//n", "<br/>") .."</p>"
            end
            
            if starring ~= nil and loretype ~= "Biographie" then
                s = s .. "<p id='featured' style='margin:0 0 1em 0;'>Mit: " .. starring .. "</p>"
            end
            
            if mentioned ~= "N/A" then
                s = s .. "<p id='featured' style='margin:0 0 1em 0;'>Erwähnt: " .. mentioned .. "</p>"
            end
        
        s = s .. "</div></div>"
        --/content
    s = s .. "</div>"

    return s
end

function getChampions(t)
    local s = ""
 
    local championtable  = {}
    for i, champion in pairs(t) do
        table.insert(championtable, champion)
    end
    table.sort(championtable)
 
    for i, champion in pairs(championtable) do
        if i ~= 1 then
            s = s  .. ", "
        end
            s = s .. "<span style='white-space:nowrap'>[[File:" .. FN.championsquare({champion}) .. "|20px|link=" .. champion .. "]] [[" .. champion .. "]]</span>"
    end
 
    return s
end

return p

-- </pre>
-- [[Category:Lua]]
Nutzung von Community-Inhalten gemäß CC-BY-SA, sofern nicht anders angegeben.