No edit summary |
No edit summary |
||
(21 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
local p = {} |
local p = {} |
||
local lib = require('Module:Feature') |
local lib = require('Module:Feature') |
||
+ | local json = require('Module:JSON') |
||
local userError = require('Dev:User error') |
local userError = require('Dev:User error') |
||
+ | local FN = require('Module:Filename') |
||
+ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | } |
||
+ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | } |
||
+ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | } |
||
function p.get(frame) |
function p.get(frame) |
||
Line 28: | Line 67: | ||
local champData = require('Module:Sandbox/Emptylord/Patch/data') |
local champData = require('Module:Sandbox/Emptylord/Patch/data') |
||
local champTable = {} |
local champTable = {} |
||
− | local filter = args[' |
+ | local filter = args['filter'] or "None" |
+ | local filter2 = args['filter2'] or "None" |
||
+ | local links = args['links'] or "false" |
||
+ | local gridonly = args['gridonly'] or "false" |
||
local s = "" |
local s = "" |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
− | } |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | } |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | } |
||
− | |||
⚫ | |||
⚫ | |||
end |
end |
||
table.sort(champTable) |
table.sort(champTable) |
||
− | |||
− | local champcount = #champTable |
||
local grid = mw.html.create('div') |
local grid = mw.html.create('div') |
||
Line 83: | Line 85: | ||
:css('clear', 'both') |
:css('clear', 'both') |
||
− | for |
+ | for _, champion in pairs(champTable) do |
− | if filter == "None" or champData[ |
+ | if filter == "None" or champData[champion]["projtype"] == filter or champData[champion]["projtype"] == filter2 then |
local gridnode = mw.html.create('div') |
local gridnode = mw.html.create('div') |
||
− | local _title = champData[ |
+ | local _title = champData[champion]["title"] or "" |
− | local _disp = champData[ |
+ | local _disp = champData[champion]["disp_name"] or champion |
− | local _icon = champData[ |
+ | local _icon = champData[champion]["icon"] or "ChampionSquare.png" |
− | local _image = champData[ |
+ | local _image = champData[champion]["image"] or "ChampionBanner.png" |
− | local _range = champData[ |
+ | local _range = champData[champion]["range"] or "Unspecified" |
− | local _class = champData[ |
+ | local _class = champData[champion]["class"] or "Unspecified" |
− | local _type = champData[ |
+ | local _type = champData[champion]["projtype"] or "Unspecified" |
− | local _status = champData[ |
+ | local _status = champData[champion]["projstatus"] or "Unspecified" |
− | local _cont = champData[ |
+ | local _cont = champData[champion]["contributors"] or "" |
− | local _desc = champData[i]["description"] or "" |
||
local opacity = 1 |
local opacity = 1 |
||
+ | local link = "" |
||
+ | local cursor = "default" |
||
local s = "" |
local s = "" |
||
if _type == "Unspecified" then opacity = 0.15 end |
if _type == "Unspecified" then opacity = 0.15 end |
||
+ | if _type ~= "Unspecified" then cursor = "pointer" end |
||
+ | if links ~= "false" then link = "User:Emptylord/Patch/" .. champion end |
||
⚫ | |||
+ | local _classlist = "" |
||
+ | for i in string.gmatch(_class, "([^,]+)") do |
||
+ | _classlist = superclass[i] .. "," .. i .. "," |
||
⚫ | |||
gridnode |
gridnode |
||
:addClass('grid-icon emptylord-icon roster-icon') |
:addClass('grid-icon emptylord-icon roster-icon') |
||
:attr('data-range', _range) |
:attr('data-range', _range) |
||
− | :attr('data-class', |
+ | :attr('data-class', _classlist) |
:attr('data-status', _status) |
:attr('data-status', _status) |
||
:attr('data-type', _type) |
:attr('data-type', _type) |
||
:attr('data-search', _title) |
:attr('data-search', _title) |
||
:css('opacity', opacity) |
:css('opacity', opacity) |
||
− | : |
+ | :css('cursor', cursor) |
+ | :wikitext("[[File:" .. _icon .. "|46px|link=" .. link .. "]]") |
||
:done() |
:done() |
||
− | if _type == "Unspecified" then |
+ | if _type == "Unspecified" or gridonly == "true" then |
grid |
grid |
||
:node(gridnode) |
:node(gridnode) |
||
Line 119: | Line 130: | ||
local _classlist = "" |
local _classlist = "" |
||
for i in string.gmatch(_class, "([^,]+)") do |
for i in string.gmatch(_class, "([^,]+)") do |
||
− | if i ~= " |
+ | if i ~= "Unspecified" then |
_classlist = _classlist .. "{{tip|Emptylord" .. i .. "|" .. i .. "}} " |
_classlist = _classlist .. "{{tip|Emptylord" .. i .. "|" .. i .. "}} " |
||
else |
else |
||
Line 135: | Line 146: | ||
s = s .. "<data><label>Contributors</label><default>" .. _cont .. "</default></data>" |
s = s .. "<data><label>Contributors</label><default>" .. _cont .. "</default></data>" |
||
s = s .. "</infobox>" |
s = s .. "</infobox>" |
||
⚫ | |||
+ | s = s .. "{{:User:Emptylord/Patch/" .. champion .. "}}" |
||
grid |
grid |
||
:node(gridnode) |
:node(gridnode) |
||
:newline() |
:newline() |
||
− | :wikitext(frame:preprocess("<div class='roster-info'>" .. s |
+ | :wikitext(frame:preprocess("<div class='roster-info'>" .. s .. "</div>")) |
end |
end |
||
else |
else |
Revision as of 13:14, 10 January 2020
- Quick Links
- MediaWiki:Common.js/rosterFilter.js
- Module:Sandbox/Emptylord/Navigation /doc (functions)
- Module:Sandbox/Emptylord/Navigation/patch /doc
- Module:Sandbox/Emptylord/Navigation/custom /doc
- Module:Sandbox/Emptylord/Navigation/getter
- User:Emptylord/Re-Workshop
- User:Emptylord/Template:Re-Workshop
- User:Emptylord/Template:Rework infobox
-- <pre>
local p = {}
local lib = require('Module:Feature')
local json = require('Module:JSON')
local userError = require('Dev:User error')
local FN = require('Module:Filename')
local superclass = {
["Enforcer"] = "Fighter",
["Juggernaut"] = "Fighter",
["Skirmisher"] = "Fighter",
["Artillery"] = "Slayer",
["Mage"] = "Slayer",
["Ranger"] = "Slayer",
["Rogue"] = "Slayer",
["Disruptor"] = "Support",
["Enchanter"] = "Support",
["Warden"] = "Support",
["Specialist"] = "Specialist",
["Unspecified"] = "Unspecified",
}
local fulltype = {
["Quality"] = "Quality of life",
["Rework"] = "Champion rework",
["Relaunch"] = "Champion relaunch",
["Original"] = "Original character",
["Imported"] = "Imported character",
["Adopted"] = "Adopted character",
["Unspecified"] = "Unspecified",
}
local statusflag = {
["Concept"] = "<span style='font-size: 75%; background-color: darkcyan; padding: 4px; border-radius: 4px; margin-left:1em; line-height: 18px;'>EARLY CONCEPT</span>",
["Draft"] = "<span style='font-size: 75%; background-color: darkblue; padding: 4px; border-radius: 4px; margin-left:1em; line-height: 18px;'>WORK IN PROGRESS</span>",
["Published"] = "<span style='font-size: 75%; background-color: darkgreen; padding: 4px; border-radius: 4px; margin-left:1em; line-height: 18px;'>COMPLETED</span>",
["Outdated"] = "<span style='font-size: 75%; background-color: darkred; padding: 4px; border-radius: 4px; margin-left:1em; line-height: 18px;'>OUTDATED</span>",
["Retired"] = "<span style='font-size: 75%; background-color: black; padding: 4px; border-radius: 4px; margin-left:1em; line-height: 18px;'>RETIRED</span>",
["Unspecified"] = "Unspecified",
}
function p.get(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
local get = require ('Module:Sandbox/Emptylord/Patch/getter')
local champname = args['champname'] or args[1]
local set = tonumber(args['set']) or tonumber(args[2])
local datatype = args['datatype'] or args[3]
local result = get[datatype](champname, set)
if (datatype == "active" or dataype == "passive ") and result ~= nil then
return frame:preprocess(result)
elseif result == nil then
return ""
else
return result
end
end
function p.getRoster(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
local champData = require('Module:Sandbox/Emptylord/Patch/data')
local champTable = {}
local filter = args['filter'] or "None"
local filter2 = args['filter2'] or "None"
local links = args['links'] or "false"
local gridonly = args['gridonly'] or "false"
local s = ""
for champname in pairs(champData) do
table.insert(champTable, champname)
end
table.sort(champTable)
local grid = mw.html.create('div')
grid
:attr('id', 'emptylord-grid')
:addClass('centered-grid')
:css('clear', 'both')
for _, champion in pairs(champTable) do
if filter == "None" or champData[champion]["projtype"] == filter or champData[champion]["projtype"] == filter2 then
local gridnode = mw.html.create('div')
local _title = champData[champion]["title"] or ""
local _disp = champData[champion]["disp_name"] or champion
local _icon = champData[champion]["icon"] or "ChampionSquare.png"
local _image = champData[champion]["image"] or "ChampionBanner.png"
local _range = champData[champion]["range"] or "Unspecified"
local _class = champData[champion]["class"] or "Unspecified"
local _type = champData[champion]["projtype"] or "Unspecified"
local _status = champData[champion]["projstatus"] or "Unspecified"
local _cont = champData[champion]["contributors"] or ""
local opacity = 1
local link = ""
local cursor = "default"
local s = ""
if _type == "Unspecified" then opacity = 0.15 end
if _type ~= "Unspecified" then cursor = "pointer" end
if links ~= "false" then link = "User:Emptylord/Patch/" .. champion end
local _classlist = ""
for i in string.gmatch(_class, "([^,]+)") do
_classlist = superclass[i] .. "," .. i .. ","
end
gridnode
:addClass('grid-icon emptylord-icon roster-icon')
:attr('data-range', _range)
:attr('data-class', _classlist)
:attr('data-status', _status)
:attr('data-type', _type)
:attr('data-search', _title)
:css('opacity', opacity)
:css('cursor', cursor)
:wikitext("[[File:" .. _icon .. "|46px|link=" .. link .. "]]")
:done()
if _type == "Unspecified" or gridonly == "true" then
grid
:node(gridnode)
:newline()
else
local _classlist = ""
for i in string.gmatch(_class, "([^,]+)") do
if i ~= "Unspecified" then
_classlist = _classlist .. "{{tip|Emptylord" .. i .. "|" .. i .. "}} "
else
_classlist = _classlist .. "{{tip|" .. i .. "}} "
end
end
s = s .. "<infobox>"
s = s .. "<header><div style='width:100%; text-align:center;'>".. (fulltype[_type] or "Unhandled type") .. " " .. (statusflag[_status] or "Unhandled status") .. "</div></header>"
s = s .. "<title><default>" .. _disp .. "</default></title>"
s = s .. "<data><default>[[File:" .. _image .. "|250px]]</default></data>"
s = s .. "<data><default>" .. _title .. "</default></data>"
s = s .. "<data><label>Range</label><default>{{tip|" .. _range .. "}}</default></data>"
s = s .. "<data><label>Classes</label><default>" .. _classlist .. "</default></data>"
s = s .. "<data><label>Contributors</label><default>" .. _cont .. "</default></data>"
s = s .. "</infobox>"
s = s .. "{{:User:Emptylord/Patch/" .. champion .. "}}"
grid
:node(gridnode)
:newline()
:wikitext(frame:preprocess("<div class='roster-info'>" .. s .. "</div>"))
end
else
--skip champion
end
end
return grid
end
return p
-- </pre>
-- [[Category:Lua]]