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") local months   = { ['Jan'] = "01", ['Feb'] = "02", ['Mar'] = "03", ['Apr'] = "04", ['May'] = "05", ['Jun'] = "06", ['Jul'] = "07", ['Aug'] = "08", ['Sep'] = "09", ['Oct'] = "10", ['Nov'] = "11", ['Dec'] = "12", ['Ineligible'] = "13" }

-- 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  - 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) --

function p.skinformatname(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 end

function p.skinavailability(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.skindistribution(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.skincost(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.skinrelease(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.skinretired(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.skinearlysale(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.skinset(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.skinneweffects(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.skinnewanimations(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.skintransforming(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.skinfilter(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.skinnewquotes(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.skinnewvoice(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.skinextras(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.skinchromas(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 = "" if (type(t) == "table") then for i, v in ipairs(t) do           if i ~= 1 then s = s .. ", " .. t[i] else s = t[1] end end return s   else return nil end end

function p.skinvu(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.skinsplashartist(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 = "" if (type(t) == "table") then for i, v in ipairs(t) do           if i ~= 1 then s = s .. ", " .. t[i]:gsub("% ", " ") else s = t[1] end end return s   else return nil end end

function p.skinvoiceactor(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 = "" if (type(t) == "table") then for i, v in ipairs(t) do           if i ~= 1 then s = s .. ", " .. t[i]:gsub("% ", " ") else s = t[1] end end return s   else return nil end end

function p.skinlist(frame) local s = " " return s end

function p.test(frame) 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, including new recall animation') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','Appearance changes or can be changed in-game') :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('div') :attr('title','Chromas') :css('width','30px') :css('height','30px') :css('padding','5px') :wikitext('') :done :done :done :newline -- START local champs = {} for x in pairs(skinData) do           table.insert(champs, x)        end table.sort(champs) for i, v in pairs(champs) do           -- i = number / v = champname local skins = {} for v in pairs(skinData[v]["skins"]) do               table.insert(skins, v)            end table.sort(skins) for j, w in pairs(skins) do               -- j = number / w = skinname local t = skinData[v]["skins"][w] local sdnode = mw.html.create('tr') local temp = "" -- Skincircle if (type(t["release"]) ~= "nil") then if (w == "Original") then temp = "!" .. t["release"] else temp = t["release"] end end sdnode :tag('td') :attr('data-sort-value', v .. temp) :wikitext('') :done -- Skinname if (type(t["formatname"]) ~= "nil") then temp = t["formatname"]--:gsub("%'", "&#39;") else temp = w .. " " .. v               end sdnode :tag('td') :addClass('skin-icon') :attr('data-champion', v)                       :attr('data-skin', w)                        :css('text-align', 'left') :wikitext(temp) :done -- Availability sdnode :tag('td') :wikitext(t["availability"]) :done -- Release sdnode :tag('td') :attr('data-sort-value', t["release"]) :wikitext(t["release"]) :done -- Cost local cost = "" if (tostring(t["cost"]) == "10") then cost = "2450" else cost = t["cost"] end 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', cost) :tag('span') :css('color', color.skin({t["cost"] .. ""}))                           :wikitext(image .. t["cost"]) :done :done sdtable:newline:node(sdnode) end end -- END sdtable:allDone return tostring(sdtable) end

function p.datetest(frame) local lang = mw.language.new( "en" ) return lang:formatDate( 'M Y', "2015-03" ) 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

-- --