Zuletzt bearbeitet vor 5 Tagen
von Xineohp1506

Player

Version vom 30. April 2025, 00:40 Uhr von Xineohp1506 (Diskussion | Beiträge)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)

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

local player = {}
local helper = require("Module:LPON/Helper")
local transcluder = require("Module:Transcluder")
local getArgs = require("Module:Arguments").getArgs

function player.render(frame)
    local args = getArgs(frame)
    local output = ''
    local name = args["Name"] or mw.title.getCurrentTitle().text
    local cleanName = helper.cleanString(name)

    -- DISPLAYTITLE setzen
    helper.setDisplayTitle({ title = name })

    -- Semantische Eigenschaften
    helper.setProperty({ args = { ["LPON:Spieler"] = name } })
    if args["Status"] then helper.setProperty({ args = { ["LPON:Status"] = args["Status"] } }) end
    if args["Beitritt"] then helper.setProperty({ args = { ["LPON:Beitritt"] = args["Beitritt"] } }) end
    if args["Rolle"] then helper.setProperty({ args = { ["LPON:Rolle"] = args["Rolle"] } }) end
    if args["Projekte"] then
        for projekt in mw.text.gsplit(args["Projekte"], ",") do
            helper.setProperty({ args = { ["LPON:Projekt"] = mw.text.trim(projekt) } })
        end
    end

    -- Container für alle Boxen
    output = output .. '<div class="lpon-player-container">'

    -- Über mich
    output = output .. '<div class="lpon-player-box">\n'
    output = output .. '    <h2>Über mich</h2>\n'
    output = output .. '    <p>' .. (args["Über"] or "Keine Beschreibung vorhanden.") .. '</p>\n'
    output = output .. '</div>\n'

    -- Allgemein + Statistiken
    local episoden = args["Episoden"] or "-"
    local projekte = args["Projekte"] and select(2, string.gsub(args["Projekte"], ",", "")) + 1 or "-"
    output = output .. '<div class="lpon-player-box">\n'
    output = output .. '    <h2>Allgemein</h2>\n'
    output = output .. '    <ul>\n'
    output = output .. '        <li><b>Status:</b> ' .. (args["Status"] or "Unbekannt") .. '</li>\n'
    output = output .. '        <li><b>Beitritt:</b> ' .. (args["Beitritt"] or "Unbekannt") .. '</li>\n'
    output = output .. '        <li><b>Rolle:</b> ' .. (args["Rolle"] or "Unbekannt") .. '</li>\n'
    output = output .. '    </ul>\n'
    output = output .. '    <h2>Statistiken</h2>\n'
    output = output .. '    <ul>\n'
    output = output .. '        <li><b>Projekte:</b> ' .. projekte .. '</li>\n'
    output = output .. '        <li><b>Episoden:</b> ' .. episoden .. '</li>\n'
    output = output .. '    </ul>\n'
    output = output .. '</div>\n'

    -- Projekte
    output = output .. '<div class="lpon-player-box">\n'
    output = output .. '    <h2>Projekte</h2>\n'
    output = output .. '    <ul>'
    if args["Projekte"] then
        for projekt in mw.text.gsplit(args["Projekte"], ",") do
            projekt = mw.text.trim(projekt)
            output = output .. '<li>[[LetsPlayOrNot:' .. projekt .. '|' .. projekt .. ']]</li>'
        end
    else
        output = output .. '<li>Keine Projekte hinterlegt.</li>'
    end
    output = output .. '</ul>\n'
    output = output .. '</div>\n'
    output = output .. '</div>' -- Ende von .lpon-player-container

    -- Links (falls aktiviert)
    if args["Links"] == "true" then
        output = output .. '<div class="lpon-player-links">\n'
        output = output .. '    <h2>Links</h2>'
        local linkPage = 'LetsPlayOrNot:' .. name .. '/Links'
        local rawContent = transcluder.get(linkPage)
        output = output .. frame:preprocess(rawContent)
        output = output .. '</div>'
    end

    return output
end

return player