Module:IconData

-- local p = {}

local iconData = mw.loadData('Module:IconData/data') local lib      = require('Module:Feature')

-- Key:   id              - int       - icon id    nicknames       - string    - alternatative names the icon may be referred by    release         - int       - release year    availability    - string    - Available, Legacy, Unavailable and Unreleased    distribution    - string    - Store, Missions, Riot and Bundle (default: Store)    details         - string    - Additional acquisition information    set             - string    - Collection name     region          - string    - eSports Team Region    tournament      - string    - eSports Event/Tournament --

function p.getIconData(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.getId(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return iconData[args[1]].id end

function p.getNicknames(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.getRelease(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.getAvailability(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.getDistribution(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.getDetails(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.getSet(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.getRegion(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return iconData[args[1]].region end

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

return iconData[args[1]].tournament end

function p.getIconList(frame) local avatarList = mw.html.create('ol') avatarList :addClass('champion_roster') :newline local avatars = {} for x in pairs(iconData) do       table.insert(avatars, x)    end table.sort(avatars) for _, avatarname in pairs(avatars) do       local current = iconData[avatarname] if current.set == "eSports" then --do nothing else if current.nicknames ~= nil then nicknames = ", " .. current.nicknames else nicknames = "" end if current.distribution == nil then source = current.distribution else source = "Store" end avatarList :tag('li') :tag('div') :addClass('avatar-icon') :attr('data-param', avatarname) :attr('data-search', avatarname .. nicknames) :attr('data-availability', current.availability) :attr('data-distribution', source) :attr('data-set', current.set) :wikitext('') :done :done :newline end end return avatarList end

function p.getEsportsList(frame) local avatarList = mw.html.create('ol') avatarList :addClass('champion_roster') :newline local avatars = {} for x in pairs(iconData) do       table.insert(avatars, x)    end table.sort(avatars) for _, avatarname in pairs(avatars) do       local current = iconData[avatarname] if current.set == "eSports" then if current.nicknames ~= nil then nicknames = ", " .. current.nicknames else nicknames = "" end if current.distribution == nil then source = current.distribution else source = "Store" end avatarList :tag('li') :tag('div') :addClass('avatar-icon') :attr('data-param', avatarname) :attr('data-search', avatarname .. nicknames) :attr('data-availability', current.availability) :attr('data-distribution', source) :attr('data-set', current.set) :wikitext('') :done :done :newline else --do nothing end end return avatarList 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

-- --