Module:SkinData

-- local p = {}

local skinData = mw.loadData('Module:SkinData/data') local lib      = require('Module:Feature') local color    = require('Module:Color') local FN       = require('Module:Filename')

-- Key: formatname   = string  - if skin name is not _ availability  = string  - Available, Legacy or Limited distribution  = string  - for limited edition skins cost          = number  - RP price release       = string  - release date retired       = string  - for skins that were made legacy after their initial release set           = string or table  - if part of a "Collection", the collection's name neweffects    = boolean - skin features new visual or sound effects newanimations = boolean - skin features new animations (even if only a recall or dance) transforming  = boolean - skin's appearance can be changed in-game filter        = boolean - skin features a voice-filter newquotes     = boolean - skin features some unique quotes newvoice      = boolean - skin features an entirely new voiceover extras        = boolean - purchasing the skin unlocks additional content (e.g. summoner icons) chromas       = table   - skin has possible chromas (including unavailable chromas) vu            = boolean - skin has been visually upgraded above its price tier (not currently used) voiceactor    = table   - voice actor(s) splashartist  = table   - splash artist(s) lore          = string  - skin lore --

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

return skinData[args[1]] end

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

return skinData[args[1]].skins[args[2] or "Original"] end

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

return skinData[args[1]].skins[args[2] or "Original"].formatname or "N/A" end

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

return skinData[args[1]].skins[args[2] or "Original"].availability end

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

return skinData[args[1]].skins[args[2] or "Original"].distribution end

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

return skinData[args[1]].skins[args[2] or "Original"].cost end

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

return skinData[args[1]].skins[args[2] or "Original"].release end

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

return skinData[args[1]].skins[args[2] or "Original"].retired end

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

return skinData[args[1]].skins[args[2] or "Original"].earlysale end

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

return skinData[args[1]].skins[args[2] or "Original"].set end

function p.getSetlist(frame) local championtable = {} local sets = {} local hash = {} local setList = mw.html.create('ul') setList:newline for x in pairs(skinData) do       table.insert(championtable, x)    end table.sort(championtable)

for _, championname in pairs(championtable) do       local skintable  = {} for championname in pairs(skinData[championname]["skins"]) do           table.insert(skintable, championname) end table.sort(skintable)

for _, skinname in pairs(skintable) do           local t = skinData[championname]["skins"][skinname] if t.set ~= nil then if type(t.set) == "table" then for _, value in pairs(t.set) do                       if (not hash[value]) then table.insert(sets, value) hash[value] = true end end else if (not hash[t.set]) then table.insert(sets, t.set) hash[t.set] = true end end end end end table.sort(sets) for _, setname in pairs(sets) do       setList :tag('li') :wikitext( .. setname .. ) :done :done :newline end return setList end

