Module:IconData

-- local p = {}

local iconData = mw.loadData('Module:IconData/data') local esportsData = mw.loadData('Module:IconData/data2') local lib      = require('Module:Feature') local color    = require('Module:Color') local FN       = require('Module:Filename')

-- Key:   nicknames       - string    - alternatative names the icon may be referred by    release         - number    - release year    availability    - string    - Available, Legacy, Returning and Unavailable    distribution    - string    - Missions, Bundle item, Limited availability and Commendation    details         - string    - Additional acquisition information    set             - string    - Collection name --

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

return iconData[args[1]] end

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

return iconData[args[1]] end

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

return iconData[args[1]].nicknames end

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

return iconData[args[1]].release end

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

return iconData[args[1]].availability end

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

return iconData[args[1]].distribution end

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

return iconData[args[1]].details end

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

return iconData[args[1]].set end

function p.iconlist(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('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 i, championname in pairs(championtable) do           local skintable  = {} for championname in pairs(skinData[championname]["skins"]) do               table.insert(skintable, championname) end table.sort(skintable) for j, skinname in pairs(skintable) do               local t = skinData[championname]["skins"][skinname] local sdnode = mw.html.create('tr') local temp = "" -- Skincircle if (type(t["release"]) ~= "nil") then if (skinname == "Original") then temp = "!" .. t["release"] else temp = t["release"] end end sdnode :tag('td') :attr('data-sort-value', championname .. temp) :wikitext('') :done -- Skinname sdnode :tag('td') :addClass('skin-icon') :attr('data-champion', championname) :attr('data-skin', skinname) :css('text-align', 'left') :wikitext(lib.ternary(type(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 sdnode :tag('td') :attr('data-sort-value', t["set"]) :tag('span') :attr('title', t["set"]) :wikitext("") :done :done else sdnode :tag('td') :attr('data-sort-value', 0) :done end -- Chromas if (type(t["chromas"]) == "table") then sdnode :tag('td') :addClass('skin-icon') :attr('data-sort-value', 1) :attr('data-champion', 'chroma//' .. championname .. '//' .. skinname .. '//' .. p.skinchromanames({championname, 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

function p.test return p.skinchromanames({'Xin Zhao', 'Dragonslayer'}) 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

-- --