Main | Documentation | Usage |
This module implements {{Event Rewards}}.
local p = {}
local Card_List = require('Module:Card_List').list
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
parentFirst = true,
wrapper = { 'Template:Event Rewards' }
})
return p._main(args, frame)
end
function p._main(args)
local rewardType = args["type"] or nil
local result = mw.html.create()
local categories = mw.html.create()
local item_categories = mw.html.create()
local delimiter = ","
if ((args.sort or ""):find("¤") ~= nil) then
delimiter = "¤"
end
local card_items = {
show_caption = "1"
}
for item in string.gmatch(args.sort or "", "([^" .. delimiter .. "]+)") do
item = item:gsub("^%s*(.-)%s*$", "%1")
if args[item] ~= nil then
table.insert(card_items, { name = item, text = args[item] })
else
table.insert(card_items, { name = item, text = "?" })
end
item_categories:wikitext("[[Category:Event Rewards ", item, "]]")
end
if (rewardType == "Quest") then
categories:wikitext("[[Category:Quests with Rewards]]")
else
if (rewardType == "Original Resin") then
result:wikitext(";Rewards that depend on [[Original Resin]] spent:\n")
categories:wikitext("[[Category:Event Rewards with Original Resin]]")
elseif (rewardType == "Event Items") then
result:wikitext(";[[Event Items]] that expire at the end of the Event:\n")
categories:wikitext("[[Category:Event Rewards with Event Items]]")
elseif (rewardType ~= nil) then
categories:wikitext("[[Category:Event Rewards with ", rewardType, "]]")
end
categories:wikitext("[[Category:Events with Rewards]]")
end
categories:node(item_categories)
result:node(Card_List(card_items))
result:wikitext(require("Module:Namespace detect")._main({main=tostring(categories)}) or "")
return tostring(result)
end
return p