function p.getSetskins(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local skinList = mw.html.create('ul') local championtable = {} local result = false skinList:newline for x in pairs(skinData) do       table.insert(championtable, x)    end table.sort(championtable) for _, championname in pairs(championtable) do       local skintable  = {} for championname in pairs(skinData[championname]["skins"]) do           table.insert(skintable, championname) end table.sort(skintable) for _, skinname in pairs(skintable) do           local hit = false local t = skinData[championname]["skins"][skinname] if t.set ~= nil then if type(t.set) == "table" then for _, subset in pairs(t.set) do                       if subset == args[1] then hit = true result = true end end else if t.set == args[1] then hit = true result = true end end end if hit == true then skinList :tag('li') :tag('div') :addClass('skin-icon') :attr('data-champion', championname) :attr('data-skin', skinname) :wikitext(' ' .. lib.ternary(t["formatname"] ~= nil, t["formatname"], skinname .. " " .. championname) .. '') :done :done :newline end end end

if result == false then skinList :tag('li') :wikitext('No match found for ' .. args[1] .. '.') :done :newline end return skinList end

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

return skinData[args[1]].skins[args[2] or "Original"].neweffects end

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

return skinData[args[1]].skins[args[2] or "Original"].newanimations end

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

return skinData[args[1]].skins[args[2] or "Original"].transforming end

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

return skinData[args[1]].skins[args[2] or "Original"].filter end

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

return skinData[args[1]].skins[args[2] or "Original"].newquotes end

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

return skinData[args[1]].skins[args[2] or "Original"].newvoice end

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

return skinData[args[1]].skins[args[2] or "Original"].extras end

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

return skinData[args[1]].skins[args[2] or "Original"].lore end

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

return skinData[args[1]].skins[args[2] or "Original"].chromas end

function p.getChromanames(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].chromas local s = "" local chromatable = {} for chromaname in pairs(t) do       table.insert(chromatable, chromaname) end table.sort(chromatable)

for i, chromaname in pairs(chromatable) do       if i ~= 1 then s = s .. ", " .. chromaname else s = s .. chromaname end end return s end

function p.getChromagallery(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].chromas local s = "" local chromatable = {} for chromaname in pairs(t) do       table.insert(chromatable, chromaname) end table.sort(chromatable)

for i, chromaname in pairs(chromatable) do       s = s .. args[1] .." " .. (string.gsub(args[2], ' ', '') or 'Original') .. " (" .. chromaname .. ").png|" .. chromaname .. "\n" end return frame:preprocess( "") end

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

return skinData[args[1]].skins[args[2] or "Original"].vu end

function p.getSplashartist(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].splashartist local s = "" for i, splashartistname in ipairs(t) do       if i ~= 1 then s = s .. ", " .. splashartistname:gsub("% ", " ") else s = splashartistname end end return s end

function p.getVoiceactor(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].voiceactor local s = "" for i, voiceactorname in ipairs(t) do       if i ~= 1 then s = s .. ", " .. voiceactorname:gsub("% ", " ") else s = voiceactorname end end return s end

function p.skinlist(frame) local lang = mw.language.new( "en" ) local sdtable = mw.html.create('table') sdtable :addClass('sortable article-table nopadding sticky-header') :css('width','100%') :css('text-align','center') :newline :tag('tr') :tag('th') :css('width','26px') :done :newline :tag('th') :wikitext('Skin') :done :newline :tag('th') :tag('span') :attr('title','Availability') :wikitext('') :done :done :newline :tag('th') :tag('span') :attr('title','Release') :wikitext('') :done :done :newline :tag('th') :tag('span') :attr('title','Cost') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','Voice filter') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','Additional/unique quotes') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','New voiceover') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','New visual and/or sound effects') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','New animations and/or new recall animation') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','Appearance can be toggled in-game [e.g. Ctrl + 5], or the skin "evolves" over the course of the game that is not part of the champion&#39;s base mechanics.') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','Part of a Collection') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','Features lore') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('div') :attr('title','Chromas') :css('width','30px') :css('height','30px') :css('padding','5px') :wikitext('') :done :done :done :newline -- START local championtable = {} for x in pairs(skinData) do           table.insert(championtable, x)        end table.sort(championtable) for _, championname in pairs(championtable) do           local skintable  = {} for championname in pairs(skinData[championname]["skins"]) do               table.insert(skintable, championname) end table.sort(skintable) for _, skinname in pairs(skintable) do               local t = skinData[championname]["skins"][skinname] local sdnode = mw.html.create('tr') local temp = "" -- Skincircle if (skinname == "Original") then temp = "!" .. t["release"] else temp = t["release"] end sdnode :tag('td') :addClass('champion-icon') :attr('data-sort-value', championname .. temp) :attr('data-champion', championname) :attr('data-skin', skinname) :wikitext('') :done -- Skinname sdnode :tag('td') :addClass('skin-icon') :attr('data-champion', championname) :attr('data-skin', skinname) :css('text-align', 'left') :wikitext(lib.ternary(t["formatname"] ~= nil, t["formatname"], skinname .. " " .. championname)) :done -- Availability temp = "Circle.svg" if (t["availability"] == "Available") then temp = "Done.svg" end if (t["availability"] == "Legacy") then temp = "YellowLine.jpg" end if (t["availability"] == "Limited") then temp = "Not done.svg" end sdnode :tag('td') :tag('span') :attr('title', t["availability"] or 'Upcoming') :wikitext('') :done -- Release local y, m, d = t["release"]:match("(%d+)-(%d+)-(%d+)") if y == nil or m == nil or d == nil then sdnode :tag('td') :attr('data-sort-value', t["release"]) :wikitext(t["release"]) :done else sdnode :tag('td') :attr('data-sort-value', t["release"]) :wikitext(lang:formatDate('d-M-Y', t["release"])) :done end -- Cost local image = "" if (tostring(t["cost"]) == "150000") then image = "" end if (tostring(t["cost"]) == "10") then image = "" end sdnode :tag('td') :attr('data-sort-value', lib.ternary(tostring(t["cost"]) == "10", "2450", t["cost"])) :tag('span') :css('color', color.skin({t["cost"] .. ""}))                           :wikitext(image .. t["cost"]) :done :done -- Filter sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["filter"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["filter"]) ~= "nil", "", "")) :done -- Newquotes sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["newquotes"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["newquotes"]) ~= "nil", "", "")) :done -- Newvoice sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["newvoice"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["newvoice"]) ~= "nil", "", "")) :done -- Neweffects sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["neweffects"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["neweffects"]) ~= "nil", "", "")) :done -- Newanimations sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["newanimations"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["newanimations"]) ~= "nil", "", "")) :done -- Transforming sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["transforming"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["transforming"]) ~= "nil", "", "")) :done -- Set if (type(t["set"]) ~= "nil") then if (type(t["set"]) == "table") then local multisets = "" for i, current in pairs(t["set"]) do                           if i ~= 1 then multisets = multisets .. ", " .. current else multisets = multisets .. current end end sdnode :tag('td') :attr('data-sort-value', 'Multiple') :tag('span') :attr('title', multisets) :wikitext("") :done :done else sdnode :tag('td') :attr('data-sort-value', t["set"]) :tag('span') :attr('title', t["set"]) :wikitext("") :done :done end else sdnode :tag('td') :attr('data-sort-value', 0) :done end -- Transforming sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["lore"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["lore"]) ~= "nil", "", "")) :done -- Chromas if (type(t["chromas"]) == "table") then sdnode :tag('td') :addClass('chroma-icon') :attr('data-sort-value', 1) :attr('data-champion', championname) :attr('data-skin', skinname) :wikitext("") :done else sdnode :tag('td') :attr('data-sort-value', 0) :done end -- Add skin row to the table sdtable :newline :node(sdnode) end end -- END sdtable:allDone return tostring(sdtable) end

-- helper functions function table.val_to_str ( v ) if "string" == type( v ) then v = string.gsub( v, "\n", "\\n" ) if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then return "'" .. v .. "'"   end return '"' .. string.gsub(v,'"', '\\"' ) .. '"' else return "table" == type( v ) and table.tostring( v ) or     tostring( v ) end end function table.key_to_str ( k ) if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then return k else return "[" .. table.val_to_str( k ) .. "]" end end function table.tostring( tbl ) local result, done = {}, {} for k, v in ipairs( tbl ) do   table.insert( result, table.val_to_str( v ) ) done[ k ] = true end for k, v in pairs( tbl ) do   if not done[ k ] then table.insert( result,       table.key_to_str( k ) .. "=" .. table.val_to_str( v ) ) end end return "{" .. table.concat( result, "," ) .. "}" end

return p

-- --