Module:UniverseData

--

--       Key            author          string            reference       string            artwork         string            starring        table            mentioned       table            region          table            loretype        string            duration        number            description     string            previous        string            following       string ('next' is a reserved word) -- 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 = '' .. name .. ' ('.. getChampions(starring) ..') ' else entry =  .. name ..  end if loretype == "Short Story" 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["Something Went Wrong"] local loretype = t.loretype or "Missing information" local starring = t.starring or {} local mentioned = t.mentioned or {} local region = t.region or {} local canon = t.status or {} local count = 0 if canon == "Outdated" then s = s .. ""       s = s .. " "   else if t.au == "True" then if loretype == "Video" then s = s .. ""           else s = s .. ""           end if loretype == "Comic" then s = s .. ""           end else if region ~= nil then for i, region in pairs(region) do                   s = s .. ""               end else s = s .. ""           end if loretype == "Video" then s = s .. ""           else s = s .. ""           end if loretype == "Comic" then s = s .. ""           end end for i, champion in pairs(starring) do           s = s .. ""           count = count + 1 end for i, champion in pairs(mentioned) do           s = s .. ""       end if count == 0 then s = s .. ""       end end return s   end

function banner(name) local piece = loreData[name] or loreData["Something Went Wrong"] local s = "" local artwork = piece.artwork or "Bard promo 2.jpg" local author = piece.author or "Unknown Author" local reference = piece.reference or "https://universe.leagueoflegends.com/en_US/" 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 == "Biography" 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 .. "" --image s = s .. " " --/image --edit s = s .. "Edit • Image • [" .. reference.. " Reference] " --/edit --content s = s .. " "            s = s .. " " if loretype == "Short Story" then if duration == "0" then s = s .. " Short Story " else s = s .. " Short Story • " .. duration .." Minute Read " end else s = s .. "" .. loretype .. " "           end if piece.previous ~= nil then s = s .. " ⮜ " end s = s .. "" .. name .." " if loretype ~= "Video" then s = s .. " By " if type(author) == "table" then for i, value in ipairs(author) do                       if i ~= 1 then s = s .. ", "                       end s = s .. value end else s = s .. author end s = s .. " "           end if piece.following ~= nil then s = s .. " ⮞ " end if loretype ~= "Biography" then s = s .. "" .. description:gsub("//n", " ") .." " end if starring ~= nil and loretype ~= "Biography" then s = s .. "Starring: " .. starring .. " "           end if mentioned ~= "N/A" then s = s .. "Mentioned: " .. mentioned .. " "           end s = s .. " "        --/content s = s .. " "

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 "Unknown Author" end

function p.getAuthorlist(frame) local authors = {} local hash = {} local authorList = mw.html.create('ul') authorList:newline for _, x in pairs(loreData) do       if x.author ~= nil then if type(x.author) == "table" then for _, value in pairs(x.author) do                   if (not hash[value]) then table.insert(authors, value) hash[value] = true end end else if (not hash[x.author]) then table.insert(authors, x.author) hash[x.author] = 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/en_US/" 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 == "Biography" then link = t.starring[1] end loreList :tag('li') :tag('div') :wikitext('' .. name .. ' ('.. loretype ..')') :done :done :newline end return loreList end

function p.getChampionlore(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.starring ~= nil) then if type(t.starring) == "table" then for _, substarring in pairs(t.starring) do                   if substarring == args[1] then hit = true result = true end end else if t.starring == args[1] then hit = true result = true end end end if hit == true then loreList = loreList .. banner(piece) end end for _, piece in pairs(lore) do       local hit = false local t = loreData[piece] if (t.mentioned ~= nil) then if type(t.mentioned) == "table" then for _, submentioned in pairs(t.mentioned) do                   if submentioned == args[1] then hit = true result = true end end else if t.mentioned == args[1] then hit = true result = true end end end if hit == true then loreList = loreList .. banner(piece) end end if result == false then loreList = "No match found for " .. args[1] .. "."   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 loreList = "" local lore = {} local result = false local result2 = false for x in pairs(loreData) do       table.insert(lore, x)    end table.sort(lore) loreList = loreList .. " Starring Champion " for _, piece in pairs(lore) do       local hit = false local t = loreData[piece] if not (t.au == "True") and t.starring ~= nil and t.loretype ~= "Biography" and t.loretype ~= "Faction" and t.status ~= "Outdated" then if type(t.starring) == "table" then for _, substarring in pairs(t.starring) do                   if substarring == args[1] then hit = true result = true end end else if t.starring == args[1] then hit = true result = true end end end if hit == true then loreList = loreList .. banner(piece) end end local templist = "" for _, piece in pairs(lore) do       local hit2 = false local t = loreData[piece] if (t.mentioned ~= nil) then if type(t.mentioned) == "table" then for _, submentioned in pairs(t.mentioned) do                   if submentioned == args[1] then hit2 = true result2 = true end end else if t.mentioned == args[1] then hit2 = true result2 = true end end end if hit2 == true then templist = templist .. banner(piece) end end if result2 == true then loreList = loreList .. "\n Mentioned Champion " .. templist .. " "   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 if type(t.region) == "table" then for _, subregion in pairs(t.region) do                   if subregion == args[1] then hit = true result = true end end else if t.region == 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 = "No match found for " .. args[1] .. "."   end return loreList 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 "Description not specified." 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 "Duration not specified." 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 "Loretype not specified." 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 "" 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

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 .. " " .. champion .. " " end return s end

return p

-- --